Skip to content

Self-hosting

xixo ships as a container image. Point it at Postgres and OpenSearch, and it migrates itself on boot. Sign-in is built in: xixo serves its own masks at /id.

Web The image’s default command, ./bin/thrust ./bin/rails server, on port 80
Worker ./bin/jobs, from the same image
xixo link beside the server ghcr.io/xixo/xixo-link, which reads and writes the server’s files
Postgres xixo_production, xixo_production_cache, xixo_production_queue, xixo_production_cable, and xixo_production_masks for the built-in masks
OpenSearch The search index

When the container runs the web command, bin/docker-entrypoint runs these before the server starts:

  • bin/rails db:prepare creates or migrates the databases.
  • bin/rails xixo:tenants creates the catalog named in XIXO_TENANT, in xixo and in the built-in masks.
  • bin/rails xixo:resources declares the resources in config/resources.yml.

Any other command starts without them.

Tag Pushed on
:<version>, such as :0.2.0, and :<major>.<minor>, such as :0.2 each server release
:main, :sha-<full commit sha>, and :latest every push to main

ghcr.io/xixo/xixo is built for amd64. ghcr.io/xixo/xixo-link and ghcr.io/xixo/xixo-updater are built for amd64 and arm64. Each image carries a build attestation, which gh attestation verify oci://ghcr.io/xixo/xixo:main --repo xixo/xixo checks.

A server release has a server-v<version> tag and its changes in CHANGELOG.md. An image built from main holds the same xixo link builds and mac reader as a release, and names its commit after the release it follows, such as 0.2.0+1a2b3c4. A machine on 0.2.0 takes that build, and takes 0.2.1 after it. Pin a version in production and read the changelog before you change it, or follow :main to run every push. :latest follows main.

In production xixo always connects as the role xixo, with the password in XIXO_DATABASE_PASSWORD. POSTGRES_USER is not read there. The official Postgres image makes POSTGRES_USER a superuser, so xixo cannot use it.

  1. Connect to Postgres as an administrator and create the role:

    CREATE ROLE xixo WITH LOGIN PASSWORD 'change-me' CREATEDB;

    CREATEDB lets db:prepare create the databases on first boot. To create them yourself, create each one with OWNER xixo and leave CREATEDB off.

  2. Check that the role holds neither SUPERUSER nor BYPASSRLS:

    SELECT rolsuper, rolbypassrls FROM pg_roles WHERE rolname = 'xixo';

    Both must be f. Every table in the catalog is behind a row-level security policy, and a role with either attribute skips it. xixo and the built-in masks refuse to serve requests as such a role.

The database holds every resource’s credentials and the masks client secret. xixo encrypts those columns with Active Record Encryption. The built-in masks derives its own keys from SECRET_KEY_BASE.

Secret Protects
SECRET_KEY_BASE Session cookies, and every key the built-in masks uses. Anyone who holds it can forge a session. Changing it signs everyone out of masks and makes its encrypted columns unreadable.
ENCRYPTION_PRIMARY_KEY, ENCRYPTION_DETERMINISTIC_KEY, ENCRYPTION_KEY_DERIVATION_SALT xixo’s encrypted columns.
  1. Generate SECRET_KEY_BASE in a xixo checkout:

    Terminal window
    bin/rails secret
  2. Generate the encryption keys in the same checkout:

    Terminal window
    bin/rails db:encryption:init
  3. Set the three values it prints as variables:

    Printed as Variable
    primary_key ENCRYPTION_PRIMARY_KEY
    deterministic_key ENCRYPTION_DETERMINISTIC_KEY
    key_derivation_salt ENCRYPTION_KEY_DERIVATION_SALT

Production refuses to boot when any of the four is unset or starts with dev_only_, the prefix of the development values in .env.example and compose.yml.

  1. Set XIXO_TENANT to a name for the catalog, such as xixo. The built-in masks names its tenant the same, and the folders xixo link beside the server uses are named after it. Without it, every page answers 404 Unknown tenant.
  2. Set XIXO_HOST_SUFFIX to the domain xixo answers under, such as xixo.example.com. Rails then answers 403 to any other Host, except at /up. Unset, Rails accepts every host.
  3. Set XIXO_PUBLIC_ORIGIN to the origin browsers use, such as https://xixo.example.com. Production refuses to boot without it.
  4. Point DNS for the host at your reverse proxy.

The proxy must terminate TLS and pass the original Host header. RAILS_ASSUME_SSL and RAILS_FORCE_SSL default to true.

One xixo can also serve several separate catalogs, each at its own host. See multiple tenants.

x-xixo: &xixo
image: ghcr.io/xixo/xixo:0.2
restart: unless-stopped
environment:
POSTGRES_HOST: postgres
XIXO_DATABASE_PASSWORD: ...
OPENSEARCH_URL: http://opensearch:9200
OPENSEARCH_USERNAME: admin
OPENSEARCH_PASSWORD: ...
SECRET_KEY_BASE: ...
ENCRYPTION_PRIMARY_KEY: ...
ENCRYPTION_DETERMINISTIC_KEY: ...
ENCRYPTION_KEY_DERIVATION_SALT: ...
XIXO_TENANT: xixo
XIXO_HOST_SUFFIX: xixo.example.com
XIXO_PUBLIC_ORIGIN: https://xixo.example.com
MASKS_MAIL_FROM: xixo@example.com
MASKS_SMTP_ADDRESS: smtp.example.com
MASKS_SMTP_USERNAME: ...
MASKS_SMTP_PASSWORD: ...
XIXO_LOCAL_LINK: /handoff
volumes:
- storage:/rails/storage
- link-handoff:/handoff
services:
xixo:
<<: *xixo
healthcheck:
test: ["CMD", "curl", "-fsS", "http://localhost/up"]
interval: 30s
timeout: 5s
retries: 3
start_period: 180s
deploy:
resources:
limits:
memory: 1g
depends_on:
postgres:
condition: service_healthy
opensearch:
condition: service_healthy
worker:
<<: *xixo
command: ["./bin/jobs"]
healthcheck:
test: ["CMD", "bin/jobs-healthy"]
interval: 30s
timeout: 10s
retries: 3
start_period: 120s
deploy:
resources:
limits:
memory: 2g
depends_on:
xixo:
condition: service_healthy
link:
image: ghcr.io/xixo/xixo-link:0.2
restart: unless-stopped
environment:
XIXO_LINK_XIXO: https://xixo.example.com
XIXO_LINK_ISSUER: https://xixo.example.com/id
XIXO_LINK_HANDOFF: /handoff/xixo
XIXO_LINK_WRITABLE: /data/files/xixo
volumes:
- link-state:/var/lib/xixo-link
- link-handoff:/handoff
- files:/data/files
deploy:
resources:
limits:
memory: 6g
depends_on:
xixo:
condition: service_healthy
postgres:
image: postgres:17-alpine
restart: unless-stopped
environment:
POSTGRES_PASSWORD: ...
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 10
deploy:
resources:
limits:
memory: 1g
volumes:
- postgres:/var/lib/postgresql/data
- ./initdb:/docker-entrypoint-initdb.d:ro
opensearch:
image: opensearchproject/opensearch:2.19.1
restart: unless-stopped
environment:
discovery.type: single-node
OPENSEARCH_INITIAL_ADMIN_PASSWORD: ...
plugins.security.ssl.http.enabled: "false"
OPENSEARCH_JAVA_OPTS: -Xms512m -Xmx512m
healthcheck:
test: ["CMD-SHELL", "curl -fsS -u \"admin:$${OPENSEARCH_INITIAL_ADMIN_PASSWORD}\" http://localhost:9200/_cluster/health"]
interval: 10s
timeout: 5s
retries: 30
deploy:
resources:
limits:
memory: 1536m
volumes:
- opensearch:/usr/share/opensearch/data
caddy:
image: caddy:2-alpine
restart: unless-stopped
ports:
- "443:443"
- "80:80"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy-data:/data
depends_on:
- xixo
volumes:
storage:
files:
link-state:
link-handoff:
postgres:
opensearch:
caddy-data:

initdb/01-xixo.sql holds the CREATE ROLE statement from the database role, with the password in XIXO_DATABASE_PASSWORD. Postgres runs it when its volume is first created. The Caddyfile sends the host to xixo:

xixo.example.com {
reverse_proxy xixo:80
}

Notes on the file:

  • OPENSEARCH_INITIAL_ADMIN_PASSWORD sets the admin password when the volume is first created. OpenSearch refuses to start when it is weak.
  • Traffic between the containers is plain HTTP. Keep Postgres and OpenSearch on a network that only xixo reaches, and publish no port for either.
  • masks sends invitations, password resets, and sign-in codes from MASKS_MAIL_FROM through the MASKS_SMTP_ server. Without them, masks sends no mail.
  • The worker waits for the web container to report healthy, so it never runs before the migrations.
  • OpenSearch gets three times its heap. xixo link gets 6 GB, because a program it runs on one file may use up to 4 GB, and exiftool up to 6 GB.
  • Chromium in the worker keeps its sandbox. Leave XIXO_CHROME_NO_SANDBOX unset, and never run the worker privileged.

xixo signs people in through masks, and by default it serves that masks itself at /id, such as https://xixo.example.com/id. See signing in.

  1. Start the stack:

    Terminal window
    docker compose up -d
  2. Find the setup token that xixo:tenants prints while masks has no account yet:

    Terminal window
    docker compose logs xixo | grep "masks:"

    To choose the token yourself, set MASKS_SETUP_TOKEN to at least 24 characters before you start.

  3. Open xixo in a browser and click Get started….

  4. Enter the setup token when masks asks for it.

  5. Create the first account. That account owns the masks tenant.

  6. Approve xixo when masks asks. You are signed in.

The account that owns the masks tenant becomes xixo’s administrator on its first sign-in. Invite everyone else from masks at /id/manage.

The built-in masks reads the other variables a masks server reads, such as MASKS_SMTP_PORT. See the masks ENV vars. It ignores MASKS_TENANT, MASKS_TENANTS, and MASKS_PUBLIC_ORIGIN_TEMPLATE, because xixo sets them from its own variables.

To sign in through a masks server that runs apart from xixo, see a masks server of your own.

xixo opens no file itself. The link container runs xixo link, which reads every file for the server, writes uploads into the files volume, and runs the programs that read documents, images, and recordings. See machines.

It takes these settings:

XIXO_LINK_XIXO xixo’s origin.
XIXO_LINK_ISSUER xixo’s masks issuer: the origin followed by /id with the built-in masks.
XIXO_LINK_HANDOFF /handoff/xixo, the folder named after XIXO_TENANT in the volume the web and worker containers mount at XIXO_LOCAL_LINK.
XIXO_LINK_WRITABLE Folders it may read and write, separated by colons. Each one is created on boot when it is missing.
XIXO_LINK_FOLDERS Folders it may only read, separated by colons. Mount each one read-only.

It enrolls itself after the first sign-in connects xixo to masks:

  1. xixo link leaves a request in /handoff/xixo.
  2. The worker answers with a single-use enrollment token.
  3. xixo link registers its own key with masks, and keeps it in its state volume.

Deleting the state volume makes it enroll again. It shows on the Resources page as This server. Each folder it shares joins the catalog by itself. A folder the deployment declares, such as files, is everyone’s, and any other is held for the administrator who signs in first. xixo may do everything with the folders it shares, and writes into the ones named in XIXO_LINK_WRITABLE.

xixo uses storage in two places.

  • Staging. Uploads wait in Active Storage until a job places them. The default, XIXO_STAGING_SERVICE=local, writes to /rails/storage, so the web and worker containers must share it. To stage in S3-compatible storage, set XIXO_STAGING_SERVICE=s3 and the other XIXO_STAGING_ variables on the ENV vars page.
  • Catalog storage. config/resources.yml declares a filesystem resource named Files as the default storage, at /data/files/xixo on xixo link beside the server, the folder named after XIXO_TENANT. That folder must be in XIXO_LINK_WRITABLE, on a volume mounted into the link container. Until xixo link connects, a placed upload waits. To keep files somewhere else, see attaching a resource.

xixo refuses to reach a private, loopback, or link-local address for a resource. List the origins of services on your own network, separated by commas:

Variable Lets through
XIXO_S3_ORIGINS An s3 endpoint, such as a MinIO container at http://minio:9000
XIXO_MCP_ORIGINS An MCP server attached as a resource
XIXO_SEARCH_ORIGINS A self-hosted web search backend
XIXO_INFERENCE_ORIGINS Every model server, public or private, such as https://api.openai.com,http://ollama:11434

A model server whose origin is not in XIXO_INFERENCE_ORIGINS is unusable, unless xixo reaches it through a machine running xixo link. See security.

Audio and video are transcribed by a resource that serves the transcription role. Without one, each recording is analyzed without a transcript. Any server that answers OpenAI’s /audio/transcriptions works, such as whisper.cpp’s whisper-server:

  1. Download a model on the machine with the best GPU. ggml-base.en.bin transcribes English, and the models without .en transcribe other languages.

    Terminal window
    curl -fL -o ggml-base.en.bin \
    https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin
  2. Start the server:

    Terminal window
    whisper-server -m ggml-base.en.bin --host 0.0.0.0 --port 11435 \
    --inference-path /v1/audio/transcriptions
  3. Attach an openai-compatible resource with the base URL http://<host>:11435/v1. Give it any name as its Transcription model, because whisper.cpp answers with the model it started with.

  4. Add the origin to XIXO_INFERENCE_ORIGINS, or reach the server through a machine running xixo link.

./bin/jobs starts Solid Queue, which runs every job and the schedule in config/recurring.yml. BULK_CONCURRENCY, ANALYSIS_CONCURRENCY, and ANALYSIS_THREADS size its pools. See jobs.

  • Raise ANALYSIS_CONCURRENCY when analyses wait in the queue. Chromium holds a core while it renders a snapshot.
  • On a small host, set SOLID_QUEUE_IN_PUMA=true on the web container and run no worker.
  • Syncs and exports save their place as they go, so a restarted worker carries on from there.
  • XIXO_ITERATORS_DISABLED=true stops every sync, analysis, export, and reindex.

Follow job progress in the worker’s log:

Terminal window
docker compose logs -f worker

Mission Control is mounted at /jobs. Its HTTP basic authentication is on, and xixo sets no user or password for it, so it answers 401 to every request. Leave it closed, or block /jobs at the proxy.

GET /up checks the database, the search index, the queue, and the workers. It skips the host check and is not logged.

Terminal window
docker compose exec -T xixo curl -fsS http://localhost/up
{"status":"ok","checks":{"database":"ok","search":"ok","queue":"ok","worker":"ok"}}
Check Fails when
database The primary database does not answer.
search OpenSearch does not answer within two seconds, or its cluster is red.
queue A job has waited more than ten minutes for a worker.
worker No worker has sent a heartbeat in XIXO_WORKER_QUIET_SECONDS, 300 by default. It always passes with SOLID_QUEUE_IN_PUMA set.

/up answers 503 when database or search fails, and 200 otherwise. A late queue or a quiet worker shows in the body without failing, so a slow worker does not restart the web container.

bin/jobs-healthy checks the worker. It exits 0 when a worker on the same host sent a heartbeat within the same window, and 1 with the reason when none did.

  1. Read CHANGELOG.md for every release between the one you run and the one you move to.

  2. Back up the catalog. Starting the old image again does not undo a migration. See back up.

  3. Change the image tags in compose.yml to the new version.

  4. Pull the images and recreate the containers:

    Terminal window
    docker compose pull
    docker compose up -d

The web container applies new migrations on start, and the worker starts after it reports healthy. To go back, restore the backup and start the old version.

xixo-updater keeps the server on builds that xixo’s CI built and signed. It runs as two containers from ghcr.io/xixo/xixo-updater:

updater Checks the registry every 15 minutes. It has network access and no Docker socket.
updater-gate Pulls images and replaces containers. It has the Docker socket and no network.

Each image CI pushes carries a build attestation, signed through Sigstore, that names the repository, workflow, and commit that built it. The updater checks it before asking for an update, and the gate checks it again offline before it pulls or replaces anything. An image without one is refused, and the refusal is logged.

  1. In x-xixo, change the image to a local tag that only the gate moves:

    x-xixo: &xixo
    image: xixo-updates/xixo:current
    pull_policy: never
  2. Do the same for link:

    link:
    image: xixo-updates/xixo-link:current
    pull_policy: never
    labels:
    network.xixo.updates: xixo-link
  3. Label xixo and worker, and make xixo wait for the gate:

    xixo:
    labels:
    network.xixo.updates: xixo
    network.xixo.updates.order: "1"
    depends_on:
    updater-gate:
    condition: service_healthy
    worker:
    labels:
    network.xixo.updates: xixo
    network.xixo.updates.order: "2"
  4. Add the two updater services and their volumes:

    services:
    updater-gate:
    image: ghcr.io/xixo/xixo-updater:0.6
    command: ["gate"]
    user: root
    network_mode: none
    restart: unless-stopped
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - updater-gate:/run/xixo-updates/gate
    - updater-tuf:/run/xixo-updates/tuf:ro
    - updater-gate-cache:/var/lib/xixo-updates/cache
    healthcheck:
    test: ["CMD", "/usr/local/bin/xixo-updater", "ready"]
    interval: 30s
    start_period: 30m
    start_interval: 5s
    updater:
    image: ghcr.io/xixo/xixo-updater:0.6
    command: ["watch"]
    restart: unless-stopped
    environment:
    XIXO_UPDATES_CHANNEL: releases
    volumes:
    - updater-gate:/run/xixo-updates/gate
    - updater-tuf:/run/xixo-updates/tuf
    - updater-state:/var/lib/xixo-updates/state
    - updater-cache:/var/lib/xixo-updates/cache
    - updater-requests:/run/xixo-updates/requests:ro
    volumes:
    updater-gate:
    updater-tuf:
    updater-gate-cache:
    updater-state:
    updater-cache:
    updater-requests:
  5. Give xixo the updater’s state to read and a folder to leave requests in, so Settings > Updates works:

    xixo:
    volumes:
    - updater-state:/var/lib/xixo-updates/state:ro
    - updater-requests:/run/xixo-updates/requests
  6. Start the stack:

    Terminal window
    docker compose up -d

On the first start, the updater fetches the newest signed build and the gate tags it as xixo-updates/xixo:current and xixo-updates/xixo-link:current. The other containers wait until the gate reports healthy, which it does once it holds a build of each. After that, docker compose up -d keeps the build the gate pinned, because the tag never changes.

  1. The gate pulls every new image by digest.
  2. It replaces each labeled container, lowest network.xixo.updates.order first. It keeps the container’s own settings, volumes, and networks, changes only the image, and waits until Docker reports the container healthy. The web container runs the migrations, so it goes first.
  3. The updater watches the containers for five minutes.

When a container does not come up, or turns unhealthy while it is watched, every container goes back to the build before it, tagged xixo-updates/xixo:previous. That build is marked bad and is not tried again. A newer build is. The gate refuses a build older than the one running.

A rollback starts the build before on the database the newer build migrated. A release adds tables and columns and removes them one release later, and CI rehearses the rollback of every build: it starts the last release, migrates with the new build, and starts the last release again. Settings > Updates says what a rollback keeps, and after one, what the database holds from the newer build. Back up before you follow a channel, and see restore when a rollback does not come up.

Variable Default Purpose
XIXO_UPDATES_CHANNEL releases releases follows the highest x.y.z tag, signed by release.yml. main follows :main, signed by ci.yml after the tests pass. Set on updater.
XIXO_UPDATES_KINDS xixo,xixo-link What the gate keeps up to date. Add masks when a masks server of your own runs on the same host, and label its container network.xixo.updates: masks. Set on updater-gate.

Settings > Updates shows what each image runs, the last ten events, and Update now, Pause updates, Roll back, and the channel. Administrators see it. A request goes to the updater through request.json, which the updater reads and never writes back to, and each one is in the audit log.

The updater does not update itself. Each check also looks up the newest signed xixo-updater build on the channel, and Settings > Updates says when it is newer than the one running. To take it, change the image tag of updater and updater-gate in the compose file and run docker compose up -d updater updater-gate. The build the gate pinned stays where it is.

/var/lib/xixo-updates/state in the updater container holds status.json, with each image’s digest, commit, and containers, the updater’s own version and the newest signed one, and events.jsonl, with the last 1,000 checks, pulls, swaps, rollbacks, and refusals. docker compose logs updater updater-gate shows the same events.

Every administrator sees the Machines section of Settings > Updates, which shows the rollout of xixo link to the linked machines and lets them steer it, as add a machine describes.

From 0.2, xixo link beside the server reads and writes the files resource. A migration moves every filesystem resource to a folder on xixo link beside the server, at the path the server used, so files becomes /data/files/xixo, named after XIXO_TENANT. Before you upgrade:

  1. Mount the volume that held /data/files into the link container at /data/files, read-write.

  2. Set XIXO_LINK_WRITABLE to /data/files/xixo on xixo link beside the server.

  3. Give xixo link, which runs as uid 1000, ownership of the files:

    Terminal window
    docker compose run --rm --user root --entrypoint chown link -R 1000:1000 /data/files
  4. Remove the /data/files mount from the web and worker containers.

  5. Remove XIXO_FILESYSTEM_ROOTS from the web and worker containers after the migration ran. The migration reads it to find where the files were.

A filesystem resource with a root in another directory moves to that path. Mount the directory into the link container at the same path, and name it in XIXO_LINK_FOLDERS or XIXO_LINK_WRITABLE. Until you do, the resource is unusable.

  • Every page answers 404 Unknown tenant: XIXO_TENANT is not set.

  • Requests answer 403: the request’s host is outside XIXO_HOST_SUFFIX.

  • Tenant::Exposed, naming the role: the database role holds SUPERUSER or BYPASSRLS. Remove them with ALTER ROLE xixo NOSUPERUSER NOBYPASSRLS;.

  • The container exits with XIXO_PUBLIC_ORIGIN is not set: set it to the origin browsers use.

  • The container exits with Switch::Invalid: a switch holds a value other than true or false. The error names it.

  • No setup token in the logs: the masks tenant already has an account. Sign in with it, or set MASKS_RECOVER as the masks docs describe.

  • Uploads stage but never land: the worker is not running, or it cannot read the web container’s /rails/storage. Check docker compose ps and docker compose logs worker.

  • “shares /data/files/xixo read-only” or “no longer shares”: xixo link beside the server does not list the folder in XIXO_LINK_WRITABLE, or its volume is not mounted into the link container.

  • An s3 resource on your network fails its check: add its origin to XIXO_S3_ORIGINS.

  • Many files failed while a model server was away: once it answers again, start them over. Each file whose last analysis failed or ran out of time waits for the model server again, and xixo starts them 50 at a time. Pass since: to go back only so far. xixo is the name in XIXO_TENANT.

    Terminal window
    docker compose exec xixo bin/rails runner 'Tenant.switch(Tenant.find_by!(subdomain: "xixo")) { puts Analysis.retry_failed!(since: 2.days.ago) }'