-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (30 loc) · 868 Bytes
/
Copy pathDockerfile
File metadata and controls
42 lines (30 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Build stage
FROM golang:1.24-alpine AS builder
WORKDIR /app
# Install dependencies
RUN apk add --no-cache git ca-certificates
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the application
ARG SERVICE=ledger
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-w -s" \
-o /app/bin/${SERVICE} \
./cmd/${SERVICE}
# Runtime stage - use distroless for security
FROM gcr.io/distroless/static-debian12:nonroot
WORKDIR /app
# Copy binary from builder
ARG SERVICE=ledger
COPY --from=builder /app/bin/${SERVICE} /app/service
# Copy CA certificates for HTTPS
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Run as non-root user (65532 is the nonroot user in distroless)
USER 65532:65532
# Expose ports
EXPOSE 8080 9090
# Run the service
ENTRYPOINT ["/app/service"]