From 27b3e0aaaec03d7e7ec9143f5316a9712b7b5c20 Mon Sep 17 00:00:00 2001 From: Sergey Lukashenko Date: Sat, 21 Nov 2026 00:14:07 +0300 Subject: [PATCH] fix: update gateway to nginx 1.31.9 --- AGENTS.md | 3 ++- Dockerfile.gateway | 2 +- Dockerfile.gateway-base | 2 +- MEMORY.md | 2 ++ structure_and_data.md | 7 ++++++- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index f54a23a..0536ce5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -14,7 +14,7 @@ - CI may only read and patch the existing `belki-runtime` Secret; it cannot list Secrets or create new ones. Bootstrap that Secret out of band before the first deploy. The multi-proxy ingress chain hides the real client IP from the app, so `BELKI_ADMIN_RATE_LIMIT_EXEMPT_PROXY_CIDRS` skips the app's shared login lockout for proxy peers. Enforce public rate limiting at the outermost proxy, and review the pod CIDR exemption against live networking after cluster changes. Never trust forwarded client-IP headers in the app for this purpose. - The production build uses the GitLab runner tag `fast`, a privileged Docker executor, and an explicit `docker:29.6.1-dind` service alias over TCP. - Production images and Kubernetes workloads are amd64-only. Preserve `linux/amd64` in Dockerfiles, CI build commands, and workload node selectors; do not reintroduce the arm64-only Python base tag. -- When adding, removing, or updating a runtime dependency, rebuild and push the matching immutable base image to `reg.nyan404.ru`, then update its tag in the final Dockerfile before running CI. `requirements.txt` maps to `Dockerfile.base`; `nginx.conf` maps to `Dockerfile.gateway-base`. +- CI builds the Belki dependency base from `Dockerfile.base` and `requirements.txt`. For Nginx version updates, pin the upstream Linux amd64 image digest in `Dockerfile.gateway-base`, publish a new immutable tag to `reg.nyan404.ru/cwshed/cwshed-base`, and set its tag and digest in `Dockerfile.gateway` before running CI. - Use Context7 for current official documentation when implementing or changing an external API, framework, or library integration. - Before adding or updating any dependency, use `prevent-eol` to check lifecycle support; do not treat its results as a vulnerability assessment. - For web UI work, use the project-local `.codex/skills/frontend-craft`, `.codex/skills/frontend-design`, and `.codex/skills/ui-ux-pro-max` instructions: establish a deliberate visual direction, preserve accessibility and interaction quality, then inspect the rendered result. @@ -27,6 +27,7 @@ - Weather easter egg: `python -m unittest discover -s tests -p test_weather.py -q` and `node --check web/weather-effect.js`; inspect `/belki` and `/admin` with rain/snow/mixed fixtures, mobile widths, reduced motion, and API failure. Prefer the remote test-zone MCP when exposed; otherwise use an isolated local server with temporary SQLite paths and stop it after validation. Keep screenshots outside the repo. - For CI-only changes, prefer a targeted YAML parse and a diff review. - For image/runtime changes, check the `Dockerfile`, Python entrypoint, static asset serving, and CI job together. +- For Nginx upgrades, check `nginx -v` and `nginx -t` on the built gateway release. An isolated syntax check can resolve the Kubernetes hostname with `--network none --add-host belki-bot:127.0.0.1`. - Python 3.12 slim does not recognize WebP in strict `mimetypes.guess_type()` without system MIME data. Keep the explicit `image/webp` response in `Handler._file`; `tests.test_lu_trainer` covers a missing MIME mapping. Do not rely only on workstation MIME tables when adding media formats. - For k3s changes, validate YAML and current cluster inventory first; keep `KUBE_CONFIG_B64` masked/protected in GitLab. - Do not add unnecessary local build artifacts or temporary files to the repository. diff --git a/Dockerfile.gateway b/Dockerfile.gateway index c86b8c5..b0fad18 100644 --- a/Dockerfile.gateway +++ b/Dockerfile.gateway @@ -1,4 +1,4 @@ -FROM --platform=linux/amd64 reg.nyan404.ru/cwshed/cwshed-base:nginx-c2431df29ccc +FROM --platform=linux/amd64 reg.nyan404.ru/cwshed/cwshed-base:nginx-1.31.9-7f5475ebf9a3@sha256:aee05868dfe80007150fff6083527191b3c370a8a66d2d6cc4348e8d2e179657 COPY nginx.conf /etc/nginx/nginx.conf COPY web /usr/share/nginx/html diff --git a/Dockerfile.gateway-base b/Dockerfile.gateway-base index 1a1d0e6..dd40479 100644 --- a/Dockerfile.gateway-base +++ b/Dockerfile.gateway-base @@ -1,4 +1,4 @@ -FROM nginx:alpine +FROM --platform=linux/amd64 nginx:1.31.9-alpine@sha256:e68702efeaad0be9ced2b4d1cedb62cd15f5d51865d913955a883f653cd9e117 ENV LANG=C.UTF-8 \ LC_ALL=C.UTF-8 diff --git a/MEMORY.md b/MEMORY.md index cacd18a..47af923 100644 --- a/MEMORY.md +++ b/MEMORY.md @@ -1,5 +1,7 @@ # MEMORY +- 2026-11-21: the Nginx gateway base moved from 1.31.4 to 1.31.9. The versioned upstream image and private registry base are pinned by Linux amd64 digest. Publish a new immutable gateway base and update the release reference on future binary upgrades. The private base push and isolated gateway checks were verified. Production rollout is pending. + - 2026-11-17 owner correction: «вход всегда на клетке x1 y1, выход может быть в разных местах». This supersedes upstream-derived fixed transition positions. Entrance is now index 0; each field owns its exit. UI labels use one-based X right/Y down with x1 y1 top-left. Random selection from the other 59 cells is the implementation choice for variable exits, not a verified CatWar distribution. Keep 5/3 initial safe cells separate from transitions and keep scene/map synchronized after restart. - 2026-11-17: CI Python 3.12 slim returns `(None, None)` for `mimetypes.guess_type("forest.webp")`; WebP is only in its non-strict common table without system MIME data. `Handler._file` now explicitly serves `.webp` as `image/webp`, independent of host MIME tables. HTTP regression coverage simulates an absent mapping; retain it when modifying static serving. diff --git a/structure_and_data.md b/structure_and_data.md index ed3cc05..01b7c86 100644 --- a/structure_and_data.md +++ b/structure_and_data.md @@ -1,5 +1,10 @@ # Structure and Data +## Gateway Nginx security update (2026-11-21) + +- The previous registry base contained Nginx 1.31.4. The rebuilt Linux amd64 gateway uses Nginx 1.31.9 on Alpine, the mainline security release from 2026-11-18. `Dockerfile.gateway-base` pins the upstream digest. `Dockerfile.gateway` pins the verified private registry digest so the next CI build picks up the new binary. [NGINX security advisories](https://nginx.org/en/security_advisories.html) +- The base was published to the private registry under a new tag. The release image passed `nginx -t` and isolated smoke checks for the homepage, trainer aliases, WebP MIME type, Belki web/API proxy, and the exact VK callback POST route with loopback upstreams. The production rollout is pending. + ## Trainer entrance and variable exit — 2026-11-17 - Applied the owner correction: entrance always `x1 y1`, exit can vary. `engine.js` sets start index 0 and chooses an exit per field from the other 59 cells. The fixed global exit constant is removed; `view()` exposes transition coordinates and per-cell entrance/exit flags. The generator reserves both transitions and a safe connecting path, preserving hazard formulas and 5/3 initially playable safe cells in the top row excluding transitions. @@ -95,7 +100,7 @@ - GitLab CI runs the build job. - Production container architecture is explicitly `linux/amd64`: CI sets `DOCKER_DEFAULT_PLATFORM` and passes `--platform linux/amd64`, Dockerfiles pin the platform, and Kubernetes workloads select nodes labeled `kubernetes.io/arch: amd64`. The former private Python base tag was arm64-only and is no longer used by the application image. - The job targets GitLab runner tag `fast` and builds through a privileged `docker:29.6.1-dind` service at `DOCKER_HOST=tcp://docker:2375`, with an explicit `alias: docker` and `DOCKER_TLS_CERTDIR=""`. -- Runtime dependency layers are prebuilt and stored in the private registry: `reg.nyan404.ru/cwshed-clone/belki-base:py312-d6c42c4497ce` contains Python 3.12, `pip 26.2.1`, and the current `requirements.txt`; `reg.nyan404.ru/cwshed/cwshed-base:nginx-c2431df29ccc` provides Nginx. Adding, removing, or updating a runtime dependency requires rebuilding/pushing and retagging the matching base image before CI. The final gateway image copies both `nginx.conf` and static assets so routing changes ship in an ordinary release. +- Runtime dependency layers are stored in the private registry. CI builds the Belki base from `Dockerfile.base`. For Nginx version upgrades, build and publish a new gateway base under `reg.nyan404.ru/cwshed/cwshed-base`, then set its tag and digest in `Dockerfile.gateway` before running CI. The final gateway image copies both `nginx.conf` and static assets so routing changes ship in an ordinary release. - The `ryzen-runner-dind` service on `root@10.3.1.168` has a valid Runner registration and its helper container can reach `https://git.nyan404.ru/`. On 2026-08-21 its malformed `DOCKER_AUTH_CONFIG` was removed and the pre-change configuration was backed up on the host as `/etc/gitlab-runner/config.toml.bak-20260821-1334`. - The job waits for the DinD daemon and runs `docker info` before starting the build. - GitLab Runner retries source checkout up to three times (`GET_SOURCES_ATTEMPTS=3`) to absorb transient connectivity failures before the job script starts. A persistent inability to reach `git.nyan404.ru:443` still requires repair on the selected runner host.