Skip to content

Commit f8ce554

Browse files
committed
feat: kfn build --show-dockerfile
1 parent 96175a6 commit f8ce554

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

go/cli/commands/build.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ func NewBuildCmd(ctx context.Context) *cobra.Command {
5151
"the docker image tag")
5252
r.Command.Flags().StringVarP(&r.DockerfilePath, "file", "f", "",
5353
"Name of the Dockerfile. If not given, using a default builtin Dockerfile")
54+
r.Command.Flags().BoolVarP(&r.ShowDockerfile, "show-dockerfile", "s", false,
55+
"whether to store the builtin Dockerfile in the disk. Default to false")
5456
return r.Command
5557
}
5658

@@ -60,6 +62,7 @@ type BuildRunner struct {
6062

6163
Tag string
6264
DockerfilePath string
65+
ShowDockerfile bool
6366
}
6467

6568
func (r *BuildRunner) PreRunE(cmd *cobra.Command, args []string) error {
@@ -90,8 +93,12 @@ func (r *BuildRunner) runDockerBuild() error {
9093
color.Red(strings.TrimSpace(errout.String()))
9194
return err
9295
}
96+
// TODO: Print out building process in real time.
9397
color.Green(out.String())
9498
color.Green("Image %v builds successfully. Now you can publish the image", r.Tag)
99+
if !r.ShowDockerfile {
100+
return os.Remove(r.DockerfilePath)
101+
}
95102
return nil
96103
}
97104

@@ -120,8 +127,7 @@ func (r *BuildRunner) createDockerfile() error {
120127
return err
121128
}
122129
if err := os.WriteFile(DockerfilePath, dockerfileContent, 0644); err != nil {
123-
return err
124-
}
125-
color.Green("created Dockerfile")
130+
return err
131+
}
126132
return nil
127133
}

0 commit comments

Comments
 (0)