build(docker): add API and ingestion worker stack

Add container builds and Compose services for PostgreSQL/pgvector, migrations, API, and a separate worker with persistent storage.
This commit is contained in:
amirhosein mazaheri
2026-10-08 12:58:59 +03:30
parent fef381c41b
commit bde43efab8
3 changed files with 156 additions and 0 deletions
+90
View File
@@ -0,0 +1,90 @@
services:
db:
image: pgvector/pgvector:pg16
container_name: rag-postgres
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-rag}
POSTGRES_USER: ${POSTGRES_USER:-rag}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-rag_password}
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-rag} -d ${POSTGRES_DB:-rag}"]
interval: 5s
timeout: 5s
retries: 5
start_period: 5s
migrations:
build:
context: .
dockerfile: Dockerfile
container_name: rag-migrations
restart: "no"
command: alembic upgrade head
env_file:
- .env
environment:
- INGEST_DATABASE_URL=postgresql+psycopg://${POSTGRES_USER:-rag}:${POSTGRES_PASSWORD:-rag_password}@db:5432/${POSTGRES_DB:-rag}
- INGEST_EMBEDDING_ENDPOINT=${INGEST_EMBEDDING_ENDPOINT:-http://host.docker.internal:11434/v1}
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
db:
condition: service_healthy
api:
build:
context: .
dockerfile: Dockerfile
container_name: rag-api
restart: unless-stopped
command: uvicorn app.main:app --host 0.0.0.0 --port 8000
ports:
- "${API_PORT:-8080}:8000"
env_file:
- .env
environment:
- INGEST_DATABASE_URL=postgresql+psycopg://${POSTGRES_USER:-rag}:${POSTGRES_PASSWORD:-rag_password}@db:5432/${POSTGRES_DB:-rag}
- INGEST_EMBEDDING_ENDPOINT=${INGEST_EMBEDDING_ENDPOINT:-http://host.docker.internal:11434/v1}
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./data/documents:/app/data/documents
- ./data/vector_db:/app/data/vector_db
- ./data/originals:/app/data/originals
- ./data/extractions:/app/data/extractions
depends_on:
db:
condition: service_healthy
migrations:
condition: service_completed_successfully
worker:
build:
context: .
dockerfile: Dockerfile
container_name: rag-worker
restart: unless-stopped
command: python -m app.worker
env_file:
- .env
environment:
- INGEST_DATABASE_URL=postgresql+psycopg://${POSTGRES_USER:-rag}:${POSTGRES_PASSWORD:-rag_password}@db:5432/${POSTGRES_DB:-rag}
- INGEST_EMBEDDING_ENDPOINT=${INGEST_EMBEDDING_ENDPOINT:-http://host.docker.internal:11434/v1}
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./data/originals:/app/data/originals
- ./data/extractions:/app/data/extractions
depends_on:
db:
condition: service_healthy
migrations:
condition: service_completed_successfully
volumes:
postgres_data: