x-logging: &logging driver: json-file options: max-size: "10m" max-file: "3" x-app: &app build: . image: mtusi-messenger:lab2 env_file: ${ENV_FILE:-.env} logging: *logging services: postgres: logging: *logging image: postgres:16.6-bookworm environment: POSTGRES_DB: ${POSTGRES_DB:-messenger} POSTGRES_USER: ${POSTGRES_USER:-messenger} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Задай POSTGRES_PASSWORD в .env} volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] interval: 2s timeout: 3s retries: 30 redis: logging: *logging image: redis:7.4.2-bookworm command: ["redis-server", "--appendonly", "yes", "--appendfsync", "always", "--maxmemory", "64mb", "--maxmemory-policy", "noeviction"] volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 2s timeout: 3s retries: 30 migration: <<: *app command: ["alembic", "upgrade", "head"] environment: REDIS_URL: &redis_url redis://redis:6379/0 DATABASE_URL: &database_url postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:?Задай POSTGRES_PASSWORD в .env}@postgres:5432/${POSTGRES_DB:-messenger} depends_on: postgres: condition: service_healthy healthcheck: disable: true api: <<: *app read_only: true tmpfs: - /tmp:rw,noexec,nosuid,size=16m cap_drop: [ALL] security_opt: ["no-new-privileges:true"] environment: APP_HOST: 0.0.0.0 APP_PORT: 8080 DATABASE_URL: *database_url REDIS_URL: *redis_url SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} LOG_LEVEL: ${LOG_LEVEL:-INFO} ports: - "127.0.0.1:${APP_PORT:-8080}:8080" depends_on: migration: condition: service_completed_successfully redis: condition: service_healthy healthcheck: interval: 2s timeout: 3s retries: 30 start_period: 10s volumes: redis_data: postgres_data: