Skip to main content
This guide provides instructions for deploying QWED in various environments.

Table of contents

  1. Docker deployment
  2. Kubernetes deployment
  3. Manual / bare metal deployment
  4. Environment variables reference
  5. Production checklist
  6. Troubleshooting
  7. 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

  1. Create Namespace
  2. 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.
    For production, use Sealed Secrets or External Secrets Operator instead of storing plain-text values in secret.yaml.
  3. Deploy Application
  4. Verify Deployment

Horizontal pod autoscaling (HPA)

For high-traffic environments, enable 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 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

  • 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

  • Set API_KEY_SECRET: This is mandatory — generate a secure value with python -c "import secrets; print(secrets.token_urlsafe(48))".
  • Set QWED_CORS_ORIGINS: Explicitly list your allowed origins (e.g., https://app.yourcompany.com). The server will not start without this.
  • 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 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:
  1. Check Docker is running: docker ps
  2. Verify the Docker daemon responds to pings: docker info
  3. 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: