medol-be/build/Dockerfile

21 lines
527 B
Docker
Raw Normal View History

2024-03-06 15:19:09 +00:00
FROM golang:alpine as builder
WORKDIR /app
2024-03-07 09:08:02 +00:00
2024-03-06 15:19:09 +00:00
COPY go.* ./
2024-03-07 09:08:02 +00:00
RUN go get -v ./...
2024-03-06 15:19:09 +00:00
RUN go mod download
2024-03-07 09:08:02 +00:00
RUN go mod vendor
2024-03-06 15:19:09 +00:00
COPY . .
2024-03-07 09:08:02 +00:00
2024-03-06 15:19:09 +00:00
RUN apk update && apk add upx ca-certificates openssl && update-ca-certificates
2024-03-06 15:27:19 +00:00
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o /bin/api-binary ./main.go
2024-03-06 15:19:09 +00:00
RUN upx -9 /bin/api-binary
FROM gcr.io/distroless/static:nonroot
WORKDIR /app/
COPY --from=builder /bin/api-binary /bin/api-binary
COPY --from=builder --chown=nonroot /app/config /app/config
ENTRYPOINT ["/bin/api-binary"]