38 lines
1.0 KiB
YAML
38 lines
1.0 KiB
YAML
services:
|
|
db:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_DB: ${POSTGRES_DB:-tasks}
|
|
POSTGRES_USER: ${POSTGRES_USER:-tasks}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-tasks}
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 10
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
networks: [tasks_net]
|
|
api:
|
|
build: .
|
|
environment:
|
|
DATABASE_URL: ${DATABASE_URL:-postgresql+psycopg2://tasks:tasks@db:5432/tasks}
|
|
APP_NAME: ${APP_NAME:-Task API}
|
|
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
|
ports:
|
|
- "${API_PORT:-8000}:8000"
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks: [tasks_net]
|
|
volumes:
|
|
postgres_data:
|
|
networks:
|
|
tasks_net:
|
|
driver: bridge
|