| 1 | # Stage one builds our programs, and then it's thrown away. |
| 2 | FROM golang:1.26.5-alpine AS build |
| 3 | WORKDIR /src |
| 4 | |
| 5 | # The modules first: built again only when go.mod or go.sum change. |
| 6 | COPY go.mod go.sum ./ |
| 7 | RUN go mod download |
| 8 | |
| 9 | COPY . . |
| 10 | RUN --mount=type=cache,target=/root/.cache/go-build \ |
| 11 | CGO_ENABLED=0 go build -trimpath -o /out/ ./cmd/api ./cmd/worker |
| 12 | |
| 13 | # Stage two is what runs. |
| 14 | FROM gcr.io/distroless/static-debian13:nonroot |
| 15 | COPY --from=build /out/ / |
| 16 | ENTRYPOINT ["/api"] |