2026-06-11 08:07:57 +00:00
FROM amd64/golang:1.26.4@sha256:62df9f3b009f61d598279a216566b04e5fee670eb4d979cee1b0235dd53a7571 as modules
2023-01-09 17:55:42 +01:00
WORKDIR /build
ADD go.* /build
RUN go mod download
FROM modules as build
2025-06-13 13:26:56 +02:00
ARG CI_COMMIT
2022-10-09 15:23:52 +02:00
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/,$//' ) ./...
2023-01-14 19:22:37 +01:00
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" ]
2022-10-09 15:23:52 +02:00
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 \
2025-06-13 13:26:56 +02:00
-ldflags " -w -s -X main.buildVersion= ${ CI_COMMIT } " \
2022-10-09 15:23:52 +02:00
./cmd/service/service.go
FROM scratch as export
COPY --from= build /build/coverage.txt /
2026-06-16 04:09:03 +00:00
FROM node:24.16.0-alpine@sha256:21f403ab171f2dc89bad4dd69d7721bfd15f084ccb46cdd225f31f2bc59b5c9a
2022-10-09 15:23:52 +02:00
ENV TZ Europe/Stockholm
2025-11-20 17:02:19 +01:00
# Install wgc CLI globally for Cosmo Router composition
RUN npm install -g wgc@latest
2026-05-19 05:20:34 +00:00
# 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"
2026-03-29 09:31:53 +00:00
2025-11-20 17:02:19 +01:00
# Copy timezone data and certificates
2022-10-09 15:23:52 +02:00
COPY --from= build /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from= build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
2025-11-20 17:02:19 +01:00
# Copy the service binary
2022-10-09 15:23:52 +02:00
COPY --from= build /release/service /
2025-11-20 17:02:19 +01:00
2022-10-09 15:23:52 +02:00
CMD [ "/service" ]