name: mtusi-lab2 x-app: &app image: mtusi-messenger:lab2 build: context: . target: runtime environment: &environment APP_HOST: 0.0.0.0 APP_PORT: "8080" APP_ENV: ${APP_ENV:-lab} SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} SESSION_STORE: redis DATABASE_URL_FILE: /run/secrets/database_url CACHE_URL_FILE: /run/secrets/cache_url CURSOR_KEY_FILE: /run/secrets/cursor_key secrets: - database_url - cache_url - cursor_key services: postgres: image: postgres:17.6-bookworm environment: POSTGRES_USER: messenger POSTGRES_DB: messenger POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password secrets: - postgres_password volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: [CMD-SHELL, "pg_isready -U messenger -d messenger"] interval: 3s timeout: 2s retries: 20 cpus: 1.0 mem_limit: 512m stop_grace_period: 10s redis: image: redis:7.4.5-bookworm command: - sh - -ec - 'exec redis-server /usr/local/etc/redis/redis.conf --requirepass "$$(cat /run/secrets/redis_password)"' secrets: - redis_password volumes: - redis_data:/data - ./infra/redis.conf:/usr/local/etc/redis/redis.conf:ro healthcheck: test: [CMD-SHELL, 'REDISCLI_AUTH="$$(cat /run/secrets/redis_password)" redis-cli ping | grep -q PONG'] interval: 3s timeout: 2s retries: 20 cpus: 0.5 mem_limit: 192m stop_grace_period: 10s migrate: <<: *app command: [python, -m, app.migrate] depends_on: postgres: condition: service_healthy restart: "no" api: <<: *app depends_on: migrate: condition: service_completed_successfully redis: condition: service_healthy ports: - "127.0.0.1:${API_PORT:-8080}:8080" cpus: 1.0 mem_limit: 256m stop_grace_period: 8s checks: profiles: [tools] image: mtusi-messenger:lab2-checks build: context: . target: checks environment: <<: *environment BASE_URL: http://api:8080 COMPOSE_PROJECT_NAME: ${COMPOSE_PROJECT_NAME:-mtusi-lab2} CHECKS_PROJECT_DIR: /checks secrets: - database_url - cache_url - cursor_key volumes: - .:/checks - /var/run/docker.sock:/var/run/docker.sock cpus: 1.0 mem_limit: 256m volumes: postgres_data: redis_data: secrets: postgres_password: file: ./secrets/postgres_password redis_password: file: ./secrets/redis_password database_url: file: ./secrets/database_url cache_url: file: ./secrets/cache_url cursor_key: file: ./secrets/cursor_key