31 lines
497 B
Docker
31 lines
497 B
Docker
# Build stage
|
|
FROM golang:1.23-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy go mod files
|
|
COPY go.mod go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the binary
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o handler .
|
|
|
|
# Final stage
|
|
FROM alpine:latest
|
|
|
|
# Install ca-certificates
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy the binary from builder stage
|
|
COPY --from=builder /app/handler .
|
|
|
|
# Run the handler
|
|
CMD ["./handler"]
|