# Collaboration server (yhub)
#
# It holds the content of the documents: the editors sync with it over the
# websocket, and the backend reads and writes documents through its REST API.
# Everything it reads is here, it loads none of the backend's own environment.

# Stores. The live state of a document is in valkey until a worker persists it
# to postgres, so this valkey is not a cache: losing it loses what has not been
# persisted yet. Give it its own instance, not the one Django caches in.
PORT=3002
REDIS=redis://yhub-valkey:6379
REDIS_PREFIX=yhub
# Its own database, next to the Django one on the same server in this example.
# The schema is created by `docker compose run --rm yhub npm run init-db`,
# which also creates the database when the user is allowed to.
POSTGRES=postgres://docs:<the DB_PASSWORD of env.d/postgresql>@postgresql:5432/yhub

# Backend. It answers who a user is and what they may do with a document, and
# publishes the JWKS the admin tokens it signs are verified against. The origin
# list is what a browser may open a websocket from.
COLLABORATION_BACKEND_BASE_URL=https://${DOCS_HOST}
COLLABORATION_SERVER_ORIGIN=https://${DOCS_HOST}
# Sent as X-Y-Provider-Key on the calls made to the backend, which is how they
# are exempt from the API throttling — one call per connection would hit it.
# The same value as in env.d/yprovider, where the backend reads the one it
# compares it to.
Y_PROVIDER_API_KEY=<the same random key as in env.d/yprovider>

# Signs the calls made to the backend, which reads the public half from the
# JWKS this server publishes. Its own key, never the backend's.
YHUB_JWT_PRIVATE_KEY_FILE=/keys/yhub-private.pem

# Soft migration: upgrading an instance whose documents were stored in the S3
# media bucket, seed a room from that bucket the first time it is opened. A new
# instance has nothing to migrate and leaves this off. Read the "Upgrading from
# a release before the collaboration server" section of
# documentation/installation/compose.md before turning it on.
#SOFT_MIGRATION=true
#LEGACY_S3_ENDPOINT_URL=https://${S3_HOST}
#LEGACY_S3_ACCESS_KEY_ID=<s3 access key, read-only is enough>
#LEGACY_S3_SECRET_ACCESS_KEY=<s3 secret key>
#LEGACY_S3_BUCKET_NAME=${BUCKET_NAME}
#LEGACY_S3_REGION_NAME=<region, if your provider needs one>
#LEGACY_S3_SIGNATURE_VERSION=s3v4
