- Add async Redis client singleton (redis_client.py) for caching and arq pool
- Add arq job functions (jobs.py) for background LLM processing
- Cache ask/explain LLM responses with TTL (1h ask, 24h explain)
- Add async mode to /api/ask: enqueue job, return job_id, poll /api/jobs/{id}
- Add GET /api/jobs/{job_id} endpoint for job status polling
- Add arq worker service to docker-compose (dev + prod)
- Switch from Redis to Valkey (BSD fork) in Docker Compose
- Add REDIS_URL config setting
- Add tests for cache hit, async mode, and job status
103 lines
2.4 KiB
YAML
103 lines
2.4 KiB
YAML
services:
|
|
redis:
|
|
image: valkey/valkey:8-alpine
|
|
container_name: aoc-redis
|
|
restart: always
|
|
volumes:
|
|
- redis_data:/data
|
|
networks:
|
|
- aoc-internal
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 5s
|
|
|
|
mongo:
|
|
image: mongo:7
|
|
container_name: aoc-mongo
|
|
restart: always
|
|
# Do NOT expose MongoDB port to the host in production
|
|
# Only backend can reach it via the internal Docker network
|
|
environment:
|
|
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USERNAME}
|
|
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD}
|
|
volumes:
|
|
- mongo_data:/data/db
|
|
networks:
|
|
- aoc-internal
|
|
healthcheck:
|
|
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 10s
|
|
|
|
backend:
|
|
image: git.cqre.net/cqrenet/aoc-backend:${AOC_VERSION:-latest}
|
|
container_name: aoc-backend
|
|
restart: always
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
MONGO_URI: mongodb://${MONGO_ROOT_USERNAME}:${MONGO_ROOT_PASSWORD}@mongo:27017/
|
|
REDIS_URL: redis://redis:6379/0
|
|
depends_on:
|
|
mongo:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
networks:
|
|
- aoc-internal
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
|
|
interval: 15s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|
|
|
|
worker:
|
|
image: git.cqre.net/cqrenet/aoc-backend:${AOC_VERSION:-latest}
|
|
container_name: aoc-worker
|
|
restart: always
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
MONGO_URI: mongodb://${MONGO_ROOT_USERNAME}:${MONGO_ROOT_PASSWORD}@mongo:27017/
|
|
REDIS_URL: redis://redis:6379/0
|
|
command: ["arq", "jobs.WorkerSettings"]
|
|
depends_on:
|
|
redis:
|
|
condition: service_healthy
|
|
mongo:
|
|
condition: service_healthy
|
|
networks:
|
|
- aoc-internal
|
|
|
|
nginx:
|
|
image: nginx:alpine
|
|
container_name: aoc-nginx
|
|
restart: always
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
- ./nginx/ssl:/etc/nginx/ssl:ro
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
networks:
|
|
- aoc-internal
|
|
- aoc-public
|
|
|
|
volumes:
|
|
mongo_data:
|
|
redis_data:
|
|
|
|
networks:
|
|
aoc-internal:
|
|
internal: true
|
|
aoc-public:
|