Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
35
Dockerfile
Normal file
35
Dockerfile
Normal file
@@ -0,0 +1,35 @@
|
||||
# Multi-service Dockerfile with build caching
|
||||
# Usage: docker build --build-arg SERVICE=gateway -t cloud-gateway .
|
||||
|
||||
ARG SERVICE=gateway
|
||||
|
||||
# Build stage
|
||||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache git ca-certificates
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
# Cache dependencies first (changes less often)
|
||||
COPY go.work go.work.sum* ./
|
||||
COPY pkg/go.mod pkg/go.sum* ./pkg/
|
||||
COPY services/${SERVICE}/go.mod services/${SERVICE}/go.sum* ./services/${SERVICE}/
|
||||
|
||||
RUN go mod download
|
||||
|
||||
# Copy source and build
|
||||
COPY pkg/ ./pkg/
|
||||
COPY services/${SERVICE}/ ./services/${SERVICE}/
|
||||
|
||||
WORKDIR /src/services/${SERVICE}
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /app .
|
||||
|
||||
# Runtime stage
|
||||
FROM alpine:3.20
|
||||
|
||||
RUN apk add --no-cache ca-certificates tzdata
|
||||
|
||||
COPY --from=builder /app /app
|
||||
|
||||
USER nobody:nobody
|
||||
ENTRYPOINT ["/app"]
|
||||
Reference in New Issue
Block a user