# Build stage FROM golang:1.22.2-alpine AS builder WORKDIR /app # Install dependencies RUN apk add --no-cache git # Copy go mod files COPY go.mod go.sum ./ RUN go mod download # Copy source and build COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o /supply-intelligence ./cmd/supply-intelligence # Runtime stage FROM alpine:3.19 RUN apk add --no-cache ca-certificates tzdata WORKDIR /app # Create non-root user RUN adduser -D -g '' appuser COPY --from=builder /supply-intelligence /app/supply-intelligence # Run migrations directory (can be volume-mounted for prod) COPY migrations /app/migrations USER appuser EXPOSE 8080 ENTRYPOINT ["/app/supply-intelligence"]