8d45ae6e3b
pkg/version.Version (default "dev") is set at link time via -ldflags from each service Dockerfile's VERSION build-arg, which the deploy passes as the git tag (git describe --tags). It surfaces as the OpenTelemetry service.version resource attribute (so Grafana/Tempo are version-aware), alongside the SPA's existing About version. Adds the VERSION build-arg to the backend/gateway/validator/bot compose builds and a serviceResource test covering service.name + service.version.
36 lines
2.0 KiB
Docker
36 lines
2.0 KiB
Docker
# Telegram platform images: the home validator (HMAC of Mini App / Login Widget
|
|
# data, no Bot API, no VPN) and the remote bot (Bot API long-poll + sendMessage,
|
|
# dialing the gateway over the reverse mTLS bot-link). One build stage compiles both
|
|
# binaries; the `validator` and `bot` targets each ship one on distroless nonroot.
|
|
#
|
|
# The platform imports only the shared scrabble/pkg module, so the build drops the
|
|
# other workspace modules (backend, gateway, loadtest), the loadtest-only
|
|
# scrabble/gateway replace and the scrabble-solver replace from a copy of go.work: it
|
|
# needs neither their sources nor the solver sibling checkout.
|
|
# Build from the repository ROOT so go.work, pkg/ and platform/telegram/ are all in
|
|
# the context (see deploy/docker-compose.yml, which sets context: ..).
|
|
FROM golang:1.26.3-alpine AS build
|
|
WORKDIR /src
|
|
|
|
COPY go.work go.work.sum ./
|
|
COPY pkg ./pkg
|
|
COPY platform/telegram ./platform/telegram
|
|
|
|
# Reduce the workspace to what the platform needs: only pkg + platform/telegram.
|
|
RUN go work edit -dropuse=./backend -dropuse=./gateway -dropuse=./loadtest -dropreplace=scrabble/gateway@v0.0.0 -dropreplace=scrabble-solver
|
|
|
|
# VERSION (the deploy passes the git tag) is stamped into both binaries via the linker.
|
|
ARG VERSION=dev
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-X scrabble/pkg/version.Version=${VERSION}" -o /out/validator ./platform/telegram/cmd/validator
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-X scrabble/pkg/version.Version=${VERSION}" -o /out/bot ./platform/telegram/cmd/bot
|
|
|
|
# --- validator (home) --------------------------------------------------------
|
|
FROM gcr.io/distroless/static-debian12:nonroot AS validator
|
|
COPY --from=build /out/validator /usr/local/bin/validator
|
|
ENTRYPOINT ["/usr/local/bin/validator"]
|
|
|
|
# --- bot (remote) ------------------------------------------------------------
|
|
FROM gcr.io/distroless/static-debian12:nonroot AS bot
|
|
COPY --from=build /out/bot /usr/local/bin/bot
|
|
ENTRYPOINT ["/usr/local/bin/bot"]
|