2
0
Эх сурвалжийг харах

[cli] create command: set default build context to dockerfile directory

Anukul Sangwan 4 жил өмнө
parent
commit
69ab115a86

+ 9 - 1
cli/cmd/create.go

@@ -92,7 +92,7 @@ func init() {
 		&localPath,
 		"path",
 		"p",
-		".",
+		"",
 		"if local build, the path to the build directory",
 	)
 
@@ -164,6 +164,10 @@ func createFull(resp *api.AuthCheckResponse, client *api.Client, args []string)
 
 	color.New(color.FgGreen).Printf("Creating %s release: %s\n", args[0], name)
 
+	if localPath == "" {
+		localPath = filepath.Dir(dockerfile)
+	}
+
 	fullPath, err := filepath.Abs(localPath)
 
 	if err != nil {
@@ -223,6 +227,10 @@ func handleSubdomainCreate(subdomain string, err error) error {
 }
 
 func createFromGithub(createAgent *deploy.CreateAgent, overrideValues map[string]interface{}) error {
+	if localPath == "" {
+		localPath = filepath.Dir(dockerfile)
+	}
+
 	fullPath, err := filepath.Abs(localPath)
 
 	if err != nil {

+ 7 - 1
cli/cmd/deploy/create.go

@@ -280,7 +280,13 @@ func (c *CreateAgent) CreateFromDocker(
 	}
 
 	if opts.Method == DeployBuildTypeDocker {
-		err = buildAgent.BuildDocker(agent, opts.LocalPath, ".", opts.LocalDockerfile, "latest")
+		basePath, err := filepath.Abs(".")
+
+		if err != nil {
+			return "", err
+		}
+
+		err = buildAgent.BuildDocker(agent, basePath, opts.LocalPath, opts.LocalDockerfile, "latest")
 	} else {
 		err = buildAgent.BuildPack(agent, opts.LocalPath, "latest")
 	}