# Dockerfile FROM docker.io/library/golang:1.23-alpine AS builder WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY . . # Build with optimization flags # -w -s: Strip debug symbols RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o /app/observability-core ./cmd/api # Use Google Distroless static image for minimal size and security FROM gcr.io/distroless/static:nonroot WORKDIR /app COPY --from=builder /app/observability-core . # Copy configs/migrations if needed at runtime, e.g.: # COPY --from=builder /app/migrations ./migrations USER nonroot:nonroot EXPOSE 8080 CMD ["./observability-core"]