Deploy with Docker and Kubernetes

In shortGenerate a Dockerfile, docker-compose.yml and Kubernetes manifest with 10xgraph build, then ship them with a production environment checklist.

  • 5 min read
  • 5 sections
  • Updated
  • v1.0.0
  • Markdown

10xgraph build generates a Dockerfile and .dockerignore for your agent, and with flags also a docker-compose.yml and a k8s.yaml manifest. The images run Gunicorn with Uvicorn workers in MODE=production. This guide covers building, configuring, and shipping your deployment with a release checklist.

The image and manifests implement the behavior described in scaling and reliability. Draining runs on shutdown is covered in Graceful shutdown.

  1. Generate the deployment files

    Run it in the project root, next to 10xgraph.json.

    Terminal
    10xgraph build --docker-compose

    For Kubernetes instead, run 10xgraph build --k8s separately (combining --docker-compose and --k8s is refused because the Compose Dockerfile omits CMD).

  2. Pin your dependencies

    The Dockerfile installs from the first of requirements.txt, requirements/requirements.txt, requirements/base.txt or requirements/production.txt that exists. With none of those, it reads pyproject.toml dependencies. With neither, it installs only 10xgraph-api, so your own packages would be missing.

  3. Build and run

    Terminal
    docker compose up --build
  4. Check health

    Terminal
    curl http://localhost:8000/ping

Which flags does build take?

Flag Default Effect
--output, -o Dockerfile Dockerfile path
--force, -f off Overwrite existing files
--python-version 3.13 Base image python:<version>-slim
--port, -p 8000 Port to expose
--docker-compose / --no-docker-compose off Also write docker-compose.yml and omit CMD from the Dockerfile
--k8s / --no-k8s off Also write k8s.yaml
--service-name 10xgraph-api Service name in compose and Kubernetes files
--worker / --no-worker asked Include a background worker. Needs a non-memory worker key in 10xgraph.json
--scheduler / --no-scheduler off Include the scheduler. Needs the worker

Without --force, build stops if the Dockerfile exists. It keeps an existing .dockerignore but appends any secret patterns it lacks (keys, certificates, cloud credential files), and errors on an existing docker-compose.yml or k8s.yaml.

Questions and background jobs

At an interactive terminal, build asks up to four questions and skips any that a flag answers or that do not apply:

  1. Where will you deploy? Docker Compose, Kubernetes or Dockerfile only. Skipped when you pass --docker-compose or --k8s.
  2. Run a background worker? Default yes. Asked only when 10xgraph.json has a worker key whose broker is not memory, and the target is Compose or Kubernetes.
  3. Run the scheduler? Default no. Asked only after a yes to the worker.
  4. Overwrite existing files? Asked only when files exist and you did not pass --force. No stops without writing.

Pass --yes or --non-interactive to skip the questions. Without a terminal, the worker is included when the config has a non-memory worker key, and the scheduler only with --scheduler. --worker without a worker key, or with the memory broker, is an error, and so is --scheduler without a worker. With the memory broker no worker is generated, because tasks run inside the API, and build prints a note. build warns when your dependencies do not list 10xgraph-api with the extra for the broker (jobs, jobs-rabbitmq or jobs-kafka).

What files does it generate?

  • your-project/
    • 10xgraph.json
    • Dockerfilepython:3.13-slim, non-root user (uid 10001), healthcheck on /ping
    • .dockerignoreexcludes .env, keys and credential files, caches, venvs, .git, eval_reports, tests, evals and agent skill folders
    • docker-compose.ymlwith --docker-compose, plus worker and scheduler services when you include them
    • k8s.yamlwith --k8s, plus worker and scheduler Deployments when you include them

The Dockerfile sets MODE=production and WEB_CONCURRENCY=2, installs gunicorn and uvicorn, removes the CLI-only files from the installed package, copies your project, drops to the non-root user appuser (fixed uid and gid 10001, set as USER 10001:10001 so Kubernetes can verify it is not root), and defines a HEALTHCHECK that calls /ping. Its CMD runs tenxgraph_api.src.app.main:app under Gunicorn with the TenxGraphUvicornWorker class (tenxgraph_api.src.app.uvicorn_worker.TenxGraphUvicornWorker), --graceful-timeout 600, --timeout 660 and --no-control-socket (the gunicorn control server would write /app/.gunicorn, and the root filesystem is read-only). The worker marks the app as draining on SIGTERM, so /health/ready answers 503 while open runs finish. TENXGRAPH_GRACEFUL_SHUTDOWN_SECONDS (default 540) sets how long uvicorn waits for open responses; see Graceful shutdown. With --k8s, the CMD runs python -m tenxgraph_api.src.app.serve (one Uvicorn process) instead of Gunicorn; see Kubernetes.

The builder stage strips the CLI’s templates and config editor and uninstalls the CLI-only libraries (typer, rich, questionary) unless your project needs them, so the image carries no CLI code paths.

Run it with Docker Compose

The compose file defines one service with build: ., the production environment, the same Gunicorn command, stop_grace_period: 660s and restart: unless-stopped. It reads secrets and ORIGINS/ALLOWED_HOST from .env through env_file, so they never enter the image. Copy .env.example to .env and fill it in first.

If you included the worker, the file also has a worker service, and with the scheduler a scheduler service. Both are built from the same image as the API, read the same .env, use the same lockdown settings and publish no ports. They run 10xgraph worker and 10xgraph scheduler in the image. The worker waits up to 600 seconds for running tasks on shutdown. The scheduler carries a comment: run exactly one, and remove the service if you have no schedules. See Background tasks.

Terminal
docker compose up --build -d

The port is published on 127.0.0.1:8000 only: the server speaks plain HTTP, so a TLS reverse proxy (Caddy, nginx or a cloud load balancer) on the same host is what faces the internet. If the proxy runs on another host, remove the 127.0.0.1: prefix and firewall the port to that host.

The container runs with read_only: true, cap_drop: [ALL] and no-new-privileges. Only /tmp (a tmpfs) and /app/uploads (the named volume uploads) are writable. If your graph writes elsewhere, for example a SQLite checkpointer file, mount a volume at that path.

For Kubernetes, see Deploy on Kubernetes.

Production environment settings

The generated files set MODE=production. Add the following at runtime:

Variable Set to Why
ORIGINS Comma-separated list of your frontend origins k8s.yaml reads it from the Secret; compose reads it from .env. A wildcard * stops startup in production unless STRICT_PRODUCTION_CHECKS=false, and is always refused when CORS_ALLOW_CREDENTIALS is true
ALLOWED_HOST Your hostnames Comma-separated. k8s.yaml reads it from the Secret; compose reads it from .env. A wildcard * stops startup in production unless STRICT_PRODUCTION_CHECKS=false
JWT_SECRET_KEY 32+ bytes, from a secret manager Required if auth is jwt. See Add JWT authentication
JWT_ALGORITHM HS256 (default) or your choice Optional
REDIS_URL Your Redis connection URL Optional. The server uses it for a cache_store of type redis that has no url. Without such a cache_store the cache store is in-memory and per process
WEB_CONCURRENCY Workers per container Default 2. Tune for your CPU and load

Full reference is in the configuration and environment pages.

Before release, run the verification checklist.

Frequently asked questions

Why does the generated config wait so long to shut down?
An agent run can take minutes, and Gunicorn's default 30 second graceful timeout would kill runs mid-flight on every rolling deploy. The generated files use a 600 second graceful timeout, a 660 second worker timeout, a 660 second Compose stop grace period and a 675 second Kubernetes grace period.
Can I change the image name in k8s.yaml?
Yes. The manifest uses the placeholder image registry.example.com/<service>:1.0.0. Build and push your own image, then set the image field to its version tag or digest before applying.
Does build read my 10xgraph.json?
No. It looks for a requirements file or pyproject.toml, and the container reads 10xgraph.json at runtime, so your code and config must be copied into the image.
The 10xgraph-api package contains CLI code, project templates and a browser config editor. Is that a security risk in production?
No. The server never imports the CLI half, and the generated Dockerfile strips it from the image.
Last updated for v1.0.0Edit this page on GitHubReport an issue