# Use a multi-stage build to create a minimal Docker image # Stage 1: Build the Go application FROM golang:1.23-alpine as builder # Set the working directory inside the container WORKDIR /app # Copy go.mod and go.sum files if you have them COPY go.mod go.sum ./ # Download all dependencies RUN go mod download # Copy the source code into the container COPY . . # Build the Go application RUN go build -o confetti-api main.go # Stage 2: Create a minimal image with the application binary FROM alpine:latest # Install ca-certificates to handle HTTPS requests RUN apk --no-cache add ca-certificates # Set the working directory inside the container WORKDIR /root/ # Copy the binary from the builder stage COPY --from=builder /app/confetti-api . # Expose port 8080 for the application EXPOSE 8080 # Command to run the application CMD ["./confetti-api"]