services: postgres: image: postgres:16.4-bookworm environment: POSTGRES_DB: ${DATABASE_NAME:-messenger} POSTGRES_USER: ${DATABASE_USER:-messenger} POSTGRES_PASSWORD: ${DATABASE_PASSWORD:?Set DATABASE_PASSWORD in .env} volumes: - postgres-data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] interval: 5s timeout: 3s retries: 20 restart: unless-stopped api: build: context: . environment: APP_HOST: 0.0.0.0 APP_PORT: 8080 DATABASE_URL: jdbc:postgresql://postgres:5432/${DATABASE_NAME:-messenger} DATABASE_USER: ${DATABASE_USER:-messenger} DATABASE_PASSWORD: ${DATABASE_PASSWORD:?Set DATABASE_PASSWORD in .env} DATABASE_POOL_SIZE: ${DATABASE_POOL_SIZE:-10} ports: - "127.0.0.1:${APP_PORT:-8080}:8080" depends_on: postgres: condition: service_healthy restart: unless-stopped volumes: postgres-data: