Organize/docker-compose.yml

42 lines
1.4 KiB
YAML

services:
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
# Local filesystem bind mount, not a named Docker volume.
- ./data/postgres:/var/lib/postgresql/data
ports:
# Exposed on the host so host-side tooling (prisma migrate/dev, npm run
# dev with the .env's localhost DATABASE_URL) can reach it. The app
# container still connects over the compose network's "db" hostname.
- "${DB_PORT:-5432}:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 10
app:
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
# Points at the "db" service by its compose network name -- distinct
# from the .env's localhost URL used for host-side `npm run dev`.
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?schema=public
AUTH_SECRET: ${AUTH_SECRET}
NODE_ENV: production
ports:
# Host-side port only -- the container itself always listens on
# 3000 internally (see Dockerfile's EXPOSE). Defaults to 3000 if
# APP_PORT isn't set.
- "${APP_PORT:-3000}:3000"