name: mtusi-lab5 services: postgres: image: postgres:16.10 environment: POSTGRES_DB: messenger POSTGRES_USER: messenger POSTGRES_PASSWORD: messenger volumes: - postgres-data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"] interval: 5s timeout: 3s retries: 20 s3: image: chrislusf/seaweedfs:4.02 command: server -s3 -dir=/data -s3.port=9000 -s3.config=/etc/seaweedfs/s3.json volumes: - s3-data:/data - ./infra/seaweedfs-s3.json:/etc/seaweedfs/s3.json:ro ports: - "9000:9000" healthcheck: test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:9333/cluster/status"] interval: 5s timeout: 3s retries: 20 broker: image: rabbitmq:3.13-management volumes: - broker-data:/var/lib/rabbitmq ports: - "15672:15672" healthcheck: test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"] interval: 5s timeout: 5s retries: 30 api1: build: . environment: &api-env DATABASE_URL: postgresql://messenger:messenger@postgres:5432/messenger S3_ENDPOINT: http://s3:9000 S3_REGION: us-east-1 S3_BUCKET: messenger-attachments S3_ACCESS_KEY_ID: minioadmin S3_SECRET_ACCESS_KEY: minioadmin123 BROKER_URL: amqp://guest:guest@broker:5672/%2F SESSION_TTL_SECONDS: "3600" API_INSTANCE_ID: api-1 depends_on: postgres: condition: service_healthy s3: condition: service_healthy broker: condition: service_healthy healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/live')"] interval: 5s timeout: 3s retries: 20 api2: build: . environment: <<: *api-env API_INSTANCE_ID: api-2 depends_on: postgres: condition: service_healthy s3: condition: service_healthy broker: condition: service_healthy healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/live')"] interval: 5s timeout: 3s retries: 20 load-balancer: image: nginx:1.28.0 volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro ports: - "${HTTP_PORT:-8080}:8080" depends_on: api1: condition: service_healthy api2: condition: service_healthy worker: build: . command: ["python", "-m", "src.worker"] environment: DATABASE_URL: postgresql://messenger:messenger@postgres:5432/messenger S3_ENDPOINT: http://s3:9000 S3_REGION: us-east-1 S3_BUCKET: messenger-attachments S3_ACCESS_KEY_ID: minioadmin S3_SECRET_ACCESS_KEY: minioadmin123 BROKER_URL: amqp://guest:guest@broker:5672/%2F WORKER_CONCURRENCY: "2" JOB_MAX_ATTEMPTS: "5" JOB_TIMEOUT_SECONDS: "60" JOB_LEASE_SECONDS: "90" JOB_RETRY_BASE_SECONDS: "1" JOB_RETRY_MAX_SECONDS: "60" WORKER_FAULT_INJECTION: "${WORKER_FAULT_INJECTION:-}" STAGING_RETENTION_SECONDS: "86400" MAX_UPLOAD_BYTES: "10485760" MAX_IMAGE_PIXELS: "40000000" mem_limit: 512m cpus: 1.0 depends_on: postgres: condition: service_healthy s3: condition: service_healthy broker: condition: service_healthy volumes: postgres-data: s3-data: broker-data: