build: run API with PostgreSQL and Redis in Docker Compose

This commit is contained in:
sinveria
2026-11-04 19:04:20 +03:00
parent 527f0e8d74
commit 2410960d3c
2 changed files with 59 additions and 1 deletions
+30 -1
View File
@@ -35,6 +35,35 @@ services:
timeout: 3s
retries: 10
api:
build:
context: .
dockerfile: Dockerfile
container_name: mtusi-lab2-api
restart: unless-stopped
environment:
DATABASE_URL: postgresql+psycopg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
CACHE_URL: redis://redis:6379/0
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
MESSAGE_CACHE_TTL_SECONDS: ${MESSAGE_CACHE_TTL_SECONDS:-60}
ports:
- "8080:8080"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test:
- CMD
- python
- -c
- "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=3)"
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
volumes:
lab2_postgres_data:
lab2_redis_data:
lab2_redis_data: