Skip to content

Commit

Permalink
update the dockerfile gen command
Browse files Browse the repository at this point in the history
  • Loading branch information
Mengqi Yu committed Sep 29, 2021
1 parent 250ea13 commit 4b0d4ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions kyaml/fn/framework/command/command.go
Expand Up @@ -122,15 +122,17 @@ func AddGenerateDockerfile(cmd *cobra.Command) {
Use: "gen [DIR]",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return ioutil.WriteFile(filepath.Join(args[0], "Dockerfile"), []byte(`FROM golang:1.15-alpine as builder
return ioutil.WriteFile(filepath.Join(args[0], "Dockerfile"), []byte(`FROM golang:1.16-alpine as builder
ENV CGO_ENABLED=0
WORKDIR /go/src/
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -tags netgo -ldflags '-w' -v -o /usr/local/bin/function ./
FROM alpine:latest
COPY --from=builder /usr/local/bin/function /usr/local/bin/function
CMD ["function"]
ENTRYPOINT ["function"]
`), 0600)
},
}
Expand Down
6 changes: 4 additions & 2 deletions kyaml/fn/framework/command/command_test.go
Expand Up @@ -45,15 +45,17 @@ func TestCommand_dockerfile(t *testing.T) {
t.FailNow()
}

expected := `FROM golang:1.15-alpine as builder
expected := `FROM golang:1.16-alpine as builder
ENV CGO_ENABLED=0
WORKDIR /go/src/
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -tags netgo -ldflags '-w' -v -o /usr/local/bin/function ./
FROM alpine:latest
COPY --from=builder /usr/local/bin/function /usr/local/bin/function
CMD ["function"]
ENTRYPOINT ["function"]
`
if !assert.Equal(t, expected, string(b)) {
t.FailNow()
Expand Down

0 comments on commit 4b0d4ca

Please sign in to comment.