2023-08-24 19:35:23 +00:00
|
|
|
FROM golang:1.21-alpine as build
|
|
|
|
RUN apk add ca-certificates
|
2023-08-10 15:42:41 +00:00
|
|
|
|
|
|
|
WORKDIR /godoor
|
|
|
|
|
|
|
|
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN go mod download && go mod verify
|
|
|
|
|
|
|
|
|
|
|
|
COPY . .
|
2023-08-24 19:35:23 +00:00
|
|
|
|
|
|
|
ENV GOBUILDLDFLAGS="-linkmode 'external' -extldflags '-static'"
|
|
|
|
RUN go build -tags netgo .
|
2023-08-10 15:42:41 +00:00
|
|
|
|
|
|
|
FROM scratch
|
|
|
|
WORKDIR /
|
2023-08-24 19:35:23 +00:00
|
|
|
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
2023-08-10 15:42:41 +00:00
|
|
|
COPY --from=build /godoor/godoor /godoor
|
|
|
|
|
|
|
|
ENTRYPOINT ["/godoor"]
|