> For the complete documentation index, see [llms.txt](https://docs.zama.org/protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zama.org/protocol/sdk/go-and-rust-guide/operations/run-in-production.md).

# Deploy in production

Deploy the Zama SDK daemon next to a Go or Rust application on your infrastructure.

{% hint style="warning" %}
The daemon and its Go and Rust clients are experimental. The wire protocol can change between minor versions, so upgrade the daemon image and the clients together.
{% endhint %}

Deploy one daemon per Go or Rust application instance. Run both on the same host or in the same Kubernetes pod, as the same UID, sharing a private Unix socket directory.

## Prerequisites

* Select the daemon image tag and client version from [Client and daemon compatibility](https://docs.zama.org/protocol/sdk/api-references/client-and-daemon-compatibility.md).
* Reserve one trust domain for each application-and-daemon pair. Read the [daemon trust model](https://docs.zama.org/protocol/sdk/concepts/trust-boundary.md).
* Allow the daemon outbound access to your chain RPC endpoints and relayer.
* Choose a credential storage backend in [Configuration](https://docs.zama.org/protocol/sdk/guides/configuration.md), and provision any derivation secret through your secrets manager.

There is no network listener. Keep the application and its daemon on the same host or in the same pod, and don't expose the socket through a network proxy.

## Prepare the socket and storage

1. Give the daemon a socket directory owned by its UID with mode `0700`, and run the application as the same UID. The daemon refuses to start when the directory is shared with its group or other users. When the socket sits on a shared volume whose root isn't private, such as a Kubernetes `emptyDir`, put it in a private subdirectory. The Compose file below sets this up.
2. For daemon SQLite storage, provision a private writable volume for this daemon and set `ZAMA_SDK_DAEMON_STORAGE_DIR` to its mount path. The daemon creates one `0700` subdirectory per named store.
3. For application-owned storage, configure the backend in your application. The daemon needs no credential volume.

{% hint style="warning" %}
Two daemons must not share a SQLite credential volume: each named database is locked to one daemon. Replicas can share application-owned storage, but credential coordination does not span daemons, so concurrent replicas can race on the same user's credentials and cause extra signature prompts.
{% endhint %}

## Verify and pin the image

Each release signs the image in the release workflow and stores the signature, build provenance, and an SBOM next to it on GitHub Container Registry. Before the first deployment of a version, and before every upgrade, resolve the release tag to its digest, verify that digest, and pin it. A tag can be moved; a digest cannot.

Resolve the tag first, so the digest you verify is the digest you pin:

```bash
export ZAMA_SDK_VERSION=3.8.0
export ZAMA_SDK_DAEMON_DIGEST="$(docker buildx imagetools inspect "ghcr.io/zama-ai/sdk-daemon:${ZAMA_SDK_VERSION}" --format '{{ .Manifest.Digest }}')"
```

Verify the digest with the [GitHub CLI](https://cli.github.com/):

```bash
gh attestation verify "oci://ghcr.io/zama-ai/sdk-daemon@${ZAMA_SDK_DAEMON_DIGEST}" --repo zama-ai/sdk \
  --signer-workflow zama-ai/sdk/.github/workflows/release.yml
```

The command checks that the image was built by the release workflow of the `zama-ai/sdk` repository. With [cosign](https://github.com/sigstore/cosign) instead:

```bash
cosign verify-attestation "ghcr.io/zama-ai/sdk-daemon@${ZAMA_SDK_DAEMON_DIGEST}" --new-bundle-format \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  --certificate-identity-regexp '^https://github.com/zama-ai/sdk/\.github/workflows/release\.yml@refs/heads/(main|beta|alpha)$' \
  --type https://slsa.dev/provenance/v1
```

Keep `ZAMA_SDK_DAEMON_DIGEST` exported. The Compose files below then pull `ghcr.io/zama-ai/sdk-daemon:<version>@sha256:…`, and Docker refuses any content that doesn't match. Images released before signing was introduced carry no attestations, and the verification fails for them.

The SBOM is attached to each platform image, not to the manifest list the tag resolves to. To read the SBOM of the image your Docker host runs, resolve the digest for its architecture and verify it with `--predicate-type https://spdx.dev/Document/v2.3` and `--format json`:

```bash
arch="$(docker version --format '{{ .Server.Arch }}')"
platform_digest="$(docker buildx imagetools inspect "ghcr.io/zama-ai/sdk-daemon@${ZAMA_SDK_DAEMON_DIGEST}" \
  --format "{{ range .Manifest.Manifests }}{{ if eq .Platform.Architecture \"${arch}\" }}{{ .Digest }}{{ end }}{{ end }}")"
gh attestation verify "oci://ghcr.io/zama-ai/sdk-daemon@${platform_digest}" --repo zama-ai/sdk \
  --predicate-type https://spdx.dev/Document/v2.3 --format json
```

Published images are re-scanned daily. A critical or high CVE in a published image is tracked in a GitHub issue on the repository and fixed with a patched release, so subscribe to releases and plan to [upgrade](https://docs.zama.org/protocol/sdk/go-and-rust-guide/operations/upgrade-and-recover.md) when one ships.

## Run with Docker Compose

The [Compose file](https://raw.githubusercontent.com/zama-ai/sdk/main/packages/sdk-daemon/deploy/compose.yaml) runs the daemon with a read-only root filesystem, no Linux capabilities, a healthcheck and a stop grace period above its shutdown timeout, and keeps its socket and SQLite storage in named volumes. A new named volume copies the image's private directories, so the daemon starts without host directory setup. The image runs the daemon as UID `10000` and GID `10001`.

Include it from your application's `compose.yaml`. Run your application as the same UID and GID and mount the socket volume where it connects:

```yaml
include:
  - zama-sdk-daemon.yaml

services:
  app:
    image: your-registry/your-app:APP_VERSION
    user: "10000:10001"
    environment:
      DAEMON_SOCKET: /run/zama/sdk.sock
    volumes:
      - socket:/run/zama:ro
    depends_on:
      daemon:
        condition: service_healthy
```

Download the daemon file next to it, then start both:

```bash
export ZAMA_SDK_VERSION=3.8.0
curl -fsSL -o zama-sdk-daemon.yaml "https://raw.githubusercontent.com/zama-ai/sdk/v${ZAMA_SDK_VERSION}/packages/sdk-daemon/deploy/compose.yaml"
docker compose up -d --wait
```

Set `ZAMA_SDK_VERSION` to the version of your Go module or Rust crate, and keep the `ZAMA_SDK_DAEMON_DIGEST` you verified above exported. `--wait` returns once the daemon's healthcheck passes. This works on Linux and on Docker Desktop.

### Application on a Linux host

When your application runs directly on a Linux host rather than in a container, use the [host Compose file](https://raw.githubusercontent.com/zama-ai/sdk/main/packages/sdk-daemon/deploy/compose.host.yaml). It mounts `socket` and `storage` directories next to the file and runs the daemon as your application's user, so the application can open the socket. Docker Desktop can't share a socket with a host process, so this applies to Linux only.

From the directory that will hold the daemon's files, replace `myapp` with the user your application runs as:

```bash
export ZAMA_SDK_VERSION=3.8.0
curl -fsSL -o compose.yaml "https://raw.githubusercontent.com/zama-ai/sdk/v${ZAMA_SDK_VERSION}/packages/sdk-daemon/deploy/compose.host.yaml"
sudo install -d -m 700 -o myapp -g myapp socket storage
ZAMA_SDK_DAEMON_UID="$(id -u myapp)" ZAMA_SDK_DAEMON_GID="$(id -g myapp)" docker compose up -d --wait
```

The daemon rejects directories that aren't private to its user, so create them before starting. Point the application at `socket/sdk.sock` in that directory. This file reads `ZAMA_SDK_DAEMON_DIGEST` too.

## Back up daemon SQLite storage

Treat the storage directory and every backup of it as sensitive. Each named store is a separate database in its own subdirectory.

1. Stop application writers and the daemon. The daemon holds each database lock while it runs.
2. Back up the whole storage directory with your backup tooling, preserving ownership and `0700` permissions. With the Compose file, the storage is the `storage` named volume, prefixed with your Compose project name. For example: `docker run --rm -v myapp_storage:/data:ro -v "$PWD":/backup alpine tar czf /backup/zama-storage.tgz -C /data .`
3. Keep the derivation secret, if you use one, in your secrets manager. The backup doesn't contain it.

To restore, copy the backup into a private volume for one stopped daemon, check that the daemon UID owns it, then start the matching client and daemon versions. Recreate SDK contexts with the original store names and derivation secret, and confirm a decryption succeeds without a new wallet signature before returning to service.

For application-owned storage, use your backend's own backup and restore procedure while its writers are stopped.

## Verify the deployment

1. Confirm the daemon log contains `Daemon ready.` and the container keeps running.
2. Confirm the liveness probe or container healthcheck passes.
3. From your application, create an SDK context with its production configuration and run an operation that reaches the RPC endpoint and relayer your workload uses.
4. Restart the daemon, recreate the SDK context, and confirm stored credentials are reused without a new wallet signature.
5. Confirm your application records operation latency and error codes, and detects callback-channel failures.

Use [Monitor and troubleshoot](https://docs.zama.org/protocol/sdk/go-and-rust-guide/operations/monitor-and-troubleshoot.md) for operational signals and [Upgrade the daemon](https://docs.zama.org/protocol/sdk/go-and-rust-guide/operations/upgrade-and-recover.md) for replacements.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zama.org/protocol/sdk/go-and-rust-guide/operations/run-in-production.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
