# Stage 1: Build the Go application FROM golang:1.20-alpine AS builder WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . # Stage 2: Create a minimal production image FROM alpine:latest WORKDIR /app # Copy the compiled binary from the builder stage COPY --from=builder /app/main . EXPOSE 8080 CMD ["./main"]