services: db: image: postgres:16-alpine restart: unless-stopped environment: POSTGRES_USER: fastapiuser POSTGRES_PASSWORD: student123 POSTGRES_DB: fastapidb volumes: - postgres_data:/var/lib/postgresql/data ports: - "5432:5432" healthcheck: test: ["CMD", "pg_isready", "-U", "fastapiuser", "-d", "fastapidb"] interval: 5s timeout: 5s retries: 10 api: build: . restart: unless-stopped ports: - "8000:8000" environment: DATABASE_HOST: db DATABASE_PORT: "5432" POSTGRES_USER: fastapiuser POSTGRES_PASSWORD: student123 POSTGRES_DB: fastapidb depends_on: db: condition: service_healthy volumes: postgres_data: