# --- build stage ------------------------------------------------------------ FROM golang:1.22-alpine AS build WORKDIR /src # Cache dependencies first. COPY go.mod go.sum ./ RUN go mod download COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /out/server ./cmd/server # --- runtime stage ---------------------------------------------------------- FROM alpine:3.20 RUN apk add --no-cache ca-certificates && adduser -D -u 10001 app USER app WORKDIR /app COPY --from=build /out/server /app/server ENV PORT=8080 EXPOSE 8080 ENTRYPOINT ["/app/server"]