From 3593881435a0059b55f7f35c98bf9d8497b8ba9c Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Tue, 30 Jan 2024 15:18:23 +0100 Subject: [PATCH] feat: add flag to skip docker build --- cmd/project/docker_build.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/project/docker_build.go b/cmd/project/docker_build.go index 03c2ed60..eea704ea 100644 --- a/cmd/project/docker_build.go +++ b/cmd/project/docker_build.go @@ -19,7 +19,7 @@ import ( var dockerFileTemplate string var dockerBuildCmd = &cobra.Command{ - Use: "build [name]", + Use: "build [image-name]", Short: "Build Docker Image", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -36,6 +36,11 @@ var dockerBuildCmd = &cobra.Command{ return err } + if only, _ := cmd.PersistentFlags().GetBool("generate-only"); only { + logging.FromContext(cmd.Context()).Info("Dockerfile and .dockerignore generated") + return nil + } + return runTransparentCommand(exec.CommandContext(cmd.Context(), "docker", "build", "-t", args[0], ".")) }, } @@ -151,4 +156,5 @@ func renderDockerfile(cfg map[string]interface{}) ([]byte, error) { func init() { dockerRootCmd.AddCommand(dockerBuildCmd) + dockerBuildCmd.PersistentFlags().Bool("generate-only", false, "Only generate Dockerfile and .dockerignore and don't build the image") }