name: highload-lab3 services: redis: image: redis:7.4.11-bookworm command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec", "--dir", "/data"] volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 3s timeout: 3s retries: 20 db: image: postgres:16.10-bookworm environment: POSTGRES_DB: ${POSTGRES_DB} POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] interval: 3s timeout: 3s retries: 20 migrate: build: ./src environment: DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?sslmode=disable command: ["./messenger", "migrate", "up"] depends_on: db: condition: service_healthy api: build: ./src deploy: replicas: 2 stop_grace_period: 15s environment: APP_HOST: 0.0.0.0 APP_PORT: 8080 SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} REDIS_ADDR: redis:6379 DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?sslmode=disable depends_on: migrate: condition: service_completed_successfully db: condition: service_healthy redis: condition: service_healthy healthcheck: test: ["CMD", "./messenger", "healthcheck"] interval: 5s timeout: 3s retries: 20 haproxy: image: haproxy:3.2.25-alpine ports: - "127.0.0.1:8080:8080" - "127.0.0.1:8404:8404" volumes: - ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro depends_on: api: condition: service_healthy healthcheck: test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/health/ready"] interval: 2s timeout: 3s retries: 20 backend-tests: profiles: ["test"] build: context: ./src target: builder environment: TEST_DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?sslmode=disable TEST_REDIS_ADDR: redis:6379 depends_on: db: condition: service_healthy redis: condition: service_healthy command: ["go", "test", "-race", "-count=1", "-v", "./backend/..."] frontend: build: context: ./src/frontend environment: API_PROXY_TARGET: http://haproxy:8080 ports: - "127.0.0.1:5173:5173" volumes: - ./src/frontend:/app - /app/node_modules depends_on: haproxy: condition: service_healthy healthcheck: test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:5173/').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"] interval: 5s timeout: 3s retries: 20 volumes: postgres_data: redis_data: