# Build stage FROM golang:1.24-alpine AS builder WORKDIR /app # Install build dependencies if needed (e.g. gcc for cgo, though we disable cgo) RUN apk add --no-cache git COPY go.mod go.sum ./ RUN go mod download COPY . . # Build the application RUN CGO_ENABLED=0 GOOS=linux go build -o main ./cmd/api # Run stage FROM alpine:latest WORKDIR /app # Install runtime dependencies RUN apk add --no-cache ca-certificates # Copy binary from builder COPY --from=builder /app/main . # Copy migrations (CRITICAL for auto-migration logic) COPY --from=builder /app/migrations ./migrations # Expose port EXPOSE 8080 # Environment variables should be passed at runtime, but we can set defaults ENV PORT=8080 CMD ["./main"]