Files
tern-server/deploy/compose.yml
T
Mateusz PstruchaandClaude Opus 5.5 0f497d88de
CI / test (push) Successful in 3m56s
Deploy tern-server on its own; accept hex keys; fix cross-origin auth
The integrated stack is gone: deploy/compose.yml is just the server and
its Postgres, published on 11901 behind the existing nginx as
tern-api.mtps.pl, and this repo's release deploys it after pushing the
image. The webapp deploys separately from tern-web.

CREDENTIAL_KEY may now be 64 hex digits as well as base64, and a wrong
length says how to generate a right one. The database password reaches
the server as PGPASSWORD rather than inside DATABASE_URL, so it needs
no URL-escaping.

CORS now names Authorization and Content-Type instead of `*`: browsers
don't let the wildcard cover Authorization, so every signed-in request
from the webapp's own origin would have been refused. A route test
checks the preflight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 12:44:22 +02:00

69 lines
2.5 KiB
YAML

# tern-server's deployment: the server and its Postgres as one compose
# project on the app host (deploy/compose in the ygg management repo), run
# by this repo's release workflow through ygg/actions/deploy. See
# deploy/README.md.
#
# `version` arrives as an extra var (the release tag without its v) and is
# templated in by Ansible. Secrets come from
# /opt/ygg/secrets/env/tern-server.env on kara, copied next to compose.yml
# as .env — never put them in here: this file is sent on the command line.
compose_project: tern-server
# The existing nginx proxies the domain to site_port on the app host; the
# include passes WebSocket upgrades through for live updates (/api/ws).
domain: tern-api.mtps.pl
cert: mtps.pl
site_port: 11901
site_includes: websocket.conf
compose:
services:
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: tern
POSTGRES_DB: tern
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in tern-server.env}
volumes:
- db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U tern -d tern"]
interval: 5s
timeout: 5s
retries: 20
server:
image: "git.app.ygg/mtps/tern-server:{{ version }}"
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
# The password goes in separately (libpq's PGPASSWORD, which sqlx
# reads), so it never needs URL-escaping inside DATABASE_URL.
DATABASE_URL: postgres://tern@db:5432/tern
PGPASSWORD: ${POSTGRES_PASSWORD}
BIND_ADDR: 0.0.0.0:8080
CREDENTIAL_KEY: ${CREDENTIAL_KEY:?set CREDENTIAL_KEY in tern-server.env}
BLOB_STORAGE_DIR: /data/blobs
SESSION_TTL_HOURS: ${SESSION_TTL_HOURS:-720}
TRASH_RETENTION_DAYS: ${TRASH_RETENTION_DAYS:-30}
OPEN_REGISTRATION: ${OPEN_REGISTRATION:-false}
PUSH_URL_REWRITE: ${PUSH_URL_REWRITE:-}
PUSH_TLS_INSECURE: ${PUSH_TLS_INSECURE:-false}
PUSH_VAPID_SUBJECT: ${PUSH_VAPID_SUBJECT:-mailto:postmaster@mtps.pl}
RUST_LOG: ${RUST_LOG:-tern_server=info}
ports:
- "11901:8080"
volumes:
- blob-data:/data/blobs
# The host's trust store, so IMAP/SMTP and push servers behind the
# internal CA are trusted like public ones.
- /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem:/etc/ssl/certs/ca-certificates.crt:ro
volumes:
db-data: {}
blob-data: {}