Deployment
Run the service with Docker Compose or Kubernetes and verify a new installation or upgrade.
On this page
The service runs a frontend, a Django backend, PostgreSQL, Redis, background workers and an event dispatcher. Production images build the frontend in advance. For live editing and automatic recompilation, use the separate development workflow.
Before you start#
Prepare a hostname, a TLS certificate, persistent database storage, and a secure place for deployment secrets. A Kubernetes deployment needs external PostgreSQL 15 or newer, Redis 7, and an ingress controller.
Back up the database and its encryption keys together. Keep the bootstrap credentials outside this service so it can start during recovery. See Backup & recovery.
Deploy with Docker Compose#
Run these commands from the repository root. On a new installation, create the production environment file:
cp .env.example .env
Edit .env before starting:
- Set
HOSTto your public hostname andHTTP_PROTOCOL=https://. - Set
DATABASE_NAMEandDATABASE_USER. Keep the bundled database and Redis service hostnames for the default Compose stack. - Generate a different random value for each required secret:
NEXTAUTH_SECRET,SECRET_KEY,SERVER_SECRET,DATABASE_PASSWORDandREDIS_PASSWORD. - Configure sign-in and optional integrations for your deployment.
For each secret, generate a fresh value using:
openssl rand -hex 32
Do not replace an existing installation's encryption keys or database credentials as part of an ordinary upgrade.
Validate and start:
docker compose config --quiet
docker compose up -d --build
docker compose ps
The default stack reads .env, runs database migrations before the backend, and uses a persistent PostgreSQL volume. .env.dev is only for the development stack. The bundled nginx certificate is self-signed; install your deployment's trusted certificate for real users.
Deploy with Helm#
The chart is in deploy/helm/matii-secret. Create a Kubernetes Secret named matii-secret, or set existingSecret to your own Secret name. Supply SECRET_KEY, DATABASE_PASSWORD, REDIS_PASSWORD, and either SERVER_SECRET or the ciphertext required by your selected key provider.
Set your image repositories and tags, database and Redis addresses, ingress/TLS settings, and trusted proxy ranges in a values file. Keep secret values in the referenced Kubernetes Secret.
helm upgrade --install secrets deploy/helm/matii-secret -f values.production.yaml
Migrations run as a pre-install or pre-upgrade Job. The chart also defines scheduled maintenance jobs, worker and dispatcher deployments, and optional monitoring resources. Review those settings in Operations.
Verify the installation#
- Check
/service/health/for process liveness. - Check
/service/readyz/for database, Redis and server-key readiness. - Sign in, create a test app and verify that an authorised member can read a test secret.
- Test a background sync and a webhook if those features are enabled.
- Run a decryption check from the backend environment:
python manage.py matii_restore_check --sample 200
Resolve any failed decryption before accepting the installation or upgrade.
Upgrade safely#
Take a backup first and retain the keys needed to decrypt it. After pulling the intended release, rebuild with docker compose up -d --build, or upgrade the Helm release with the new image tags. Check migration results, readiness, representative secrets and background jobs.
An upgrade from an older upstream installation may also need the one-time matii_scrub_token_plaintext and matii_scrub_read_event_ciphertext management commands after verification. These remove historical token plaintext and ciphertext retained in old read events; they are not ordinary per-upgrade steps.
Restricted-network deployments#
Build and mirror images and dependencies before disconnecting external access. Configure an internal Vault or OpenBao instance if using Transit for root-key protection. Disable unavailable sync targets, omit external release links, and turn off or mirror the password breach lookup service. Add only the required internal integration hosts to MATII_EGRESS_ALLOWLIST.
Continue with Configuration and Backup & recovery.