PostgreSQL
PostgreSQL is the default database for the production Compose stack and the recommended backend for horizontal scaling or deployments with application and worker processes on multiple hosts.
Bundled PostgreSQL
The production Docker Compose stack includes PostgreSQL 17 and stores its data in the persistent puppetflow-db volume.
Configure the shared .env file:
DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=puppetflow
DB_USERNAME=puppetflow
DB_PASSWORD=
DB_SSLMODE=preferSet a strong, unique DB_PASSWORD. The DB_DATABASE, DB_USERNAME, and DB_PASSWORD values are also used to initialize the bundled PostgreSQL container.
Start the stack and apply migrations:
docker compose up -d
docker compose exec app php artisan migrate --forceExternal PostgreSQL
For a managed or external PostgreSQL service:
DB_CONNECTION=pgsql
DB_HOST=postgres.example.internal
DB_PORT=5432
DB_DATABASE=puppetflow
DB_USERNAME=puppetflow
DB_PASSWORD=
DB_SSLMODE=requireAllow connections from every Puppetflow application and worker host. The database user must be able to create and alter tables, indexes, foreign keys, and check constraints when migrations run.
When the external service replaces the bundled database:
- Remove the
postgresservice from the customized Compose file. - Remove
depends_on: postgresfromapp,queue-1,queue-2,scheduler, andmailbox-smtp. - Remove the unused
puppetflow-dbvolume. - Recreate the Puppetflow services.
Queue, cache, and sessions
The recommended configuration keeps application state in PostgreSQL:
QUEUE_CONNECTION=database
DB_QUEUE_RETRY_AFTER=900
CACHE_STORE=database
SESSION_DRIVER=databaseThis configuration keeps queued jobs, cache entries, distributed locks, and sessions durable. Use Redis for these features only when connecting to a separate Redis deployment with persistence and backups.
Backups
Back up PostgreSQL independently from S3, R2, or local file storage. A basic logical backup is:
docker compose exec -T postgres pg_dump \
--username=puppetflow \
--dbname=puppetflow \
--format=custom > puppetflow.dumpRestore into an empty database:
cat puppetflow.dump | docker compose exec -T postgres pg_restore \
--username=puppetflow \
--dbname=puppetflow \
--clean \
--if-existsTest restore procedures regularly. Managed PostgreSQL services should also use automated snapshots and point-in-time recovery when available.
Operational checklist
- Monitor free disk space, connections, slow queries, and lock waits.
- Keep automated backups outside the database host.
- Require TLS for external database connections.
- Restrict network access to Puppetflow hosts.
- Run
php artisan migrate --forceonce during each application upgrade.
