> ## Documentation Index
> Fetch the complete documentation index at: https://docs.papermap.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy a worker

> Package and operate AIR workers safely in containers and Kubernetes.

A worker is a long-running Python process. Run it anywhere that can reach AIR
over HTTPS and the private systems used by its tools.

## Container example

```dockerfile theme={null}
FROM python:3.12-slim

WORKDIR /app
RUN python -m pip install --no-cache-dir papermap-air==0.1.0
COPY tools.py /app/tools.py

CMD ["air", "worker", "start", "--module", "tools"]
```

Configure runtime values through your deployment system:

```text theme={null}
AIR_BASE_URL=https://dev.airapi.papermap.ai
AIR_WORKER_KEY=<from-your-secret-manager>
AIR_WORKER_ENV=staging
AIR_WORKER_CLAIM_TIMEOUT=5
```

## Kubernetes secret reference

```yaml theme={null}
env:
  - name: AIR_BASE_URL
    value: https://dev.airapi.papermap.ai
  - name: AIR_WORKER_KEY
    valueFrom:
      secretKeyRef:
        name: air-worker
        key: worker-key
  - name: AIR_WORKER_ENV
    value: staging
```

## Operational checklist

* Pin the SDK version and test upgrades before rollout.
* Give staging and production separate worker keys.
* Give the worker's database identity the minimum required permissions.
* Let the process receive `SIGTERM`; the CLI stops claiming work and closes its connections.
* Start with one staging replica and scale after observing tool latency and throughput.
* Rotate a key by deploying the new value, confirming reconnection, and revoking the old key.
* Monitor registration, task failure, lease loss, and downstream timeouts.

<Warning>
  Do not put real credentials in a Dockerfile, image layer, committed `.env`
  file, or Kubernetes manifest. Sync them from a managed vault at runtime.
</Warning>
