services: db: image: postgres:17-alpine restart: unless-stopped environment: POSTGRES_USER: blog POSTGRES_PASSWORD: blog POSTGRES_DB: blog ports: # Host port is configurable because 5432/5433 are often taken by local installs. - "${POSTGRES_PORT:-5434}:5432" volumes: - pgdata:/var/lib/postgresql/data # Creates the blog_test and blog_e2e databases on first startup of a fresh volume. - ./docker/initdb:/docker-entrypoint-initdb.d:ro healthcheck: test: ["CMD-SHELL", "pg_isready -U blog -d blog"] interval: 3s timeout: 3s retries: 20 volumes: pgdata: