Files
scrabble-game/loadtest/Dockerfile
T
Ilia Denisov 1ba52dd0b4
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 17s
CI / ui (pull_request) Successful in 54s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m28s
refactor(deploy): make DICT_VERSION a required build arg (single-sourced)
Drop the literal version default from the build files (backend Dockerfile both
stages, loadtest Dockerfile, the compose build-arg) so the release tag is not
duplicated as a stale-prone default a newcomer can't tell from the real source.

DICT_VERSION is now required: compose uses ${DICT_VERSION:?…} and the Dockerfiles
have no ARG default, so a missing value fails loudly instead of baking a stale tag.
The tag lives only in its genuine sources — ci.yaml env (CI tests), the Gitea
TEST_/PROD_DICT_VERSION variables (deploy seed) and deploy/.env.example (local).
Adds a "Bumping the dictionary version" section to deploy/README and fixes the bare
docker-build examples (CLAUDE.md, README.md, loadtest/README) to pass --build-arg.
2026-06-22 15:03:07 +02:00

45 lines
2.1 KiB
Docker

# Multi-stage build for the R2 load harness. Mirrors backend/Dockerfile: a
# golang-alpine builder yields a static binary on distroless nonroot, with the
# dictionary DAWGs baked in from the scrabble-dictionary release (the harness runs
# the same solver as the backend, so it needs the same dictionary). The published
# scrabble-solver module is fetched from Gitea (GOPRIVATE), so the build stage needs
# git and network.
#
# The harness is not a contour service; build and run it ad hoc, from the repo root
# so go.work, pkg/, gateway/ and loadtest/ are in the Docker context:
# docker build -f loadtest/Dockerfile -t scrabble-loadtest .
# docker run --rm --network scrabble-internal -e POSTGRES_PASSWORD=... scrabble-loadtest run
# --- dictionary artifact -----------------------------------------------------
FROM alpine:3.20 AS dawg
# Required, no default: the build caller supplies the scrabble-dictionary release tag.
ARG DICT_VERSION
RUN apk add --no-cache curl tar
RUN mkdir -p /dawg \
&& curl -fsSL -o /tmp/dawg.tar.gz \
"https://gitea.iliadenisov.ru/developer/scrabble-dictionary/releases/download/${DICT_VERSION}/scrabble-dawg-${DICT_VERSION}.tar.gz" \
&& tar xzf /tmp/dawg.tar.gz -C /dawg
# --- build -------------------------------------------------------------------
FROM golang:1.26.3-alpine AS build
WORKDIR /src
# git: the published solver module is fetched from Gitea directly (GOPRIVATE).
RUN apk add --no-cache git
ENV GOPRIVATE=gitea.iliadenisov.ru/*
COPY go.work go.work.sum ./
COPY pkg ./pkg
COPY gateway ./gateway
COPY loadtest ./loadtest
# Reduce the workspace to what the harness needs: loadtest + gateway (edge proto) + pkg.
RUN go work edit -dropuse=./backend -dropuse=./platform/telegram
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -o /out/loadtest ./loadtest/cmd/loadtest
# --- runtime -----------------------------------------------------------------
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=build /out/loadtest /usr/local/bin/loadtest
COPY --from=dawg /dawg /opt/dawg
ENV LOADTEST_DAWG_DIR=/opt/dawg
ENTRYPOINT ["/usr/local/bin/loadtest"]