Files
schemas/Dockerfile
T
argoyle 921d4e39fa
schemas / vulnerabilities (pull_request) Successful in 2m10s
schemas / check (pull_request) Successful in 2m59s
schemas / check-release (pull_request) Successful in 3m35s
pre-commit / pre-commit (pull_request) Successful in 6m43s
schemas / build (pull_request) Successful in 17m35s
schemas / deploy-prod (pull_request) Has been skipped
fix: raise Node heap cap to 512MB and bump pod memory limit
The Dockerfile's NODE_OPTIONS=--max-old-space-size=64 was added to keep
idle Node memory low, but in practice it OOMs wgc router compose as soon
as the supergraph has more than a handful of subgraphs:

  FATAL ERROR: Ineffective mark-compacts near heap limit
  Allocation failed - JavaScript heap out of memory

Bake the higher cap into the image and raise the container memory limit
(k8s/deploy.yaml) so the cgroup doesn't kill the pod at the new ceiling.
Memory request stays modest so the pod still schedules tightly when idle.

The live k8s.unbound.se cluster was already patched in place (kubectl
set env + set resources). This commit makes the manifest match.
2026-05-19 06:56:12 +02:00

46 lines
1.6 KiB
Docker

FROM amd64/golang:1.26.3@sha256:f9a8afb8a11d7e9220a5e61cedf2bb34babc7618ee51838e16c120fc74e0d92f as modules
WORKDIR /build
ADD go.* /build
RUN go mod download
FROM modules as build
ARG CI_COMMIT
WORKDIR /build
ENV CGO_ENABLED=0
ADD . /build
RUN CGO_ENABLED=1 go test -mod=readonly -race -coverprofile=coverage.txt.tmp -covermode=atomic -coverpkg=$(go list ./... | tr '\n' , | sed 's/,$//') ./...
RUN ["/bin/bash", "-c", "cat coverage.txt.tmp | grep -v testing.go | grep -v -f <(find . -type f | xargs grep -l 'Code generated by github.com/99designs/gqlgen, DO NOT EDIT') > coverage.txt"]
RUN go tool cover -html=coverage.txt -o coverage.html
RUN go tool cover -func=coverage.txt
RUN rm coverage.txt.tmp
RUN GOOS=linux GOARCH=amd64 go build \
-a -installsuffix cgo \
-mod=readonly \
-o /release/service \
-ldflags "-w -s -X main.buildVersion=${CI_COMMIT}" \
./cmd/service/service.go
FROM scratch as export
COPY --from=build /build/coverage.txt /
FROM node:24.15.0-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f
ENV TZ Europe/Stockholm
# Install wgc CLI globally for Cosmo Router composition
RUN npm install -g wgc@latest
# Cap Node.js heap for runtime wgc invocations. 512MB leaves room for
# composing supergraphs with many subgraphs; lower caps (e.g. 64MB) OOM
# wgc as the subgraph count grows.
ENV NODE_OPTIONS="--max-old-space-size=512"
# Copy timezone data and certificates
COPY --from=build /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Copy the service binary
COPY --from=build /release/service /
CMD ["/service"]