x-bigrag-env: &bigrag-env BIGRAG_ENV: "${BIGRAG_ENV:-dev}" BIGRAG_DATABASE_URL: "postgres://${POSTGRES_USER:-bigrag}:${POSTGRES_PASSWORD:-bigrag}@postgres:5432/${POSTGRES_DB:-bigrag}?sslmode=disable" BIGRAG_REDIS_URL: "${BIGRAG_REDIS_URL:-redis://redis:6379/0}" BIGRAG_CACHE_REDIS_URL: "${BIGRAG_CACHE_REDIS_URL:-redis://redis-cache:6379/0}" BIGRAG_MASTER_KEY: "${BIGRAG_MASTER_KEY:-}" BIGRAG_MASTER_KEY_PREVIOUS: '${BIGRAG_MASTER_KEY_PREVIOUS:-[]}' BIGRAG_SESSION_COOKIE_SECURE: "${BIGRAG_SESSION_COOKIE_SECURE:-false}" BIGRAG_SESSION_COOKIE_SAMESITE: "${BIGRAG_SESSION_COOKIE_SAMESITE:-lax}" BIGRAG_SESSION_COOKIE_DOMAIN: "${BIGRAG_SESSION_COOKIE_DOMAIN:-}" BIGRAG_CORS_ORIGINS: '${BIGRAG_CORS_ORIGINS:-["http://localhost:3000"]}' BIGRAG_TRUSTED_PROXIES: '${BIGRAG_TRUSTED_PROXIES:-[]}' BIGRAG_LOG_LEVEL: "${BIGRAG_LOG_LEVEL:-info}" BIGRAG_LOG_FORMAT: "${BIGRAG_LOG_FORMAT:-text}" BIGRAG_UPLOAD_DIR: /data/uploads services: bigrag-api: image: "${BIGRAG_API_IMAGE:-bigrag-api:local}" build: ./api container_name: bigrag-api restart: unless-stopped ports: - "127.0.0.1:4000:4000" volumes: - bigrag_data:/data environment: <<: *bigrag-env BIGRAG_HOST: 0.0.0.0 BIGRAG_ALLOW_PUBLIC_BIND_IN_PROD: "${BIGRAG_ALLOW_PUBLIC_BIND_IN_PROD:-false}" deploy: resources: limits: memory: 4g cpus: "4" depends_on: postgres: condition: service_healthy redis: condition: service_healthy redis-cache: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:4000/health"] interval: 30s timeout: 10s retries: 3 bigrag-worker: image: "${BIGRAG_API_IMAGE:-bigrag-api:local}" container_name: bigrag-worker restart: unless-stopped command: ["bigrag-worker", "--processes", "${BIGRAG_WORKER_PROCESSES:-5}", "--threads", "${BIGRAG_WORKER_THREADS:-8}"] volumes: - bigrag_data:/data environment: <<: *bigrag-env BIGRAG_WORKER_HEALTHCHECK_KEY: "${BIGRAG_WORKER_HEALTHCHECK_KEY:-bigrag:dramatiq:worker:heartbeat}" deploy: resources: limits: memory: 4g cpus: "4" depends_on: postgres: condition: service_healthy redis: condition: service_healthy redis-cache: condition: service_healthy healthcheck: test: [ "CMD-SHELL", "python -c 'import os, sys, redis; client = redis.Redis.from_url(os.environ.get(\"BIGRAG_REDIS_URL\", \"redis://redis:6379/0\")); key = os.environ.get(\"BIGRAG_WORKER_HEALTHCHECK_KEY\", \"bigrag:dramatiq:worker:heartbeat\"); sys.exit(0 if client.ttl(key) > 0 else 1)'", ] interval: 30s timeout: 10s retries: 3 start_period: 60s bigrag-ui: image: "${BIGRAG_UI_IMAGE:-bigrag-ui:local}" build: context: . dockerfile: app/Dockerfile container_name: bigrag-ui restart: unless-stopped ports: - "127.0.0.1:3000:3000" environment: BIGRAG_URL: "${BIGRAG_UI_API_URL:-http://localhost:4000}" depends_on: bigrag-api: condition: service_healthy postgres: image: postgres:17 container_name: bigrag-postgres restart: unless-stopped ports: - "127.0.0.1:5432:5432" environment: POSTGRES_USER: "${POSTGRES_USER:-bigrag}" POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-bigrag}" POSTGRES_DB: "${POSTGRES_DB:-bigrag}" volumes: - postgres_data:/var/lib/postgresql/data command: postgres -c max_connections=200 -c shared_buffers=256MB -c work_mem=8MB -c effective_cache_size=768MB deploy: resources: limits: memory: 1g healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-bigrag}"] interval: 10s timeout: 5s retries: 5 redis: image: redis:7-alpine container_name: bigrag-redis restart: unless-stopped ports: - "127.0.0.1:6379:6379" environment: REDIS_PASSWORD: "${REDIS_PASSWORD:-}" volumes: - redis_data:/data command: - sh - -c - | if [ -n "$$REDIS_PASSWORD" ]; then exec redis-server --appendonly yes --maxmemory 1gb --maxmemory-policy noeviction --requirepass "$$REDIS_PASSWORD" fi exec redis-server --appendonly yes --maxmemory 1gb --maxmemory-policy noeviction deploy: resources: limits: memory: 1536m healthcheck: test: ["CMD-SHELL", "if [ -n \"$${REDIS_PASSWORD}\" ]; then redis-cli -a \"$${REDIS_PASSWORD}\" --no-auth-warning ping; else redis-cli ping; fi"] interval: 10s timeout: 5s retries: 5 redis-cache: image: redis:7-alpine container_name: bigrag-redis-cache restart: unless-stopped command: redis-server --maxmemory 512mb --maxmemory-policy allkeys-lru --save "" deploy: resources: limits: memory: 640m healthcheck: test: ["CMD-SHELL", "redis-cli ping"] interval: 10s timeout: 5s retries: 5 volumes: bigrag_data: postgres_data: redis_data: