High Availability Setup
For production environments where data integrity and uptime are critical, we strictly recommend decoupling your state from your containers.
In the default docker-compose.yml, the database (PostgreSQL) and cache (Redis) run inside containers. If the host disk fails or the container volume is accidentally pruned, you lose data.
The Architecture
Section titled “The Architecture”In this setup:
-
Stateless Containers: backend, frontend, and publisher run on your compute nodes (VPS, App Platform, ECS).
-
Managed Database: PostgreSQL is hosted by a provider (AWS RDS, DigitalOcean Managed Databases, Neon).
-
Managed Cache: Redis is hosted by a provider (AWS ElastiCache, Upstash, DigitalOcean Managed Redis).
General Implementation Steps
Section titled “General Implementation Steps”-
Create your PostgreSQL 16+ database and Redis 7+ instance. Obtain the connection strings for both services.
-
Use the Stateless Compose File We provide a specific configuration file for this purpose: stateless docker-compose.yml.
-
Configure Environment Variables
You must override the default connection variables in your environment variables:
Terminal window # Point to your managed databaseDATABASE_URL="postgresql://doadmin:password@private-db-postgresql-nyc1.db.ondigitalocean.com:25060/isekai?sslmode=require"# Point to your managed RedisREDIS_URL="rediss://default:password@private-db-redis-nyc1.db.ondigitalocean.com:25061"# Ensure session store uses RedisSESSION_STORE="redis" -
Running Migrations
Since the database is external, the application container might need to run migrations on startup. Our backend Docker image tries to run migrations on boot. If you have issues, you can run migrations manually from your local machine if you have the env vars set:
Terminal window export DATABASE_URL="your-production-url"pnpm db:migrate