Use Docker Compose for local PostgreSQL on Windows, macOS, and Linux. Do not ask users to install PostgreSQL natively during first-run setup unless they explicitly choose to manage their own database.
This template currently uses the official postgres:18-alpine image. The major version is pinned to PostgreSQL 18 instead of postgres:latest so patch updates are easy while unexpected major upgrades do not break local volumes. PostgreSQL 18 is also a schema requirement for this template because Prisma models use database-generated UUIDv7 defaults through the native uuidv7() function.
Use explicit postgresql://user:password@host:port/db?schema=public URLs for Prisma commands, even on native local installs. Peer-auth style URLs without a user can make Prisma schema-engine commands fail with a generic error instead of a useful connection diagnostic.
- Windows: Docker Desktop with the WSL 2 backend enabled.
- macOS: Docker Desktop or another Docker Engine with Compose v2.
- Linux: Docker Engine and the Docker Compose plugin.
Check that Compose is available and the Docker daemon is running:
docker compose version
docker infoRun commands from the repository root.
Agents should check docker compose version and docker info before database or E2E setup. If either command fails, do this:
- Tell the user that Docker is the local app this template uses to run PostgreSQL. Do not ask them to install native PostgreSQL.
- Ask them to install/start the right Docker option for their OS:
- Windows: Docker Desktop with the WSL 2 backend enabled.
- macOS: Docker Desktop, or another Docker Engine that includes Compose v2.
- Linux: Docker Engine plus the Docker Compose plugin, with the Docker service running.
- After installation, rerun
docker compose versionanddocker info. - Continue only after both commands succeed. Then run
docker compose pull postgresanddocker compose up -d postgres.
If Docker cannot be installed on the machine, local database-backed development and E2E are blocked. Do not silently fall back to a cloud database or a different local PostgreSQL setup.
docker compose pull postgres
docker compose up -d postgres
docker compose ps postgres
docker compose exec postgres pg_isready -U superuser -d web_app_demoThe development database is:
host: localhost
port: 54329
database: web_app_demo
user: superuser
password: superpassword
DATABASE_URL: postgresql://superuser:superpassword@localhost:54329/web_app_demo?schema=public
Create the backend env file:
# macOS, Linux, or Git Bash on Windows
cp backend/.env.example backend/.env# Windows PowerShell
Copy-Item backend/.env.example backend/.envThen apply Prisma migrations:
bun run --cwd backend prisma:migrateIf 54329 is already in use, create a repository-root .env from .env.example and change POSTGRES_PORT:
# macOS, Linux, or Git Bash on Windows
cp .env.example .env# Windows PowerShell
Copy-Item .env.example .envAfter changing the port, update backend/.env so DATABASE_URL uses the same port.
postgres_test is reserved for integration, Docker smoke, and Playwright flows:
docker compose up -d postgres_testManual default connection:
host: localhost
port: 54330
database: web_app_demo_test
user: superuser
password: superpassword
TEST_DATABASE_URL: postgresql://superuser:superpassword@localhost:54330/web_app_demo_test?schema=public
Automated test runners normally set a repository-derived POSTGRES_TEST_PORT and derive TEST_DATABASE_URL from it so multiple template checkouts can run in parallel. Set POSTGRES_TEST_PORT only when a fixed test database port is required.
The test database name must end with _test. Backend integration, Docker smoke, and Playwright E2E refuse non-test database names by default so they do not write to development data.
Stop containers but keep local data:
docker compose downDelete local PostgreSQL data only when you intentionally want a clean database:
docker compose down -vPostgreSQL major upgrades are not automatic data migrations. If this template bumps from one PostgreSQL major version to another, either export/import the data manually or delete the local development volumes with docker compose down -v when the data is disposable.
- Docker Compose: https://docs.docker.com/compose/
- PostgreSQL Docker Official Image: https://hub.docker.com/_/postgres
- PostgreSQL docs: https://www.postgresql.org/docs/