-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.export-worker
More file actions
42 lines (31 loc) Β· 1.25 KB
/
Copy pathDockerfile.export-worker
File metadata and controls
42 lines (31 loc) Β· 1.25 KB
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.25-alpine AS builder
RUN apk add --no-cache git ca-certificates tzdata
WORKDIR /src
COPY go.mod ./
COPY go.sum* ./
RUN go mod download 2>/dev/null || true
COPY . .
RUN go mod tidy
ARG VERSION=dev
# Memory-conservative compile to avoid Go 1.25 inliner crashes on
# constrained CI runners. The `internal/api` package is large (~219 files)
# and the inliner can panic at sync/atomic/type.go under memory pressure.
# - GOMEMLIMIT bounds Go's GC growth so peak RSS stays within runner limits
# - `-p 2` caps parallel compile jobs (default = NumCPU, often too high)
# - `-gcflags=all=-l` disables inlining (sidesteps the inliner crash with
# a small binary-size / perf cost that's negligible for an I/O-bound
# worker)
RUN GOMEMLIMIT=2GiB CGO_ENABLED=0 GOOS=linux go build \
-p 2 \
-gcflags=all=-l \
-ldflags="-s -w -X main.Version=${VERSION}" \
-o /bin/export-worker ./cmd/export-worker
# Runtime stage β distroless
FROM gcr.io/distroless/static:nonroot
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /bin/export-worker /usr/local/bin/export-worker
USER nonroot:nonroot
EXPOSE 8082
ENTRYPOINT ["export-worker"]