This guide provides instructions for deploying QWED in various environments.
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
A Dockerfile is provided in the root directory. It builds the QWED core service based on python:3.13-slim-bookworm, upgraded from Python 3.12 for reduced CVE exposure.
Docker Compose
QWED provides a docker-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.
Before starting the stack, create a .env file in the deploy/ directory with the required environment variables:
DATABASE_URL, QWED_CORS_ORIGINS, and API_KEY_SECRET are required. Docker Compose will refuse to start if any of these are missing. Generate API_KEY_SECRET with:
Start the stack:
Access the services:
Docker requirement for code execution
Both the Stats Engine and the Consensus Engine (in high/maximum mode) execute model-generated Python inside Docker containers. Docker is required — there are no in-process fallbacks. If Docker is unavailable, these endpoints return HTTP 503.
Kubernetes deployment
For production environments, QWED ships Kubernetes manifests in deploy/kubernetes/.
Prerequisites
- A running Kubernetes cluster (v1.24+ recommended).
kubectl configured.
- A PostgreSQL database and Redis instance (managed services recommended for production).
Deployment steps
-
Create Namespace
-
Configure Secrets & ConfigMaps
Edit
deploy/kubernetes/secret.yaml and replace all __REPLACE_WITH_*__ placeholders with your real values. The DATABASE_URL is now stored in the Secret (not the ConfigMap) because it contains credentials.
-
Deploy Application
-
Verify Deployment
Horizontal pod autoscaling (HPA)
For high-traffic environments, enable HPA (requires Metrics Server):
If you prefer to run the application directly on a host or VM:
1. Prerequisites
Docker Installation (Required for Secure Code Execution)
QWED requires Docker for all model-generated code execution in the Stats Engine and Consensus Engine. Without Docker, these verification endpoints return HTTP 503.
Linux (Ubuntu/Debian)
2. Python dependencies
3. Database setup
Ensure PostgreSQL and Redis are running. Set the DATABASE_URL and REDIS_URL environment variables.
Initialize the database:
4. Running the API
Environment variables reference
Infrastructure
API_KEY_SECRET no longer has a default value. The server will refuse to start if it is not set. This prevents accidental deployment with a weak default secret.
Security configuration
AI providers
Observability
Production checklist
Before going to production, ensure the following:
1. Database setup
2. Redis configuration
3. Security
4. Observability
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 or consensus verification returning 503
Error: Service temporarily unavailable on /verify/stats or /verify/consensus
Cause: The secure Docker sandbox is unreachable. QWED does not fall back to in-process execution.
Solution:
- Check Docker is running:
docker ps
- Verify the Docker daemon responds to pings:
docker info
- Check
python:3.10-slim image exists: docker pull python:3.10-slim (The executor uses this image).
Operations and monitoring
View recent security events
Security metrics dashboard
For detailed architecture documentation, see: