# syntax=docker/dockerfile:1 ARG GOARCH=amd64 ARG GOOS=linux ARG CGO_ENABLED=0 ARG BUILD_TIME=unknown ARG VERSION=unknown # Stage 1: Build FROM docker.io/golang:1.24-alpine AS build ARG GOOS ARG GOARCH ARG CGO_ENABLED ARG BUILD_TIME ARG VERSION WORKDIR /src COPY go.mod go.sum ./ RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ go mod download COPY . . RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ CGO_ENABLED=${CGO_ENABLED} \ GOOS=${GOOS} \ GOARCH=${GOARCH} \ go build -trimpath \ -ldflags "-s -w -X main.BuildTime=${BUILD_TIME} -X main.Version=${VERSION}" \ -o /out/auth ./cmd/auth && \ chmod +x /out/auth # Stage 2: Runtime FROM gcr.io/distroless/static-debian13:latest AS runtime ARG BUILD_TIME ARG VERSION WORKDIR /app COPY --from=build --chown=1000:1000 /out/auth /app/bin/auth EXPOSE 8081 50052 ENTRYPOINT ["/app/bin/auth"]