Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit aea9785

Browse files
author
Mike Parker
committed
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.
Signed-off-by: Mike Parker <michael.parker@docker.com>
1 parent e2d9fa3 commit aea9785

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

cmd/docker-app/deploy.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"os"
5+
46
"github.com/docker/app/internal"
57
"github.com/docker/app/internal/packager"
68
"github.com/docker/app/render"
@@ -16,14 +18,15 @@ import (
1618
)
1719

1820
type deployOptions struct {
19-
deployComposeFiles []string
20-
deploySettingsFiles []string
21-
deployEnv []string
22-
deployOrchestrator string
23-
deployKubeConfig string
24-
deployNamespace string
25-
deployStackName string
26-
deploySendRegistryAuth bool
21+
deployComposeFiles []string
22+
deploySettingsFiles []string
23+
deployEnv []string
24+
deployOrchestrator string
25+
deployKubeConfig string
26+
deployNamespace string
27+
deployStackName string
28+
deploySendRegistryAuth bool
29+
deployKeepWorkingDirectory bool
2730
}
2831

2932
// deployCmd represents the deploy command
@@ -47,6 +50,7 @@ func deployCmd(dockerCli command.Cli) *cobra.Command {
4750
cmd.Flags().StringVarP(&opts.deployNamespace, "namespace", "n", "default", "Kubernetes namespace to deploy into")
4851
cmd.Flags().StringVarP(&opts.deployStackName, "name", "d", "", "Stack name (default: app name)")
4952
cmd.Flags().BoolVarP(&opts.deploySendRegistryAuth, "with-registry-auth", "", false, "Sends registry auth")
53+
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)")
5054
if internal.Experimental == "on" {
5155
cmd.Flags().StringArrayVarP(&opts.deployComposeFiles, "compose-files", "c", []string{}, "Override Compose files")
5256
}
@@ -75,6 +79,9 @@ func runDeploy(dockerCli command.Cli, flags *pflag.FlagSet, appname string, opts
7579
if stackName == "" {
7680
stackName = internal.AppNameFromDir(app.Name)
7781
}
82+
if !opts.deployKeepWorkingDirectory {
83+
os.Chdir(app.Path)
84+
}
7885
return stack.RunDeploy(dockerCli, flags, rendered, deployOrchestrator, options.Deploy{
7986
Namespace: stackName,
8087
ResolveImage: swarm.ResolveImageAlways,

0 commit comments

Comments
 (0)