Fix attachments on deploy by switching the working directory to the new temp directory created. Also added --keep-workdir option to preserve the old behaviour.
package main
import (
+ "os"
+
"github.com/docker/app/internal"
"github.com/docker/app/internal/packager"
"github.com/docker/app/render"
@@ -24,6 +26,7 @@ type deployOptions struct {
deployNamespace string
deployStackName string
deploySendRegistryAuth bool
+ deployKeepWorkingDirectory bool
}
// deployCmd represents the deploy command
@@ -47,6 +50,7 @@ func deployCmd(dockerCli command.Cli) *cobra.Command {
cmd.Flags().StringVarP(&opts.deployNamespace, "namespace", "n", "default", "Kubernetes namespace to deploy into")
cmd.Flags().StringVarP(&opts.deployStackName, "name", "d", "", "Stack name (default: app name)")
cmd.Flags().BoolVarP(&opts.deploySendRegistryAuth, "with-registry-auth", "", false, "Sends registry auth")
+ cmd.Flags().BoolVarP(&opts.deployKeepWorkingDirectory, "keep-workdir", "", false, "Keeps the working directory from where you ran the deploy command (rather than inside the dockerapp directory)")
if internal.Experimental == "on" {
cmd.Flags().StringArrayVarP(&opts.deployComposeFiles, "compose-files", "c", []string{}, "Override Compose files")
}
@@ -75,6 +79,9 @@ func runDeploy(dockerCli command.Cli, flags *pflag.FlagSet, appname string, opts
if stackName == "" {
stackName = internal.AppNameFromDir(app.Name)
}
+ if !opts.deployKeepWorkingDirectory {
+ os.Chdir(app.Path)
+ }
return stack.RunDeploy(dockerCli, flags, rendered, deployOrchestrator, options.Deploy{
Namespace: stackName,
ResolveImage: swarm.ResolveImageAlways,
