services: db: image: postgres:16-alpine container_name: healthcare_db restart: unless-stopped environment: POSTGRES_USER: healthcare POSTGRES_PASSWORD: healthcare_secret POSTGRES_DB: healthcare_db ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U healthcare -d healthcare_db"] interval: 5s timeout: 5s retries: 5 api: build: context: ./backend dockerfile: Dockerfile container_name: healthcare_api restart: unless-stopped env_file: - ./backend/.env environment: DATABASE_URL: postgresql://healthcare:healthcare_secret@db:5432/healthcare_db ports: - "8000:8000" depends_on: db: condition: service_healthy volumes: - ./backend:/app command: > sh -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload" volumes: postgres_data: