Local Postgres and Redis via Docker Compose, with a Postgres-backed health check.
Start infrastructure:
docker compose up -dRun the API locally against the compose services:
npm install
cp .env.example .env
npm run devCheck health (expects ok when Postgres is reachable):
curl http://localhost:3000/api/healthBuild and run the API container:
docker build -t expressots-docker-compose .
docker run --rm -p 3000:3000 \
-e DB_HOST=host.docker.internal \
-e DB_PORT=5432 \
-e DB_NAME=expressots \
-e DB_USER=postgres \
-e DB_PASSWORD=postgres \
expressots-docker-composeOn Linux you may need --add-host=host.docker.internal:host-gateway.
| Variable | Default | Description |
|---|---|---|
DB_HOST |
(unset) | Postgres host (localhost when using compose) |
DB_PORT |
5432 |
Postgres port |
DB_NAME |
expressots |
Database name |
DB_USER |
postgres |
Database user |
DB_PASSWORD |
postgres |
Database password |
REDIS_URL |
(unset) | Optional Redis URL for other examples |
npm testTests run without Docker and expect a degraded health response when DB_HOST is unset.
| Example | Topic |
|---|---|
| 05-database-postgres | Postgres patterns |
| 09-message-queue | BullMQ + Redis |
| 10-redis-cache | Redis cache |