34 lines
551 B
Docker
34 lines
551 B
Docker
# Build stage
|
|
FROM golang:1.25.5-alpine AS builder
|
|
|
|
WORKDIR /build
|
|
|
|
# Copy go mod files (for better caching)
|
|
COPY app/go.mod app/go.sum ./
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY app/ ./
|
|
|
|
# Build the application
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gateway .
|
|
|
|
# Runtime stage
|
|
FROM alpine:latest
|
|
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy binary from builder
|
|
COPY --from=builder /build/gateway .
|
|
|
|
# Copy configuration
|
|
COPY gateway.yaml .
|
|
|
|
# Expose port
|
|
EXPOSE 8080
|
|
|
|
# Run the gateway
|
|
CMD ["./gateway"]
|