medol-be/Dockerfile

21 lines
531 B
Docker
Raw Normal View History

2024-03-06 15:19:09 +00:00
FROM golang:alpine as builder
2024-03-07 10:20:51 +00:00
WORKDIR /src
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
2024-03-06 15:19:09 +00:00
RUN go mod download
2024-03-07 10:20:51 +00:00
RUN go get -v ./...
2024-03-07 09:08:02 +00:00
RUN go mod vendor
2024-03-07 10:20:51 +00:00
COPY build .
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
2024-03-07 10:20:51 +00:00
WORKDIR /src/
2024-03-06 15:19:09 +00:00
COPY --from=builder /bin/api-binary /bin/api-binary
2024-03-07 10:20:51 +00:00
COPY --from=builder --chown=nonroot /src/config /src/config
2024-03-06 15:19:09 +00:00
ENTRYPOINT ["/bin/api-binary"]