Skip to content

Deploy

cicord serve is a single static binary: the runtime (reconciler, bot gateways, plugin host), the HTTP API, the admin console (/admin/) and the default community portal (/). It needs a data directory and outbound access to Discord (and to your git host). There is no database server, no Node.js and no git binary to install: git is implemented in Go and SQLite is a pure Go driver. If you prefer, a PostgreSQL database can hold the runtime state instead of SQLite.

cicord serve [dir] [--data-dir DIR] [--database-url URL] [--listen ADDR] [--public-url URL] [--admin-url URL] [--cors-origin ORIGIN]... [--log-level LEVEL] [--local] [--github-app-key-file FILE]
  • dir (default .) must contain cicord.yaml. Its spec.source says what to follow:
    • provider: github or git, with repo, branch (default main), path and pollInterval (default 1m): the runtime clones and polls the repository. dir only needs cicord.yaml.
    • provider: embedded: on first start, the contents of dir are imported into a bare repository in the data directory (repo.git), which is then the source of truth.
    • no spec.source, or --local: dir is watched as is (no git). Admin console edits are written to the files, so dir must be writable.
  • --listen defaults to :7420.
  • --public-url (env CICORD_PUBLIC_URL) is the URL browsers use, for example https://cicord.example.org. Set it for every non-local deployment: it is the OAuth redirect base, the base of portal links, the origin of the CSRF check, and an https:// value turns on Secure cookies. Without it, the runtime assumes http://<listen>, and browser POST/PUT requests from any other origin are rejected with 403.
  • --admin-url (env CICORD_ADMIN_URL): the URL of the admin console when it lives on a separate, private hostname, for example https://cicord.example.ts.net on a Tailscale tailnet, while the portal stays public on --public-url. It must be https://host[:port] without a path (http only for a loopback host) and differ from the public URL. Requests on that hostname log in with the admin URL, and the admin console and admin API answer 404 on every other hostname. See Admin on a private network, portal public.
  • --cors-origin (repeatable; env CICORD_CORS_ORIGINS, comma-separated): origins of external portals allowed to call the API with credentials (cookie sessions).
  • --data-dir defaults to .cicord-data, relative to the working directory. With a local source inside the repository, it must be under <repo>/.cicord/.
  • --database-url (env CICORD_DATABASE_URL): PostgreSQL connection URL of the state store. Unset: SQLite in the data directory, which is needed either way. The URL is never logged.
  • --log-level: debug, info (default), warn or error.
  • --github-app-key-file (env CICORD_GITHUB_APP_PRIVATE_KEY_FILE): the GitHub App private key as a file (a Docker or Kubernetes secret mounted as a file), instead of the CICORD_GITHUB_APP_PRIVATE_KEY secret. See GitHub access.

Started in a directory without cicord.yaml, cicord serve enters setup mode and prints a one-time link to the setup wizard.

Variable Purpose
DISCORD_TOKEN_* Bot tokens. The name is each bot’s spec.token.secretRef, e.g. DISCORD_TOKEN_MODERATOR. A missing token leaves that bot Missing.
CICORD_GIT_TOKEN HTTPS token to fetch a private repository, push write-back commits, open GitHub pull requests and set commit statuses (see GitHub access).
CICORD_GITHUB_APP_ID GitHub App ID: authenticate as a GitHub App instead of a token (it takes precedence over CICORD_GIT_TOKEN).
CICORD_GITHUB_APP_PRIVATE_KEY The App’s private key (the .pem content), or --github-app-key-file.
CICORD_GITHUB_APP_INSTALLATION_ID The App’s installation. Optional: discovered from spec.source.repo on github.com.
CICORD_RUNTIME_TOKEN Bearer token of the CLI and CI (cicord plan --remote, cicord status, cicord sync). Acts as admin on every server. Unset: the machine endpoints answer 401.
CICORD_WEBHOOK_SECRET Secret of the GitHub webhook (POST /hooks/github). Unset: webhooks are rejected.
CICORD_DISCORD_CLIENT_SECRET OAuth2 client secret for “Log in with Discord” (admin console, portal). Unset: /auth/login answers 503.
CICORD_DISCORD_CLIENT_ID OAuth2 client ID. Default: the application ID of the first bot (by key).
CICORD_LINK_SECRET Signing key of portal links. Default: generated once in the data directory (link.key).
CICORD_SECRET_KEY Key of the encrypted secret store: base64 or hex of exactly 32 bytes (openssl rand -base64 32). Default: secret.key, generated in the data directory.
CICORD_PUBLIC_URL, CICORD_CORS_ORIGINS Defaults of --public-url and --cors-origin.
CICORD_ADMIN_URL Default of --admin-url: the admin console on a separate, private hostname.
CICORD_DATABASE_URL Default of --database-url (also read by cicord dev and cicord secret): use PostgreSQL for the state store. Unset: SQLite in the data directory.
CICORD_CACHE_DIR Plugin download cache. Default: the user cache directory; the Docker image sets /data/cache.
CICORD_ALLOW_PRIVATE_REGISTRIES true lets the Store and plugin downloads reach private networks.
CICORD_REGISTRY_<NAME>_TOKEN Access token of a private registry (see Publishing).

Bot tokens, CICORD_GIT_TOKEN, the CICORD_GITHUB_APP_* secrets, the OAuth client secret and registry tokens can also live in the encrypted secret store (the setup wizard writes them there, cicord secret set too). The environment always wins. See Backups and secrets.

In the Discord developer portal, add <public-url>/auth/callback as an OAuth2 redirect URL of the application used for login, and also <admin-url>/auth/callback when --admin-url is set.

Path Content Back up?
cicord.db (+ cicord.db-wal, cicord.db-shm) SQLite (WAL mode): resource map, plugin storage, sessions, audit log, sync history, encrypted secrets. Absent with PostgreSQL. Yes
secret.key Key of the secret store (when CICORD_SECRET_KEY is not set). Yes
link.key Portal link signing key (when CICORD_LINK_SECRET is not set). Losing it invalidates outstanding links. Yes
repo.git Bare repository of the embedded provider: this is your configuration. Yes
source/ Clone of the git source. No (fetched again)
writeback/ Work tree used to commit and push admin console edits. No
snapshots/ Snapshots of a local source. No
cache/ (Docker image) Downloaded plugins. No

Run a single runtime per data directory, per state database and per set of bot tokens (scheduled tasks are not claimed across processes). Backups are covered in Backups and secrets.

The state store holds the resource map, plugin storage, scheduled tasks, sessions, the audit log, the sync history and the encrypted secrets.

  • SQLite (default): cicord.db in the data directory. Nothing to install or operate.
  • PostgreSQL (14 or later): set --database-url or CICORD_DATABASE_URL, for example postgres://cicord@db.internal:5432/cicord?sslmode=verify-full. Useful when the database is managed separately (backups, replication, monitoring).

With PostgreSQL:

  • Keep the data directory. It still holds secret.key (unless CICORD_SECRET_KEY is set), link.key (unless CICORD_LINK_SECRET is set), repo.git for the embedded provider and the caches. The secrets in the database are encrypted with that key: a runtime started with a new data directory against an existing database refuses to start. Setting CICORD_SECRET_KEY removes that dependency.

  • Create an empty database owned by the runtime’s user. Cicord creates and migrates its tables at startup (in one transaction, under an advisory lock) and refuses a database whose schema is newer than the binary.

    CREATE ROLE cicord LOGIN PASSWORD '…';
    CREATE DATABASE cicord OWNER cicord;
  • Connection options go in the URL: sslmode (use verify-full across a network), pool_max_conns, search_path=<schema> for a dedicated schema (create it first), default_query_exec_mode=exec behind PgBouncer in transaction mode. The password can come from PGPASSWORD or ~/.pgpass instead of the URL. The startup log shows postgres://user@host:port/database, never the password.

  • Same behavior as SQLite: both backends pass the same conformance suite (CI runs it on PostgreSQL 19). Text fields other than plugin storage keys and values (server keys, resource keys, IDs) must be valid UTF-8 without NUL bytes, which keys from YAML always are; audit and sync entries are ordered by ID, allocated from a sequence.

  • No conversion tool between the backends yet: switching starts from an empty state (Discord resources are adopted again by name; plugin data, history and stored secrets are not carried over).

With Compose, add a postgres service and point the runtime at it:

compose.yaml (excerpt)
services:
cicord:
# ... as above, plus:
environment:
CICORD_DATABASE_URL: postgres://cicord@postgres:5432/cicord?sslmode=disable
PGPASSWORD: ${CICORD_DB_PASSWORD} # from .env, keeps the password out of the URL
depends_on:
postgres: { condition: service_healthy }
postgres:
image: postgres:19
restart: unless-stopped
environment:
POSTGRES_USER: cicord
POSTGRES_PASSWORD: ${CICORD_DB_PASSWORD}
volumes: [cicord-pg:/var/lib/postgresql]
healthcheck:
test: ["CMD", "pg_isready", "-U", "cicord"]
interval: 5s
volumes:
cicord-data:
cicord-pg:

Each release publishes the multi-arch image ghcr.io/cicord/cicord:<version> (linux/amd64, linux/arm64; how to verify it: Installation). Pull it and give it the short name used below, or build the same image from the repository:

Terminal window
docker pull ghcr.io/cicord/cicord:0.1.0 && docker tag ghcr.io/cicord/cicord:0.1.0 cicord
# or
docker build -t cicord --build-arg VERSION=0.1.0 --build-arg COMMIT=$(git rev-parse --short HEAD) .

It runs cicord serve /repo --data-dir /data --listen :7420 as user 65532 on a distroless image, with a volume on /data and port 7420, and a HEALTHCHECK (cicord healthcheck, which probes http://127.0.0.1:7420/healthz; override it if you change --listen). /repo must contain at least cicord.yaml.

For a git source, mounting cicord.yaml alone is enough:

Terminal window
docker run -d --name cicord --restart unless-stopped \
-p 127.0.0.1:7420:7420 \
-v cicord-data:/data \
-v "$PWD/cicord.yaml:/repo/cicord.yaml:ro" \
--env-file cicord.env \
cicord serve /repo --data-dir /data --listen :7420 --public-url https://cicord.example.org

Arguments after the image name replace the default command, so repeat the defaults when you add flags. The entrypoint is cicord, so docker run --rm cicord validate /repo works too.

  • A named volume inherits the ownership of /data from the image (65532). For a bind mount, chown 65532:65532 the host directory first.

  • For a local source (no spec.source), mount the whole repository at /repo, writable if admin console edits should be saved (:ro makes write-back fail).

  • Health: GET /healthz (process up) and GET /readyz (a revision is active; 503 before). The image has no shell or curl; cicord healthcheck checks http://127.0.0.1:7420/healthz from inside the container (exit 0 on 200), for a Docker HEALTHCHECK or a Compose healthcheck:

    healthcheck:
    test: ["CMD", "/usr/local/bin/cicord", "healthcheck"]
    interval: 30s
    timeout: 5s
  • Stop with SIGTERM (docker stop): the HTTP server and the bots shut down gracefully (about 25 seconds).

Run Cicord behind a TLS-terminating proxy (Caddy, nginx, Traefik) and keep port 7420 private (bound to 127.0.0.1 or an internal network).

  • --public-url must be exactly the scheme, host and port browsers see. The CSRF check compares the browser’s Origin with it, so the proxy must pass Origin through unchanged. Without --admin-url, Host is not used by cicord serve; with it, Host tells the admin hostname from the others, so every proxy must pass the original Host (Caddy does by default, nginx with proxy_set_header Host $host).
  • Request bodies: JSON up to 1 MiB, POST /api/v1/plan up to 32 MiB (for nginx, client_max_body_size 32m). API handlers time out after 60 seconds and a configuration edit may wait up to 20 seconds for the new revision, so keep proxy read timeouts above 60 seconds.
  • An external portal on another origin is allowed with --cors-origin https://portal.example.org.
Caddyfile
cicord.example.org {
reverse_proxy 127.0.0.1:7420
}

Every access to the configuration repository (fetch, write-back pushes, pull requests, commit statuses) uses one of these credentials:

  • A personal access token, CICORD_GIT_TOKEN: a fine-grained token restricted to the configuration repository, with the permissions below. Simple, but tied to a person and long-lived.
  • A GitHub App, recommended for organizations: commits, pull requests and statuses appear as <app-name>[bot]. The runtime only holds the App’s private key; it mints installation tokens that expire after an hour, restricted to the configuration repository, and renews them before they expire. When the App is configured, it takes precedence over CICORD_GIT_TOKEN. The App can only be used with a repository on github.com (https://github.com/owner/name): its tokens are never sent to another host. For a repository hosted elsewhere, use a token.

Repository permissions, the same for a fine-grained token and for the App:

Permission Access Used for
Contents Read and write fetching, write-back commits and cicord/change-… branches
Pull requests Read and write the pullRequest write-back mode
Commit statuses Read and write the cicord/sync commit status
Metadata Read-only mandatory (selected automatically)

No organization or account permission is needed.

  1. On GitHub, open Settings → Developer settings → GitHub Apps → New GitHub App (for an organization: the organization’s Settings → Developer settings → GitHub Apps).
  2. Enter a name (it becomes the commit author, for example acme-cicord[bot]) and a homepage URL (your public URL).
  3. Webhook is optional. Uncheck Active to rely on polling, or set the webhook URL to <public-url>/hooks/github, its secret to CICORD_WEBHOOK_SECRET, and subscribe to the Push event (other events are acknowledged and ignored). See Webhooks.
  4. Set the repository permissions of the table above.
  5. Under Where can this GitHub App be installed?, choose Only on this account, then create the App.
  6. Note the App ID (General → About). Under Private keys, click Generate a private key: GitHub downloads a .pem file.
  7. Open Install App, install it on the account that owns the configuration repository, choose Only select repositories and pick the configuration repository.
Secret Value
CICORD_GITHUB_APP_ID The App ID (the client ID works too).
CICORD_GITHUB_APP_PRIVATE_KEY The content of the .pem file (PKCS#1 or PKCS#8). A single line with literal \n is accepted; or use --github-app-key-file.
CICORD_GITHUB_APP_INSTALLATION_ID Optional on github.com (discovered from the repository): the number at the end of the installation’s settings URL.

Set them as environment variables, or store them encrypted:

Terminal window
cicord secret set CICORD_GITHUB_APP_ID --data-dir /data # type the App ID, then Enter
cicord secret set CICORD_GITHUB_APP_PRIVATE_KEY --data-dir /data < acme-cicord.private-key.pem

In the setup wizard, the Repository step offers GitHub App next to the token: it checks the App by getting a token and reading the repository, then stores these secrets. A partial configuration (an App ID without a key, or the reverse) stops cicord serve with an error naming what is missing. The startup log says which method is used, never the secret. GitHub Enterprise Server is not supported yet.

With provider: github and credentials, every commit the runtime evaluates gets a commit status with the context cicord/sync:

  • pending while the revision is validated and applied;
  • success once it is applied to every server;
  • failure when it is rejected (validation or plugin build) or a server failed; the description gives the first reason.

The status links to <admin-url>/admin/ when --admin-url is set, otherwise to <public-url>/admin/, unless that URL is a loopback address. When the credentials lack the Commit statuses permission, the runtime logs a warning (GitHub commit status not set, once; then at debug level) and the sync goes on. Statuses are set on the commits of the tracked branch, after the merge; to check a pull request before merging, run cicord plan in CI (Your first change).

The runtime polls its git source (every minute by default). For instant syncs, add a GitHub webhook:

Setting Value
Payload URL <public-url>/hooks/github
Content type application/json
Secret the value of CICORD_WEBHOOK_SECRET (signatures are verified with HMAC-SHA256)
Events push

Pushes to the tracked branch trigger a sync; polling still runs as a fallback. Without a webhook, cicord sync (with CICORD_RUNTIME_TOKEN) asks the runtime to fetch now.