Files
mozhi/Dockerfile
gigirassy f5b10d01e6 Replace runtime stage with scratch
An Alpine runtime is not necessary for a simple go binary like this with zero other folders/data, and using scratch reduces memory significantly as all that'll be running is the binary.
2025-11-01 02:40:15 +01:00

25 lines
489 B
Docker

FROM --platform=$BUILDPLATFORM golang:alpine AS build
ARG TARGETARCH
WORKDIR /src
RUN apk --no-cache add git
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go run github.com/swaggo/swag/cmd/swag@latest init --parseDependency
ENV CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH}
RUN go build -ldflags="-s -w" -o /src/mozhi ./ # adjust path if needed
FROM scratch AS runtime
WORKDIR /app
COPY --from=build /src/mozhi /app/mozhi
EXPOSE 3000
ENTRYPOINT ["/app/mozhi", "serve"]