-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
30 lines (21 loc) · 990 Bytes
/
Copy pathDockerfile
File metadata and controls
30 lines (21 loc) · 990 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
# ── Stage 1: build ──────────────────────────────────────────────────────────
FROM golang:1.24-alpine AS builder
WORKDIR /src
# Download dependencies separately so Docker can cache this layer.
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build \
-trimpath \
-ldflags="-w -s" \
-o /k8s-api \
.
# ── Stage 2: runtime ────────────────────────────────────────────────────────
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=builder /k8s-api /k8s-api
EXPOSE 8080
# Health probe uses the binary's built-in /health endpoint
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD ["/k8s-api", "--healthcheck"]
USER nonroot:nonroot
ENTRYPOINT ["/k8s-api"]