6a602aefae
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 12s
CI / integration (pull_request) Successful in 16s
CI / ui (pull_request) Successful in 56s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m20s
Users who DM the bot anything but /start are relayed into a private forum supergroup, one topic per user. Operators (the chat's admins) reply in the topic and the bot copies it back to the user; an info card opening each topic carries a Block/Unblock toggle and a Clear button. State is a small JSON file on a new /data volume — the bot host has no database. Off by default (TELEGRAM_SUPPORT_CHAT_ID=0): the prod bot is unchanged until the operator sets the chat id and adds the bot as a forum admin. - internal/support: concurrency-safe JSON store (topic map, block list, relayed message ids) with field-targeted mutators and atomic save - bot/support.go: relay both ways via copyMessage, short-TTL admin cache, callback buttons, per-user topic-create lock, loop guard (skip the bot's own posts), reopen a deleted topic on the next message - config + compose + CI/prod-deploy: TELEGRAM_SUPPORT_CHAT_ID per contour + TELEGRAM_SUPPORT_STATE_DIR; bot-state named volume; /data pre-owned by UID 65532 so a fresh volume is writable under distroless - docs: ARCHITECTURE §15 + decision record, FUNCTIONAL (+ru), README
42 lines
2.3 KiB
Docker
42 lines
2.3 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
|
|
|
|
# The bot's support relay writes its JSON state under /data. Stage an empty directory
|
|
# owned by the distroless nonroot UID so a fresh named volume mounted there inherits
|
|
# writable ownership (Docker copies the image dir's mode/owner into an empty volume).
|
|
RUN mkdir -p /out/data
|
|
|
|
# --- 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
|
|
COPY --from=build --chown=65532:65532 /out/data /data
|
|
ENTRYPOINT ["/usr/local/bin/bot"]
|