Optimized Dockerfile

This commit is contained in:
Atridad Lahiji 2024-10-21 21:20:10 -06:00
parent e18d1c9aeb
commit 12e3414833
Signed by: atridad
SSH key fingerprint: SHA256:LGomp8Opq0jz+7kbwNcdfTcuaLRb5Nh0k5AchDDb438

View file

@ -1,14 +1,17 @@
FROM golang:1.23.2 as build
FROM golang:1.23.2-alpine AS build
WORKDIR /app
COPY . .
COPY go.mod go.sum ./
RUN go mod download
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /go/bin/app
FROM gcr.io/distroless/base-debian12
COPY . .
COPY --from=build /go/bin/app /
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /go/bin/app
CMD [ "/app" ]
FROM scratch
COPY --from=build /go/bin/app /app
ENTRYPOINT ["/app"]