Skip to content

Commit

Permalink
feat: add flag to skip docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 30, 2024
1 parent 9b54b5f commit 3593881
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/project/docker_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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], "."))
},
}
Expand Down Expand Up @@ -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")
}

0 comments on commit 3593881

Please sign in to comment.