FROM amd64/golang:1.27.0@sha256:47526c1fe3e75149ec38346e66f15399e20fc8044045827305dbc2814babe5a2 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.20.0-alpine@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf 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"]