# Build stage FROM golang:1.21-alpine AS builder WORKDIR /app # Copy go mod and sum files COPY go.mod go.sum ./ # Download dependencies RUN go mod download # Copy source code COPY . . # Build the application RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . # Final stage FROM alpine:latest # Install ca-certificates for HTTPS requests RUN apk --no-cache add ca-certificates WORKDIR /root/ # Copy the binary from builder stage COPY --from=builder /app/main . # Expose port EXPOSE 8080 # Run the binary CMD ["./main"]