Skip to content

Commit c5eaffc

Browse files
authored
gomodule multistage build (#274)
1 parent 6c8428f commit c5eaffc

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
FROM golang:{{VERSION}}
1+
FROM golang:{{VERSION}} AS builder
22
ENV PORT {{PORT}}
33
EXPOSE {{PORT}}
44

5-
WORKDIR /go/src/app
5+
WORKDIR /build
6+
COPY go.mod go.sum ./
7+
RUN go mod download && go mod verify
68
COPY . .
9+
RUN CGO_ENABLED=0 GOOS=linux go build -v -o app-binary
710

8-
RUN go get
9-
RUN go build -v -o app
10-
RUN mv ./app /go/bin/
11-
12-
CMD ["app"]
11+
FROM gcr.io/distroless/static-debian12
12+
WORKDIR /app
13+
COPY --from=builder /build/app-binary .
14+
CMD ["/app/app-binary"]

0 commit comments

Comments
 (0)