Table of Contents
- Docker Deployment
- Kubernetes Deployment
- Manual / Bare Metal Deployment
- Environment Variables Reference
- Production Checklist
- Troubleshooting
- Operations & Monitoring
Docker Deployment
The easiest way to run QWED locally or on a single server is using Docker Compose.Dockerfile
ADockerfile is provided in the root directory. It builds the QWED core service based on python:3.11-slim.
Docker Compose
We provide adocker-compose.yml that orchestrates:
- qwed-core: The main API server.
- postgres: Primary database.
- redis: Cache and rate limiting.
- jaeger: Distributed tracing.
- prometheus: Metrics collection.
- grafana: Observability dashboards.
- API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Grafana: http://localhost:3000 (admin/qwed_admin)
- Jaeger: http://localhost:16686
🏢 Enterprise Support Coming Soon: Managed hosting, dedicated support, and SLA guarantees. Contact support@qwedai.com
Notes on Stats Verification
The Stats Verification engine (Engine 3) executes code securely inside Docker containers. For this to work in a Docker Compose environment, theqwed-core container mounts the host’s Docker socket (/var/run/docker.sock). Ensure the user running Docker Compose has appropriate permissions.
Kubernetes Deployment
For production environments, we provide Kubernetes manifests indeploy/kubernetes/.
Prerequisites
- A running Kubernetes cluster (v1.24+ recommended).
kubectlconfigured.- A PostgreSQL database and Redis instance (managed services recommended for production).
Deployment Steps
-
Create Namespace
-
Configure Secrets & ConfigMaps
Edit
deploy/kubernetes/secret.yamlwith your real API keys and database credentials. -
Deploy Application
-
Verify Deployment
Horizontal Pod Autoscaling (HPA)
For high-traffic environments, we recommend enabling HPA (requires Metrics Server):Manual / Bare Metal Deployment
If you prefer to run the application directly on a host or VM:1. Prerequisites
Docker Installation (Required for Secure Code Execution) QWED uses Docker for secure code execution in the Stats Verification engine.Linux (Ubuntu/Debian)
2. Python Dependencies
3. Database Setup
Ensure PostgreSQL and Redis are running. Set theDATABASE_URL and REDIS_URL environment variables.
Initialize the database:
4. Running the API
Environment Variables Reference
Infrastructure
| Variable | Description | Default | Required |
|---|---|---|---|
DATABASE_URL | Postgres connection string | sqlite:///./qwed.db | Yes (Prod) |
REDIS_URL | Redis connection string | redis://localhost:6379/0 | Yes (Prod) |
API_KEY_SECRET | Secret key for signing JWTs | change-me... | YES |
Security Configuration
| Variable | Description | Default |
|---|---|---|
MAX_INPUT_LENGTH | Max query length (chars) | 2000 |
SIMILARITY_THRESHOLD | Prompt injection detection threshold | 0.6 |
DOCKER_TIMEOUT | Code execution timeout (seconds) | 10 |
DOCKER_MEMORY_LIMIT | Container memory limit | 512m |
AI Providers
| Variable | Description | Default |
|---|---|---|
ACTIVE_PROVIDER | Selected LLM provider | azure_openai |
AZURE_OPENAI_API_KEY | API Key for Azure OpenAI | - |
AZURE_OPENAI_ENDPOINT | Endpoint URL | - |
ANTHROPIC_API_KEY | API Key for Anthropic | - |
Observability
| Variable | Description | Default |
|---|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | Jaeger/OTLP Endpoint | http://localhost:4317 |
Production Checklist
Before going to production, ensure the following:1. Database Setup
- Use a managed PostgreSQL instance (e.g., AWS RDS, Azure Database for PostgreSQL).
- Enable automated backups.
- Run database migrations.
2. Redis Configuration
- Use a managed Redis instance (e.g., AWS ElastiCache).
- Configure eviction policy (LRU).
- Enable persistence (RDB/AOF).
3. Security
- Rotate Keys: Change all default passwords and secrets.
- SSL/TLS: Ensure the API is behind a Load Balancer with a valid SSL certificate.
- Network Policies: Restrict access to database/Redis.
- Docker Security: Ensure the Docker socket is protected or use a secure container runtime (gVisor) for the Stats Verification engine if possible.
4. Observability
- Configure alert rules in Prometheus/Grafana.
- Ensure logs are shipped to a centralized logging system.
Troubleshooting
1. Docker Permission Denied
Error:docker: Got permission denied while trying to connect to the Docker daemon socket
Solution: Ensure the user running the app is in the docker group, or (for Docker Compose) ensure the socket is mounted correctly and the container user has permissions.
2. Stats Verification Failing
Error:SecureCodeExecutor initialization failed
Solution:
- Check Docker is running:
docker ps - Check
python:3.10-slimimage exists:docker pull python:3.10-slim(The executor uses this image).