WIP: dockerfile go

main
sudo pacman -Syu 2021-12-18 23:52:46 +07:00
parent 4554aed22d
commit f9b384d2a5
1 changed files with 25 additions and 0 deletions

View File

@ -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"]
```