services: postgres: image: postgres:16.10-bookworm restart: unless-stopped environment: POSTGRES_USER: ${DB_USER} POSTGRES_DB: ${DB_NAME} POSTGRES_PASSWORD: ${DB_PASSWORD} volumes: - pgdata:/var/lib/postgresql/data ports: - "127.0.0.1:${DB_HOST_PORT:-5432}:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] interval: 5s timeout: 3s retries: 10 redis: image: redis:7.4.2-bookworm restart: unless-stopped environment: REDIS_PASSWORD: ${REDIS_PASSWORD} command: - sh - -c - >- exec redis-server --appendonly yes --appendfsync always --maxmemory 256mb --maxmemory-policy noeviction --requirepass "$$REDIS_PASSWORD" volumes: - redisdata:/data ports: - "127.0.0.1:${REDIS_HOST_PORT:-6379}:6379" healthcheck: test: ["CMD-SHELL", "redis-cli -a \"$$REDIS_PASSWORD\" --no-auth-warning ping | grep -q PONG"] interval: 5s timeout: 3s retries: 10 migrate: build: . image: mtusi-messenger:lab2 command: ["alembic", "upgrade", "head"] env_file: .env depends_on: postgres: condition: service_healthy restart: "no" api: build: . image: mtusi-messenger:lab2 restart: unless-stopped env_file: .env ports: - "127.0.0.1:${API_HOST_PORT:-8080}:8080" depends_on: postgres: condition: service_healthy redis: condition: service_healthy migrate: condition: service_completed_successfully volumes: pgdata: redisdata: