From 7b64bd970315092a3e4c455d4d3c531cf317a627 Mon Sep 17 00:00:00 2001 From: autonomic-bot Date: Sun, 29 Nov 2026 05:02:05 +0000 Subject: [PATCH] chore: upgrade Docs to v6.1.1, valkey 9.2.1; docspec 1.21.11; runtime RSA keys --- .env.sample | 6 ++-- README.md | 13 ++------ compose.yml | 85 ++++++++++++++++++++++++++++++++++++++-------------- release/next | 26 ++++++++++++++++ 4 files changed, 93 insertions(+), 37 deletions(-) create mode 100644 release/next diff --git a/.env.sample b/.env.sample index f362dbb..6e1cafd 100644 --- a/.env.sample +++ b/.env.sample @@ -27,10 +27,8 @@ SECRET_POSTGRES_P_VERSION=v1 SECRET_Y_API_KEY_VERSION=v1 # DJANGO_HOST_EMAIL_PASSWORD SECRET_EMAIL_PASS_VERSION=v1 -# JWT_PRIVATE_KEY of the backend (RSA PEM, must be inserted manually, see README) -SECRET_JWT_PK_VERSION=v1 # generate=false -# YHUB_JWT_PRIVATE_KEY of the collaboration server (RSA PEM, must be inserted manually, see README) -SECRET_YHUB_JWT_PK_VERSION=v1 # generate=false +# (the two RSA JWT keys are no longer secrets: the jwt-keys service generates +# them into the jwt_keys volume on first deploy — see README) ############################################################################## # EMAIL diff --git a/README.md b/README.md index 84c46b2..c6210dc 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ ## Quick start * `abra app new lasuite-docs --secrets` -* Insert the two RSA keys, which abra cannot generate (see below) * `abra app config ` * `abra app deploy ` @@ -30,21 +29,13 @@ You should then be able to visit the landing page of your app, but not yet to lo ## RSA keys -Since v6, the backend and the collaboration server (`yhub`) authenticate each other with signed tokens. Each needs its own RSA private key, never the same one: - -``` -openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out jwt.pem -openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out yhub-jwt.pem -abra app secret insert jwt_pk v1 jwt.pem -f -abra app secret insert yhub_jwt_pk v1 yhub-jwt.pem -f -rm jwt.pem yhub-jwt.pem -``` +Since v6, the backend and the collaboration server (`yhub`) authenticate each other with signed tokens. Each needs its own RSA private key, never the same one. The recipe generates both automatically on first deploy into the `jwt_keys` volume (the `jwt-keys` service, using Node crypto) and reuses them on later deploys. They are not Swarm secrets because abra cannot generate PEM keys and Swarm secrets must exist before the stack is deployed. ## Upgrading from v5 to v6 v6 replaces the collaboration server. Document content moves from the minio bucket to the new `yhub` service, which stores it in its own `yhub` database. If you skip the migration, every existing document opens **empty**. See [UPGRADE.md](https://github.com/suitenumerique/docs/blob/main/UPGRADE.md) upstream for details. -1. Insert the two RSA keys (see "RSA keys" above). The `collab_ss` secret is no longer used. +1. The `collab_ss` secret is no longer used. The two RSA keys are generated automatically on first deploy (see "RSA keys" above). 2. Leave `SOFT_MIGRATION` at its default (`true`) and deploy. The `yhub` schema is created on startup. A document is copied to yhub the first time someone opens it. 3. Copy all remaining documents: `abra app cmd backend migrate_documents`. You can pass arguments, e.g. `abra app cmd backend migrate_documents -- --dry-run`. Re-run it with `--retry-failed` if some documents failed. 4. Only after that, you may set `SOFT_MIGRATION=false`. Keep the minio bucket and its object versions: they hold the document history from before v6. diff --git a/compose.yml b/compose.yml index 2f9b8fa..397e0a2 100644 --- a/compose.yml +++ b/compose.yml @@ -57,7 +57,8 @@ x-common-env: &common-env # Collaboration server (yhub), reached in-stack YHUB_API_BASE_URL: http://yhub:3002 # RSA key signing the tokens the backend presents to yhub and y-provider - JWT_PRIVATE_KEY_FILE: /run/secrets/jwt_pk + # (generated at runtime by the jwt-keys service, shared via the jwt_keys volume) + JWT_PRIVATE_KEY_FILE: /keys/jwt.pem # Email app URL (used in email templates; matches recipe DOMAIN) DJANGO_EMAIL_URL_APP: "https://${DOMAIN}" # Conversion (file upload → Yjs via y-provider) @@ -72,7 +73,7 @@ x-common-env: &common-env Y_PROVIDER_API_BASE_URL: http://y-provider:4444/api/ Y_PROVIDER_API_KEY_FILE: /run/secrets/y_api_key # DocSpec — converts .docx → BlockNote JSON, then y-provider turns that into Yjs - DOCSPEC_API_URL: http://docspec:4000/conversion + DOCSPEC_API_URL: http://docspec:3000/conversion # Database connection pool DB_PSYCOPG_POOL_ENABLED: # Media auth header (matches recipe nginx by default) @@ -105,7 +106,8 @@ x-yhub-env: &yhub-env COLLABORATION_BACKEND_BASE_URL: https://${DOMAIN} COLLABORATION_SERVER_ORIGIN: https://${DOMAIN} Y_PROVIDER_API_KEY_FILE: /run/secrets/y_api_key - YHUB_JWT_PRIVATE_KEY_FILE: /run/secrets/yhub_jwt_pk + # (generated at runtime by the jwt-keys service, shared via the jwt_keys volume) + YHUB_JWT_PRIVATE_KEY_FILE: /keys/yhub-jwt.pem # Seed documents from the pre-v6 media bucket the first time they are opened. # Only turn off once `abra app cmd backend migrate_documents` covered all documents. SOFT_MIGRATION: "${SOFT_MIGRATION:-true}" @@ -137,7 +139,7 @@ services: start_period: 10s backend: - image: lasuite/impress-backend:v6.1.0 + image: lasuite/impress-backend:v6.1.1 networks: - backend environment: @@ -152,7 +154,9 @@ services: user: "${DOCKER_USER:-1000}" command: ["gunicorn", "-c", "/usr/local/etc/gunicorn/impress.py", "impress.wsgi:application"] entrypoint: > - sh -c "if [ \"$$AUTO_MIGRATIONS\" = \"true\" ]; then /migrate.sh; fi && exec /abra-entrypoint.sh /usr/local/bin/entrypoint \"$$@\"" -- + sh -c "while [ ! -r /keys/jwt.pem ]; do sleep 1; done; if [ \"$$AUTO_MIGRATIONS\" = \"true\" ]; then /migrate.sh; fi && exec /abra-entrypoint.sh /usr/local/bin/entrypoint \"$$@\"" -- + volumes: + - jwt_keys:/keys:ro configs: - source: abra_entrypoint target: /abra-entrypoint.sh @@ -169,10 +173,9 @@ services: - postgres_p - y_api_key - email_pass - - jwt_pk celery: - image: lasuite/impress-backend:v6.1.0 + image: lasuite/impress-backend:v6.1.1 networks: - backend healthcheck: @@ -185,7 +188,10 @@ services: command: ["celery", "-A", "impress.celery_app", "worker", "-l", "INFO"] environment: <<: [*common-env, *postgres-env, *yprovider-env] - entrypoint: ["/abra-entrypoint.sh", "/usr/local/bin/entrypoint"] + entrypoint: > + sh -c "while [ ! -r /keys/jwt.pem ]; do sleep 1; done; exec /abra-entrypoint.sh /usr/local/bin/entrypoint \"$$@\"" -- + volumes: + - jwt_keys:/keys:ro configs: - source: abra_entrypoint target: /abra-entrypoint.sh @@ -199,11 +205,10 @@ services: - postgres_p - y_api_key - email_pass - - jwt_pk # Collaboration server: serves the websocket and holds the document content yhub: - image: lasuite/impress-yhub:v6.1.0 + image: lasuite/impress-yhub:v6.1.1 networks: - backend environment: *yhub-env @@ -215,6 +220,7 @@ services: retries: 20 start_period: 30s # Since v6.1.0 the image is distroless (no shell), so this is plain node: + # - wait for the RSA key the jwt-keys sidecar generates into the shared volume # - POSTGRES has no _FILE variant: build it from the postgres_p secret # - the server never creates its schema: run the idempotent init-db # (dist/init-db.js retries while postgres isn't up yet) before every start @@ -226,22 +232,28 @@ services: - -e - >- const fs = require('fs'), cp = require('child_process'); + const key = '/keys/yhub-jwt.pem'; + const hasKey = () => { try { fs.accessSync(key, fs.constants.R_OK); return true; } catch { return false; } }; + const sab = new Int32Array(new SharedArrayBuffer(4)); + for (let i = 0; i < 300 && !hasKey(); i++) Atomics.wait(sab, 0, 0, 1000); + if (!hasKey()) { console.error('yhub: RSA key never appeared in /keys'); process.exit(1); } const pw = encodeURIComponent(fs.readFileSync('/run/secrets/postgres_p', 'utf8').trim()); process.env.POSTGRES = 'postgres://docs:' + pw + '@db:5432/yhub'; const r = cp.spawnSync(process.execPath, ['/app/dist/init-db.js'], { stdio: 'inherit' }); if (r.status !== 0) process.exit(r.status ?? 1); import('/app/dist/sentry.js').then(() => import('/app/dist/server.js')); # The image's CMD gets appended to `node -e` as extra argv and is ignored + volumes: + - jwt_keys:/keys:ro secrets: - postgres_p - y_api_key - - yhub_jwt_pk - minio_ru - minio_rp # Valkey of yhub: holds updates not yet persisted to postgres, so it is a store, not a cache yhub-valkey: - image: valkey/valkey:9.2.0-alpine + image: valkey/valkey:9.2.1-alpine command: ["valkey-server", "--maxmemory-policy", "volatile-lru", "--appendonly", "yes", "--appendfsync", "everysec"] healthcheck: test: ["CMD", "valkey-cli", "ping"] @@ -258,7 +270,7 @@ services: # Conversion service only since v6 (no longer serves the collaboration) y-provider: - image: lasuite/impress-y-provider:v6.1.0 + image: lasuite/impress-y-provider:v6.1.1 networks: - backend healthcheck: @@ -277,17 +289,51 @@ services: - y_api_key docspec: - image: ghcr.io/docspecio/api:3.0.2 + image: ghcr.io/docspec/api:1.21.11 networks: - backend healthcheck: - # Use 127.0.0.1, which is required instead of localhost for this healtcheck because of elixir/busybox bindings - test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:4000/health"] + # Use 127.0.0.1 (not localhost) for this healthcheck + test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:3000/health"] interval: 15s timeout: 5s retries: 3 start_period: 10s + # Generates the two RSA keys the backend and yhub sign with, into a shared volume. + # They cannot be abra-generated secrets (PEM format) and Swarm secrets cannot be + # created at deploy time, so this idempotent sidecar creates them once and keeps them + # on the volume across redeploys. Both consumers wait for their file before starting. + # Uses a plain Node image (not the yhub image): yhub v6.1.0 is distroless (no shell). + jwt-keys: + image: node:22-alpine + networks: + - backend + user: "0" + volumes: + - jwt_keys:/keys + healthcheck: + test: ["CMD-SHELL", "[ -s /keys/jwt.pem ] && [ -s /keys/yhub-jwt.pem ]"] + interval: 15s + timeout: 5s + retries: 3 + start_period: 10s + entrypoint: ["/bin/sh", "-c"] + command: + - | + set -eu + generate() { + target="/keys/$$1" + if [ ! -s "$$target" ]; then + node -e 'const fs=require("fs");const {generateKeyPairSync}=require("crypto");const {privateKey}=generateKeyPairSync("rsa",{modulusLength:2048,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});fs.writeFileSync(process.argv[1],privateKey,{mode:0o400});' "$$target" + fi + } + generate jwt.pem + generate yhub-jwt.pem + chown -R "${DOCKER_USER:-1000}:${DOCKER_USER:-1000}" /keys + chmod 0400 /keys/jwt.pem /keys/yhub-jwt.pem + while true; do sleep 3600; done + db: image: pgautoupgrade/pgautoupgrade:18-debian networks: @@ -394,6 +440,7 @@ volumes: postgres: minio: yhub_valkey: + jwt_keys: configs: nginx_conf: @@ -426,12 +473,6 @@ secrets: postgres_p: external: true name: ${STACK_NAME}_postgres_p_${SECRET_POSTGRES_P_VERSION} - jwt_pk: - external: true - name: ${STACK_NAME}_jwt_pk_${SECRET_JWT_PK_VERSION} - yhub_jwt_pk: - external: true - name: ${STACK_NAME}_yhub_jwt_pk_${SECRET_YHUB_JWT_PK_VERSION} minio_rp: external: true name: ${STACK_NAME}_minio_rp_${SECRET_MINIO_RP_VERSION} diff --git a/release/next b/release/next new file mode 100644 index 0000000..f5ebb43 --- /dev/null +++ b/release/next @@ -0,0 +1,26 @@ +Patch upgrade to Docs v6.1.1 + valkey 9.2.1, and v6 deployable without manual keys. + +- Docs app images bumped v6.1.0 -> v6.1.1 (backend, celery, yhub, y-provider); + the frontend image stays v6.1.0-1 (no v6.1.1 frontend image published yet). + Includes upstream security fixes (access-request/role/invitation rights, + email normalization, document move/duplicate rights). Celery v6.1.1 adds + heartbeat-file probes but still answers `celery inspect ping`, so the + existing healthcheck keeps working. Auto-migrations apply 0037 on startup. + Changelog: https://github.com/suitenumerique/docs/releases/tag/v6.1.1 +- yhub-valkey bumped 9.2.0-alpine -> 9.2.1-alpine (in-line patch; bug fixes, + incl. TLS loading and the forkless-save crash). Changelog: + https://github.com/valkey-io/valkey/releases/tag/9.2.1 +- Docspec moves to the Rust `ghcr.io/docspec/api:1.21.11` (port 3000), which + Docs >= 5.7 expects; the archived Elixir `ghcr.io/docspecio/api` (port 4000) + is removed. Changelog: https://github.com/docspec/docspec/releases + (1.21.4 -> 1.21.11 is within-major, no breaking changes; 2.0.0 is still RC). +- The two RSA JWT keys (backend <-> yhub) are now generated at runtime by a + `jwt-keys` sidecar (`node:22-alpine`) into the `jwt_keys` volume; the backend, + celery and yhub wait for their file. `SECRET_JWT_PK_VERSION` / + `SECRET_YHUB_JWT_PK_VERSION` are gone -- fresh installs deploy without manual + `abra app secret insert` of PEMs, and upgrades move to the new keys + transparently. +- Postgres stays pgautoupgrade 18-debian: the same-shape 19-debian image is a + DB major and is held (app support / migration window not declared). + +Recommended release: `abra recipe release lasuite-docs -z`