contiai / render.yaml
aliroya's picture
ContiAI platform: API and queue worker in one container (part 3)
7451968 verified
Raw History Blame Contribute Delete
5.67 kB
# Render blueprint. Render reads this from the repository root.
#
# Three services. The worker is a separate process on purpose: a book run takes
# tens of minutes, far past any HTTP timeout, and doing that work inside a
# request is the main thing this architecture fixes.
#
# The worker must be on a paid plan. Free instances sleep when idle, and a
# sleeping worker abandons whatever job it was in the middle of.
services:
# ── API ────────────────────────────────────────────────────────────────
- type: web
name: contiai-api
runtime: python
plan: starter
region: frankfurt
rootDir: apps/api
buildCommand: pip install --upgrade pip && pip install -e .
# Migrations run here rather than in the build: the build has no database
# attached, and running them per-boot is idempotent.
#
# One worker, not two. Every gunicorn worker is a separate process with its
# own copy of the agent stack, and this image loads sentence-transformers -
# two of them do not fit in a starter instance's memory. Concurrency comes
# from the async event loop, and the long work belongs to the queue anyway.
startCommand: >-
alembic upgrade head &&
gunicorn app.main:app
--worker-class uvicorn.workers.UvicornWorker
--workers 1
--bind 0.0.0.0:$PORT
--timeout 120
healthCheckPath: /health
envVars:
- key: ENV
value: production
- key: DEBUG
value: "false"
- key: PYTHON_VERSION
value: "3.11.11"
# Supabase pooler URL on port 6543, as postgresql+asyncpg://
- key: DATABASE_URL
sync: false
- key: REDIS_URL
fromService:
type: keyvalue
name: contiai-redis
property: connectionString
# The Vercel origin and the custom domain, comma separated.
- key: CORS_ORIGINS
sync: false
- key: SUPABASE_URL
sync: false
- key: SUPABASE_SERVICE_ROLE_KEY
sync: false
- key: SUPABASE_ANON_KEY
sync: false
- key: SUPABASE_JWT_SECRET
sync: false
- key: QDRANT_URL
sync: false
- key: QDRANT_API_KEY
sync: false
- key: OPENROUTER_API_KEY
sync: false
- key: MISTRAL_API_KEY
sync: false
- key: SERPER_API_KEYS
sync: false
# Without this a fresh deployment is unreachable: every account is
# created pending, only an administrator can approve one, and there is
# no administrator. Addresses listed here arrive approved and admin.
- key: BOOTSTRAP_ADMIN_EMAILS
sync: false
# ── worker ─────────────────────────────────────────────────────────────
#
# Standard, not starter, and the reason is measured rather than assumed.
# This process loads the embedding model, and the model is most of it:
#
# python alone 18 MB
# + torch 191 MB
# + sentence-transformers 378 MB
# + the model loaded 698 MB
# + after encoding a batch 793 MB
#
# A starter instance has 512 MB. The worker would be killed the moment
# retrieval loaded the encoder - after the search and the downloads had
# been paid for - and the log would say `Exited with status 137` and
# nothing else.
- type: worker
name: contiai-worker
runtime: python
plan: standard
region: frankfurt
rootDir: apps/api
buildCommand: pip install --upgrade pip && pip install -e .
# No migrations here - the API owns the schema. Two processes racing
# `alembic upgrade head` on a cold deploy is a deadlock waiting to happen.
startCommand: arq app.workers.worker.WorkerSettings
envVars:
- key: ENV
value: production
- key: DEBUG
value: "false"
- key: PYTHON_VERSION
value: "3.11.11"
- key: DATABASE_URL
fromService: { type: web, name: contiai-api, envVarKey: DATABASE_URL }
- key: REDIS_URL
fromService:
type: keyvalue
name: contiai-redis
property: connectionString
- key: SUPABASE_URL
fromService: { type: web, name: contiai-api, envVarKey: SUPABASE_URL }
- key: SUPABASE_SERVICE_ROLE_KEY
fromService: { type: web, name: contiai-api, envVarKey: SUPABASE_SERVICE_ROLE_KEY }
- key: SUPABASE_JWT_SECRET
fromService: { type: web, name: contiai-api, envVarKey: SUPABASE_JWT_SECRET }
- key: QDRANT_URL
fromService: { type: web, name: contiai-api, envVarKey: QDRANT_URL }
- key: QDRANT_API_KEY
fromService: { type: web, name: contiai-api, envVarKey: QDRANT_API_KEY }
- key: OPENROUTER_API_KEY
fromService: { type: web, name: contiai-api, envVarKey: OPENROUTER_API_KEY }
- key: MISTRAL_API_KEY
fromService: { type: web, name: contiai-api, envVarKey: MISTRAL_API_KEY }
- key: SERPER_API_KEYS
fromService: { type: web, name: contiai-api, envVarKey: SERPER_API_KEYS }
# ── queue ──────────────────────────────────────────────────────────────
- type: keyvalue
name: contiai-redis
plan: free
region: frankfurt
maxmemoryPolicy: noeviction # a queue must not drop jobs under pressure
ipAllowList: [] # private network only