# SaaS, self-hosted, air-gapped

One code base and one image for every deployment; `DEPLOYMENT_MODE` chooses. Regulated organisations usually start self-hosted or air-gapped.

- `saas` — Azoth runs it: billing, product analytics and the public site are on.
- `self_hosted` — Your Kubernetes cluster, your database, your identity provider and your e-mail relay. The plan comes from your licence (`LICENSE_PLAN`).
- `airgapped` — As self-hosted, and the server reaches no host outside `EGRESS_ALLOWLIST`: a model call to any other is refused and sealed. An unknown mode reads as air-gapped.

## Install with Helm

The chart (`helm/azoth-os`) ships the app, its scheduled jobs, network policies, a nightly backup of the bundled database, and an optional bundled Supabase (Postgres, GoTrue, PostgREST) and Redis. Secrets come from one Secret you generate offline:

```
kubectl create namespace azoth
node scripts/self-hosted/gen-secrets.mjs --name azoth-secrets --namespace azoth | kubectl apply -f -

helm install azoth helm/azoth-os -n azoth \
  --set appUrl=https://azoth.bank.internal \
  --set image.repository=<registry>/azoth-os --set image.digest=sha256:… \
  --set ingress.tls[0].secretName=azoth-tls
```

## Migrations, by hand

The chart never applies migrations. The image carries the runner: run `node migrator/scripts/migrate.mjs --status`, then `--apply`, as a Job. It keeps a checksum ledger and refuses an edited file; the app reports ready only once the database is at the migration it expects.

## Identity and e-mail

Sign in through your organisation’s OIDC provider, or through SAML with Entra ID or ADFS, single logout included. E-mail goes through your SMTP relay: STARTTLS without downgrade, never credentials in plaintext.

## Air-gapped

- The deployment’s own infrastructure — its database, Redis, time-stamping authority and telemetry collector — stays reachable; anything else must be on the allowlist.
- Models hosted inside the deployment — vLLM, TGI, LiteLLM, Ollama’s OpenAI API — are the `internal` provider: the same gateway, rules and journal, at the price you declare.
- Without the Internet, give the deployment its own time-stamping authority: the local level.

```
egress:
  allowlist:
    - llm.bank.internal            # any port
    - siem.bank.internal:8443      # this port only
    - "*.models.bank.internal"     # any sub-domain
internalModels:
  - name: vllm
    baseUrl: http://vllm.models.svc:8000/v1
    models: [llama-3.1-70b-instruct]
    price: { input: 0.4, output: 0.8 }   # USD per 1M tokens, declared by you
```

## The signed image and the offline bundle

Each release pushes a signed image and its signed SBOM, and attaches an offline bundle — the chart, every image, a signed `SHA256SUMS` — that verifies with openssl alone, without the Internet.

## The model catalog

A self-hosted deployment imports the latest signed model catalog every day; an air-gapped one imports a signed file from Platform admin. A catalog is refused unless it is signed and hashes to its sha256.

The full guide is `docs/self-hosting.md` in the repository.
