Skip to content
AnchrasDocumentation
Browse documentation

Getting started / User guide

Self-host Anchras

Run the Anchras control plane locally from source and prepare a separate production deployment.

On this page

Self-hosting runs the Anchras control plane in your own environment. It includes the API server, dashboard, PostgreSQL, and NATS with JetStream. This source-based procedure is for local evaluation; production needs durable storage, TLS, secrets, backups, and monitored services.

Prerequisites

  • Access to the Anchras source repository.
  • Go 1.26.8 or newer, Node.js 22 or newer, and the pnpm version pinned in the repository.
  • Docker with Compose for local dependencies.
  • buf, the protobuf plugins, sqlc, and the PostgreSQL-enabled migrate CLI.

Use the toolchain versions pinned by the checkout you are installing. The Anchras agent runs on Linux and macOS (Proxmox, virtual machine and Kubernetes node work needs a Linux agent); the management UI and CLI can run separately.

Prepare the checkout

bash
git clone https://github.com/anchras/platform.git
cd platform
test -f .env || cp .env.example .env
export PATH="$(go env GOPATH)/bin:$PATH"
bash scripts/install-buf.sh
INSTALL_OPENAPI_PLUGIN=1 bash scripts/install-proto-plugins.sh
go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.31.1
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
pnpm install --frozen-lockfile

Review .env before starting services. The example contains local development settings, not production credentials.

Start dependencies and migrate

Run from the repository root:

bash
set -a
. ./.env
set +a
export DOCKERHUB_PROXY=registry-1.docker.io
make dev-services

Wait for PostgreSQL to be ready, then apply the schema and generate API code:

bash
docker compose exec -T postgres pg_isready -U anchras
make migrate-up
make proto-generate
make build

PostgreSQL must include the extensions required by the migrations, including pgvector. NATS with JetStream must be reachable before the API starts.

Start the API and dashboard

In one terminal, from the repository root:

bash
set -a
. ./.env
set +a
cd server
go run ./cmd/server

In another terminal:

bash
cd web
pnpm dev

Open http://localhost:3000. The API listens on port 8080 and the agent endpoint on 8081. Check http://localhost:8080/health and http://localhost:8080/readyz before onboarding a machine.

Connect a remote hypervisor

Set the public server and agent URLs in .env to addresses reachable from the hypervisor. Use .env.example for the exact configuration available in your version. Preserve web and agent routing when placing the service behind a reverse proxy. Do not put localhost in a remote machine's install command.

The ANCHRAS_DEV_SINGLE_PORT option is for local LAN testing only. Production should preserve the web and agent routing separation.

Prepare for production

Use the deployment manifests and operator instructions supplied with your checkout to configure durable PostgreSQL and NATS storage, an HTTPS origin, appropriate CORS origins, persistent encryption keys, mail delivery, and service restart policies. Back up the database and the keys needed to decrypt credentials, then test restoration in an isolated environment.

For the default local key provider, set a dedicated ENCRYPTION_KEY and disable ALLOW_JWT_KMS_FALLBACK for production. External KMS providers require ENCRYPTION_KEY to be empty. Keep prior encryption keys available during planned rotations. Never use development seed data or development credentials in a public deployment.

Keep the root key in an HSM

By default, ENCRYPTION_KEY in your environment is the root of every stored credential. If your policy requires the root key to stay in a hardware security module (HSM) you control, use the PKCS#11 server image. Examples are Thales Luna, Entrust nShield and Utimaco. The HSM holds a non-extractable AES-256 key that wraps the installation's key-encryption key, so the server never sees the root key. Periodic checks use ANCHRAS_KMS_CHECK_INTERVAL; a completed check that returns a denial stops access to stored credentials. Unavailable checks retain the cached key until ANCHRAS_KMS_MAX_UNVERIFIED expires. A vendor module can block a check, so the interval is not a guaranteed revocation deadline. For HashiCorp Vault, OpenBao or OVHcloud KMS, keep the standard image and set ANCHRAS_KMS_PROVIDER to vault or ovh-okms.

Vendor PKCS#11 modules are glibc C libraries, and the standard server image cannot load them. The variant is built from server/Dockerfile.pkcs11 in the same checkout, with the same version build arguments. It is the same server with the same agent and CLI downloads, built with the pkcs11 provider on Debian. It also contains the kms-hygiene tool. The standard image refuses to start with ANCHRAS_KMS_PROVIDER=pkcs11 and reports that the provider was not compiled in.

To build the variant with Docker Compose, add this to the env file you pass to docker compose --env-file, then rebuild and restart the server service:

bash
ANCHRAS_SERVER_DOCKERFILE=server/Dockerfile.pkcs11

Without Compose, run docker build -f server/Dockerfile.pkcs11 -t anchras-server:pkcs11 . from the repository root.

Point the server at your HSM:

  1. On the HSM token or partition, create an AES-256 key with CKA_TOKEN, CKA_SENSITIVE, CKA_ENCRYPT and CKA_DECRYPT set, CKA_EXTRACTABLE false, and a unique label. Create a crypto-user PIN for Anchras.
  2. Mount the vendor's PKCS#11 client read-only under /opt/anchras/pkcs11 in the server container: the module library, its configuration and its certificates. Pass the client's own environment variables to the server, such as ChrystokiConfigurationPath for Luna.
  3. Mount the PIN in a file. The server runs as UID and GID 10001, which must be able to read the module, the configuration and the PIN file.
  4. Set ANCHRAS_KMS_PKCS11_MODULE to the library path inside the container, for example /opt/anchras/pkcs11/lib/libCryptoki2_64.so. Also set ANCHRAS_KMS_PKCS11_TOKEN_LABEL, ANCHRAS_KMS_PKCS11_KEY_LABEL and ANCHRAS_KMS_PKCS11_PIN_FILE, and optionally ANCHRAS_KMS_PKCS11_MECHANISM. .env.example describes each one.
  5. Set ANCHRAS_KMS_PROVIDER=pkcs11 and run kms-hygiene kek new in the variant image, for example with docker compose run --rm --no-deps --entrypoint /bin/kms-hygiene server kek new. Add the printed ANCHRAS_KMS_WRAPPED_KEK to the env file and restart the server.

The image includes glibc, libstdc++ and OpenSSL 3. If the server cannot load the module, run ldd on it inside the container. Add any library it reports as not found by building your own image FROM the variant, rather than mounting host libraries into it.

At startup the server logs kms keyring ready with "provider":"pkcs11". It retries an unreachable HSM for ANCHRAS_KMS_STARTUP_TIMEOUT and then refuses to start. A wrong PIN or an unknown key label stops the startup immediately.

Run Headscale for a disconnected install

A self-hosted install can coordinate its private network with your own Headscale server instead of Tailscale. Set HEADSCALE_API_URL and HEADSCALE_API_KEY, and set HEADSCALE_SERVER_URL to the address machines use to reach Headscale (its server_url) when that differs from the API address. Machines in organizations that use Headscale join that address, never Tailscale's coordination server, and do not upload Tailscale client logs.

Headscale still hands machines Tailscale's public relay (DERP) servers by default. On a network without internet access, enable Headscale's embedded DERP server and remove the public DERP map in its config.yaml:

yaml
server_url: https://headscale.example.internal
derp:
  server:
    enabled: true
    region_id: 999
    region_code: anchras
    region_name: Anchras embedded DERP
    stun_listen_addr: 0.0.0.0:3478
  urls: []
  paths: []
  auto_update_enabled: false

The embedded relay listens on the Headscale HTTPS port and on UDP port 3478 for STUN, so both must be reachable from every machine. If the Anchras server can access this file, set HEADSCALE_CONFIG_PATH to it; Anchras then manages Headscale's DNS settings there.

Troubleshooting

If startup exits, verify both PostgreSQL and NATS connectivity. If migrations fail, resolve the reported schema or extension error before starting the API. If the UI loads but login fails, check the web API URL, proxy routing, and CORS settings.

If you do not have access to the source distribution, you can still use the hosted platform and install its CLI or connect your hypervisor.