# Multi-stage build for mock echo server
# Build context: project root (internal/service-proxy/)

# Build stage
FROM golang:1.25.4@sha256:e68f6a00e88586577fafa4d9cefad1349c2be70d21244321321c407474ff9bf2 AS builder

WORKDIR /build

# Copy only the mock server source
COPY test/e2e/mock_server/main.go .

# Build static binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
    go build -ldflags="-s -w" -o mock-server main.go

# Runtime stage
FROM gcr.io/distroless/static-debian12:nonroot

COPY --from=builder /build/mock-server /mock-server

# Use numeric UID:GID instead of username for Kubernetes compatibility.
# Kubernetes runAsNonRoot requires numeric user to verify non-root execution.
# Distroless nonroot user is 65532:65532.
USER 65532:65532

EXPOSE 8080

ENTRYPOINT ["/mock-server"]
