2026-04-07 06:59:28 +00:00
FROM amd64/golang:1.26.1@sha256:5ba1126a6dbb65aa517ff5eaecab6abc29480671e5c0ca176192de8da9dba4b8 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-03-26 14:08:20 +00:00
FROM node:24.14.1-alpine@sha256:01743339035a5c3c11a373cd7c83aeab6ed1457b55da6a69e014a95ac4e4700b
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-03-29 09:31:53 +00:00
# Cap Node.js heap for runtime wgc invocations to prevent OOM
ENV NODE_OPTIONS = "--max-old-space-size=64"
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" ]