Merge pull request 'Replace runtime stage with scratch' (#112) from gigirassy/mozhi:master into master
Reviewed-on: https://codeberg.org/aryak/mozhi/pulls/112
This commit is contained in:
22
Dockerfile
22
Dockerfile
@@ -1,21 +1,17 @@
|
||||
FROM --platform=$BUILDPLATFORM golang:alpine AS build
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
WORKDIR /src
|
||||
RUN apk --no-cache add git
|
||||
RUN apk --no-cache add git ca-certificates
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
|
||||
ENV GOPRIVATE=codeberg.org/aryak/libmozhi
|
||||
#RUN go mod download
|
||||
RUN go run github.com/swaggo/swag/cmd/swag@latest init --parseDependency
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -o /src/mozhi
|
||||
|
||||
FROM alpine:3.16 AS bin
|
||||
ENV CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH}
|
||||
RUN go build -ldflags="-s -w" -o /src/mozhi .
|
||||
|
||||
FROM scratch AS runtime
|
||||
WORKDIR /app
|
||||
COPY --from=build /src/mozhi .
|
||||
|
||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
COPY --from=build /src/mozhi /app/mozhi
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["/app/mozhi", "serve"]
|
||||
ENTRYPOINT ["/app/mozhi", "serve"]
|
||||
|
||||
Reference in New Issue
Block a user