Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee1a22cbe9 | ||
|
|
68ece4222e | ||
|
|
7cba86f0c4 | ||
|
|
f059d56081 | ||
|
|
3e77b7d6d1 | ||
|
|
1f6ada41e9 | ||
|
|
91dd9c5389 | ||
|
|
7d8f0448cc |
+5
-2
@@ -1,4 +1,5 @@
|
||||
TYPE=lasuite-docs
|
||||
|
||||
DOMAIN=lasuite-docs.example.com
|
||||
|
||||
## Domain aliases
|
||||
@@ -26,8 +27,10 @@ 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)
|
||||
# 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
|
||||
|
||||
##############################################################################
|
||||
# EMAIL
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
## Quick start
|
||||
|
||||
* `abra app new lasuite-docs --secrets`
|
||||
* Insert the two RSA keys, which abra cannot generate (see below)
|
||||
* `abra app config <app-name>`
|
||||
* `abra app deploy <app-name>`
|
||||
|
||||
@@ -29,13 +30,21 @@ 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:
|
||||
|
||||
```
|
||||
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 <app-name> jwt_pk v1 jwt.pem -f
|
||||
abra app secret insert <app-name> yhub_jwt_pk v1 yhub-jwt.pem -f
|
||||
rm jwt.pem yhub-jwt.pem
|
||||
```
|
||||
|
||||
## 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. The `collab_ss` secret is no longer used. The two RSA keys are generated automatically on first deploy (see "RSA keys" above).
|
||||
1. Insert the two RSA keys (see "RSA keys" above). The `collab_ss` secret is no longer used.
|
||||
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 <app-name> backend migrate_documents`. You can pass arguments, e.g. `abra app cmd <app-name> 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Set any config versions here
|
||||
# Docs: https://docs.coopcloud.tech/maintainers/handbook/#manage-configs
|
||||
export ABRA_ENTRYPOINT_VERSION=v6
|
||||
export NGINX_CONF_VERSION=v4
|
||||
export NGINX_CONF_VERSION=v5
|
||||
export PG_BACKUP_VERSION=v5
|
||||
export MINIO_INITIALIZE_VERSION=v2
|
||||
export MIGRATE_VERSION=v1
|
||||
|
||||
+38
-71
@@ -57,8 +57,7 @@ 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
|
||||
JWT_PRIVATE_KEY_FILE: /run/secrets/jwt_pk
|
||||
# Email app URL (used in email templates; matches recipe DOMAIN)
|
||||
DJANGO_EMAIL_URL_APP: "https://${DOMAIN}"
|
||||
# Conversion (file upload → Yjs via y-provider)
|
||||
@@ -73,7 +72,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:3000/conversion
|
||||
DOCSPEC_API_URL: http://docspec:4000/conversion
|
||||
# Database connection pool
|
||||
DB_PSYCOPG_POOL_ENABLED:
|
||||
# Media auth header (matches recipe nginx by default)
|
||||
@@ -106,8 +105,7 @@ 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
|
||||
YHUB_JWT_PRIVATE_KEY_FILE: /run/secrets/yhub_jwt_pk
|
||||
# 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.
|
||||
SOFT_MIGRATION: "${SOFT_MIGRATION:-true}"
|
||||
@@ -122,14 +120,14 @@ x-minio-env: &minio-env
|
||||
|
||||
services:
|
||||
app:
|
||||
image: lasuite/impress-frontend:v6.1.0
|
||||
image: lasuite/impress-frontend:v6.1.0-1
|
||||
networks:
|
||||
- backend
|
||||
deploy:
|
||||
labels:
|
||||
- "traefik.enable=false"
|
||||
- "coop-cloud.${STACK_NAME}.timeout=${TIMEOUT:-120}"
|
||||
- "coop-cloud.${STACK_NAME}.version=2.0.0+v6.0.4"
|
||||
- "coop-cloud.${STACK_NAME}.version=2.1.2+v6.1.0-1"
|
||||
user: "${DOCKER_USER:-1000}"
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080"]
|
||||
@@ -154,9 +152,7 @@ services:
|
||||
user: "${DOCKER_USER:-1000}"
|
||||
command: ["gunicorn", "-c", "/usr/local/etc/gunicorn/impress.py", "impress.wsgi:application"]
|
||||
entrypoint: >
|
||||
sh -c "while [ ! -s /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
|
||||
sh -c "if [ \"$$AUTO_MIGRATIONS\" = \"true\" ]; then /migrate.sh; fi && exec /abra-entrypoint.sh /usr/local/bin/entrypoint \"$$@\"" --
|
||||
configs:
|
||||
- source: abra_entrypoint
|
||||
target: /abra-entrypoint.sh
|
||||
@@ -173,6 +169,7 @@ services:
|
||||
- postgres_p
|
||||
- y_api_key
|
||||
- email_pass
|
||||
- jwt_pk
|
||||
|
||||
celery:
|
||||
image: lasuite/impress-backend:v6.1.0
|
||||
@@ -188,10 +185,7 @@ services:
|
||||
command: ["celery", "-A", "impress.celery_app", "worker", "-l", "INFO"]
|
||||
environment:
|
||||
<<: [*common-env, *postgres-env, *yprovider-env]
|
||||
entrypoint: >
|
||||
sh -c "while [ ! -s /keys/jwt.pem ]; do sleep 1; done; exec /abra-entrypoint.sh /usr/local/bin/entrypoint \"$$@\"" --
|
||||
volumes:
|
||||
- jwt_keys:/keys:ro
|
||||
entrypoint: ["/abra-entrypoint.sh", "/usr/local/bin/entrypoint"]
|
||||
configs:
|
||||
- source: abra_entrypoint
|
||||
target: /abra-entrypoint.sh
|
||||
@@ -205,6 +199,7 @@ services:
|
||||
- postgres_p
|
||||
- y_api_key
|
||||
- email_pass
|
||||
- jwt_pk
|
||||
|
||||
# Collaboration server: serves the websocket and holds the document content
|
||||
yhub:
|
||||
@@ -219,27 +214,28 @@ 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.
|
||||
# Since v6.1.0 the image is distroless (no shell), so this is plain node:
|
||||
# - 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
|
||||
# - then load sentry and the server in this process, like the image's
|
||||
# `node --import ./dist/sentry.js dist/server.js`
|
||||
# No `$` in here, or compose would interpolate it.
|
||||
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" });
|
||||
volumes:
|
||||
- jwt_keys:/keys:ro
|
||||
- node
|
||||
- -e
|
||||
- >-
|
||||
const fs = require('fs'), cp = require('child_process');
|
||||
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
|
||||
secrets:
|
||||
- postgres_p
|
||||
- y_api_key
|
||||
- yhub_jwt_pk
|
||||
- minio_ru
|
||||
- minio_rp
|
||||
|
||||
@@ -281,51 +277,17 @@ services:
|
||||
- y_api_key
|
||||
|
||||
docspec:
|
||||
image: ghcr.io/docspec/api:1.21.4
|
||||
image: ghcr.io/docspecio/api:3.0.2
|
||||
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"]
|
||||
# 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"]
|
||||
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:
|
||||
@@ -354,7 +316,7 @@ services:
|
||||
- postgres_p
|
||||
|
||||
redis:
|
||||
image: redis:8.10.3
|
||||
image: redis:8.12.0
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 15s
|
||||
@@ -395,7 +357,7 @@ services:
|
||||
- minio_ru
|
||||
|
||||
web:
|
||||
image: nginx:1.31.9
|
||||
image: nginx:1.31.10
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8083"]
|
||||
interval: 15s
|
||||
@@ -432,7 +394,6 @@ volumes:
|
||||
postgres:
|
||||
minio:
|
||||
yhub_valkey:
|
||||
jwt_keys:
|
||||
|
||||
configs:
|
||||
nginx_conf:
|
||||
@@ -465,6 +426,12 @@ 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}
|
||||
|
||||
+8
-2
@@ -13,6 +13,12 @@ server {
|
||||
# Disables server version feedback on pages and in headers
|
||||
server_tokens off;
|
||||
|
||||
# Docker's embedded DNS. Used to resolve yhub per request (via a variable
|
||||
# in proxy_pass) so nginx doesn't refuse to start while yhub isn't healthy
|
||||
# yet: swarm only publishes a service's DNS name once it has a healthy task.
|
||||
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||
set $yhub_upstream http://{{ env "STACK_NAME" }}_yhub:3002;
|
||||
|
||||
location @proxy_to_docs_backend {
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header Host $http_host;
|
||||
@@ -62,7 +68,7 @@ server {
|
||||
proxy_set_header Connection "Upgrade";
|
||||
|
||||
# Collaboration server
|
||||
proxy_pass http://{{ env "STACK_NAME" }}_yhub:3002;
|
||||
proxy_pass $yhub_upstream;
|
||||
|
||||
# Set appropriate timeout for WebSocket
|
||||
proxy_read_timeout 86400;
|
||||
@@ -76,7 +82,7 @@ server {
|
||||
|
||||
# Document routes (http fallback, history) and the public keys of yhub
|
||||
location ~ ^/collaboration/(ydoc|activity|changeset|rollback|jwks)/ {
|
||||
proxy_pass http://{{ env "STACK_NAME" }}_yhub:3002;
|
||||
proxy_pass $yhub_upstream;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header Origin $http_origin;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Latest images need different handling, but you should not need to change anything!
|
||||
@@ -0,0 +1 @@
|
||||
Patches nginx image
|
||||
@@ -1,18 +0,0 @@
|
||||
Fix upstream main + make v6.1.0 deployable; runtime RSA keys + docspec 1.21.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.
|
||||
|
||||
Recommended release: `abra recipe release lasuite-docs -y`
|
||||
Reference in New Issue
Block a user