Files
Database-FastAPI-Python-Bac…/compose.yaml
2026-02-23 16:42:35 +01:00

38 lines
978 B
YAML

services:
api:
restart: unless-stopped
container_name: api_${postgres_db}
build: .
env_file:
- .env
ports:
- "${api_port}:8000"
environment:
DATABASE_URL: postgresql+asyncpg://${postgres_user}:${postgres_password}@db:${db_port}/${postgres_db}
depends_on:
db:
condition: service_healthy
volumes:
- ./app:/app/app
db:
image: postgres:18-alpine
container_name: postgres_${postgres_db}
restart: unless-stopped
shm_size: 128mb
ports:
- ${db_port}:5432
volumes:
- ./postgresData:/var/lib/postgresql/data
- ./Create.sql:/docker-entrypoint-initdb.d/Create.sql
environment:
POSTGRES_USER: ${postgres_user}
POSTGRES_PASSWORD: ${postgres_password}
POSTGRES_DB: ${postgres_db}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${postgres_user} -d ${postgres_db}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s