Compare commits

..
1 Commits
Author SHA1 Message Date
autonomic-bot 64b1974eb8 chore: runtime RSA keys + docspec 1.21.4 on 2.0.0+v6.0.4 (valkey 9.1.3 kept)
cc-ci/testme cc-ci: success
2026-11-13 04:58:19 +00:00
4 changed files with 57 additions and 78 deletions
+1 -2
View File
@@ -1,4 +1,5 @@
TYPE=lasuite-docs
DOMAIN=lasuite-docs.example.com
## Domain aliases
@@ -26,8 +27,6 @@ SECRET_POSTGRES_P_VERSION=v1
SECRET_Y_API_KEY_VERSION=v1
# DJANGO_HOST_EMAIL_PASSWORD
SECRET_EMAIL_PASS_VERSION=v1
# (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
+1 -1
View File
@@ -29,7 +29,7 @@ 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. 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.
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 the yhub image's 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
+44 -59
View File
@@ -57,7 +57,6 @@ 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
# (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}"
@@ -106,7 +105,6 @@ 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
# (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 <app> backend migrate_documents` covered all documents.
@@ -122,7 +120,7 @@ x-minio-env: &minio-env
services:
app:
image: lasuite/impress-frontend:v6.1.0
image: lasuite/impress-frontend:v6.0.4
networks:
- backend
deploy:
@@ -139,7 +137,7 @@ services:
start_period: 10s
backend:
image: lasuite/impress-backend:v6.1.0
image: lasuite/impress-backend:v6.0.4
networks:
- backend
environment:
@@ -175,7 +173,7 @@ services:
- email_pass
celery:
image: lasuite/impress-backend:v6.1.0
image: lasuite/impress-backend:v6.0.4
networks:
- backend
healthcheck:
@@ -208,7 +206,7 @@ services:
# Collaboration server: serves the websocket and holds the document content
yhub:
image: lasuite/impress-yhub:v6.1.0
image: lasuite/impress-yhub:v6.0.4
networks:
- backend
environment: *yhub-env
@@ -219,22 +217,10 @@ services:
timeout: 5s
retries: 20
start_period: 30s
# The server never creates its schema: run the idempotent init-db before every start.
# The v6.1.0 yhub image is distroless (no shell), so the init-db + server chain is a
# plain Node script: wait for the RSA key, build POSTGRES from the secret, init-db,
# then exec the server exactly as the image's default Cmd would.
entrypoint:
- /nodejs/bin/node
- "-e"
- |-
const fs = require("fs"), cp = require("child_process");
const key = "/keys/yhub-jwt.pem";
const sleep = () => { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1000); };
for (let i = 0; i < 300 && !(fs.existsSync(key) && fs.statSync(key).size > 0); i++) sleep();
if (!(fs.existsSync(key) && fs.statSync(key).size > 0)) { console.error("yhub: RSA key never appeared in /keys"); process.exit(1); }
process.env.POSTGRES = "postgres://docs:" + encodeURIComponent(fs.readFileSync("/run/secrets/postgres_p", "utf8").trim()) + "@db:5432/yhub";
cp.execFileSync(process.execPath, ["node_modules/@y/hub/bin/init-db.js"], { stdio: "inherit" });
cp.execFileSync(process.execPath, ["--import", "./dist/sentry.js", "dist/server.js"], { stdio: "inherit" });
# The server never creates its schema: run the idempotent init-db before every start
entrypoint: >
sh -c "while [ ! -s /keys/yhub-jwt.pem ]; do sleep 1; done; export POSTGRES=\"postgres://docs:$$(node -e 'process.stdout.write(encodeURIComponent(require(\"fs\").readFileSync(\"/run/secrets/postgres_p\",\"utf8\").trim()))')@db:5432/yhub\" && node node_modules/@y/hub/bin/init-db.js && exec /usr/local/bin/entrypoint \"$$@\"" --
command: ["node", "--import", "./dist/sentry.js", "dist/server.js"]
volumes:
- jwt_keys:/keys:ro
secrets:
@@ -245,7 +231,7 @@ services:
# 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.1.3-alpine
command: ["valkey-server", "--maxmemory-policy", "volatile-lru", "--appendonly", "yes", "--appendfsync", "everysec"]
healthcheck:
test: ["CMD", "valkey-cli", "ping"]
@@ -260,45 +246,12 @@ services:
labels:
backupbot.backup: "${ENABLE_BACKUPS:-true}"
# Conversion service only since v6 (no longer serves the collaboration)
y-provider:
image: lasuite/impress-y-provider:v6.1.0
networks:
- backend
healthcheck:
# y-provider returns 403 on unauthenticated requests; wget exit 4 = network error (server down), anything else = server is responding
test: ["CMD-SHELL", "wget -qO /dev/null http://localhost:4444/ 2>/dev/null; test $$? -ne 4"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
environment: *yprovider-env
user: "${DOCKER_USER:-1000}"
entrypoint: >
sh -c "export Y_PROVIDER_API_KEY=\"$$(cat /run/secrets/y_api_key)\" && exec /usr/local/bin/entrypoint \"$$@\"" --
command: ["yarn", "start"]
secrets:
- y_api_key
docspec:
image: ghcr.io/docspec/api:1.21.4
networks:
- backend
healthcheck:
# Use 127.0.0.1, which is required instead of 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
image: lasuite/impress-yhub:v6.0.4
networks:
- backend
user: "0"
@@ -326,6 +279,38 @@ services:
chmod 0400 /keys/jwt.pem /keys/yhub-jwt.pem
while true; do sleep 3600; done
# Conversion service only since v6 (no longer serves the collaboration)
y-provider:
image: lasuite/impress-y-provider:v6.0.4
networks:
- backend
healthcheck:
# y-provider returns 403 on unauthenticated requests; wget exit 4 = network error (server down), anything else = server is responding
test: ["CMD-SHELL", "wget -qO /dev/null http://localhost:4444/ 2>/dev/null; test $$? -ne 4"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
environment: *yprovider-env
user: "${DOCKER_USER:-1000}"
entrypoint: >
sh -c "export Y_PROVIDER_API_KEY=\"$$(cat /run/secrets/y_api_key)\" && exec /usr/local/bin/entrypoint \"$$@\"" --
command: ["yarn", "start"]
secrets:
- y_api_key
docspec:
image: ghcr.io/docspec/api:1.21.4
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:3000/health"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
db:
image: pgautoupgrade/pgautoupgrade:18-debian
networks:
@@ -395,7 +380,7 @@ services:
- minio_ru
web:
image: nginx:1.31.9
image: nginx:1.31.8
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8083"]
interval: 15s
@@ -476,4 +461,4 @@ secrets:
name: ${STACK_NAME}_y_api_key_${SECRET_Y_API_KEY_VERSION}
email_pass:
external: true
name: ${STACK_NAME}_email_pass_${SECRET_EMAIL_PASS_VERSION}
name: ${STACK_NAME}_email_pass_${SECRET_EMAIL_PASS_VERSION}
+11 -16
View File
@@ -1,18 +1,13 @@
Fix upstream main + make v6.1.0 deployable; runtime RSA keys + docspec 1.21.4.
Deployability + docspec fix on top of 2.0.0+v6.0.4.
- Upstream `compose.yml` at `34e6c91` contains unresolved merge-conflict markers
(valkey 9.1.4 vs 9.1.3) around the `yhub-valkey` service — abra FATA
`yaml: line 230: could not find expected ':'`. Resolved here to a single
`yhub-valkey` bumped to `valkey/valkey:9.2.0-alpine`.
- The yhub v6.1.0 image is distroless (no shell, no /usr/local/bin/entrypoint), so
upstream's renovate bump broke the yhub service entirely. The entrypoint is now a
plain `node -e` script: wait for the RSA key, build POSTGRES from the secret, run
the idempotent init-db, then exec the server (same default Cmd).
- 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; consumers 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.
- Docspec moves to the Rust `ghcr.io/docspec/api:1.21.4` (port 3000), which Docs
>= 5.7 expects; the archived Elixir `ghcr.io/docspecio/api` (port 4000) is removed.
The backend and yhub RSA keys are now generated automatically on first deploy
into the `jwt_keys` volume (the `jwt-keys` service) and reused afterwards; no
manual secret insertion is needed. `SECRET_JWT_PK_VERSION` and
`SECRET_YHUB_JWT_PK_VERSION` are no longer used.
Recommended release: `abra recipe release lasuite-docs -y`
Docspec moves to the Rust `ghcr.io/docspec/api:1.21.4` (port 3000), which Docs
>= 5.7 expects; the archived Elixir `ghcr.io/docspecio/api` (port 4000) is
removed.
`yhub-valkey` is 9.1.3-alpine (from upstream 2.0.0); safe for this standalone,
no-auth deployment (see the valkey 9 release notes).