go.mod requires Go 1.25+, but Dockerfile was still using golang:1.22-alpine as the builder image. This caused CI build failure: "go.mod requires go >= 1.25.0 (running go 1.22.12)"
20 lines
495 B
Docker
20 lines
495 B
Docker
# Multi-stage build for MrixsCraft backend.
|
|
# Final image: ~20 MB, non-root, no toolchain.
|
|
|
|
FROM golang:1.25-alpine AS builder
|
|
WORKDIR /build
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
COPY . .
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /mc-backend ./cmd/server
|
|
|
|
FROM alpine:3.19
|
|
RUN apk --no-cache add ca-certificates
|
|
RUN adduser -D -g '' appuser
|
|
WORKDIR /app
|
|
COPY --from=builder /mc-backend .
|
|
COPY ./migrations /migrations
|
|
USER appuser
|
|
EXPOSE 8080
|
|
ENTRYPOINT ["/app/mc-backend"]
|