version: '3.8' services: db: image: postgres:15 environment: POSTGRES_DB: library POSTGRES_USER: user POSTGRES_PASSWORD: password ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U user -d library"] interval: 5s timeout: 5s retries: 5 api: build: . ports: - "8000:8000" depends_on: db: condition: service_healthy environment: - DATABASE_URL=postgresql://user:password@db:5432/library volumes: - ./app:/code/app restart: on-failure volumes: postgres_data: