From f9b384d2a5190b2e0560e5370d032d90ef0fe285 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Sat, 18 Dec 2021 23:52:46 +0700 Subject: [PATCH] WIP: dockerfile go --- posts/2021-12-18-dockerfile-go.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 posts/2021-12-18-dockerfile-go.md diff --git a/posts/2021-12-18-dockerfile-go.md b/posts/2021-12-18-dockerfile-go.md new file mode 100644 index 0000000..742551c --- /dev/null +++ b/posts/2021-12-18-dockerfile-go.md @@ -0,0 +1,25 @@ +# Dockerfile for Go + +Each time I start new Go project, I repeat many steps. +Like set up `.gitignore`, CI configs, Dockerfile, ... + +So I decide to have a baseline Dockerfile like this: + +```Dockerfile +FROM golang:1.18beta1-bullseye as builder + +WORKDIR /build + +COPY go.mod . +COPY go.sum . +COPY vendor . +COPY . . + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOAMD64=v3 go build -o ./app main.go + +FROM gcr.io/distroless/base-debian11 + +COPY --from=builder /build/app /app + +ENTRYPOINT ["/app"] +```