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
Section titled “cicord serve”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 containcicord.yaml. Itsspec.sourcesays what to follow:provider: githuborgit, withrepo,branch(defaultmain),pathandpollInterval(default1m): the runtime clones and polls the repository.dironly needscicord.yaml.provider: embedded: on first start, the contents ofdirare imported into a bare repository in the data directory (repo.git), which is then the source of truth.- no
spec.source, or--local:diris watched as is (no git). Admin console edits are written to the files, sodirmust be writable.
--listendefaults to:7420.--public-url(envCICORD_PUBLIC_URL) is the URL browsers use, for examplehttps://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 anhttps://value turns onSecurecookies. Without it, the runtime assumeshttp://<listen>, and browserPOST/PUTrequests from any other origin are rejected with403.--admin-url(envCICORD_ADMIN_URL): the URL of the admin console when it lives on a separate, private hostname, for examplehttps://cicord.example.ts.neton a Tailscale tailnet, while the portal stays public on--public-url. It must behttps://host[:port]without a path (httponly 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 answer404on every other hostname. See Admin on a private network, portal public.--cors-origin(repeatable; envCICORD_CORS_ORIGINS, comma-separated): origins of external portals allowed to call the API with credentials (cookie sessions).--data-dirdefaults to.cicord-data, relative to the working directory. With a local source inside the repository, it must be under<repo>/.cicord/.--database-url(envCICORD_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),warnorerror.--github-app-key-file(envCICORD_GITHUB_APP_PRIVATE_KEY_FILE): the GitHub App private key as a file (a Docker or Kubernetes secret mounted as a file), instead of theCICORD_GITHUB_APP_PRIVATE_KEYsecret. 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.
Environment variables
Section titled “Environment variables”| 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.
Data directory
Section titled “Data directory”| 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.
State store: SQLite or PostgreSQL
Section titled “State store: SQLite or PostgreSQL”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.dbin the data directory. Nothing to install or operate. - PostgreSQL (14 or later): set
--database-urlorCICORD_DATABASE_URL, for examplepostgres://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(unlessCICORD_SECRET_KEYis set),link.key(unlessCICORD_LINK_SECRETis set),repo.gitfor 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. SettingCICORD_SECRET_KEYremoves 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(useverify-fullacross a network),pool_max_conns,search_path=<schema>for a dedicated schema (create it first),default_query_exec_mode=execbehind PgBouncer in transaction mode. The password can come fromPGPASSWORDor~/.pgpassinstead of the URL. The startup log showspostgres://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:
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: 5svolumes: cicord-data: cicord-pg:Docker
Section titled “Docker”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:
docker pull ghcr.io/cicord/cicord:0.1.0 && docker tag ghcr.io/cicord/cicord:0.1.0 cicord# ordocker 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:
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.orgArguments 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.
services: cicord: image: ghcr.io/cicord/cicord:0.1.0 # or build: . restart: unless-stopped command: [ "serve", "/repo", "--data-dir", "/data", "--listen", ":7420", "--public-url", "https://cicord.example.org", ] ports: ["127.0.0.1:7420:7420"] env_file: cicord.env # DISCORD_TOKEN_*, CICORD_* (keep it out of git) volumes: - cicord-data:/data - ./cicord.yaml:/repo/cicord.yaml:rovolumes: cicord-data:-
A named volume inherits the ownership of
/datafrom the image (65532). For a bind mount,chown 65532:65532the host directory first. -
For a local source (no
spec.source), mount the whole repository at/repo, writable if admin console edits should be saved (:romakes write-back fail). -
Health:
GET /healthz(process up) andGET /readyz(a revision is active;503before). The image has no shell or curl;cicord healthcheckcheckshttp://127.0.0.1:7420/healthzfrom inside the container (exit 0 on200), for a DockerHEALTHCHECKor a Composehealthcheck:healthcheck:test: ["CMD", "/usr/local/bin/cicord", "healthcheck"]interval: 30stimeout: 5s -
Stop with
SIGTERM(docker stop): the HTTP server and the bots shut down gracefully (about 25 seconds).
Reverse proxy and TLS
Section titled “Reverse proxy and TLS”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-urlmust be exactly the scheme, host and port browsers see. The CSRF check compares the browser’sOriginwith it, so the proxy must passOriginthrough unchanged. Without--admin-url,Hostis not used bycicord serve; with it,Hosttells the admin hostname from the others, so every proxy must pass the originalHost(Caddy does by default, nginx withproxy_set_header Host $host).- Request bodies: JSON up to 1 MiB,
POST /api/v1/planup 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.
cicord.example.org { reverse_proxy 127.0.0.1:7420}server { listen 443 ssl; server_name cicord.example.org; # ssl_certificate ...; client_max_body_size 32m; location / { proxy_pass http://127.0.0.1:7420; proxy_set_header Host $host; proxy_read_timeout 90s; }}GitHub access: token or GitHub App
Section titled “GitHub access: token or GitHub App”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 overCICORD_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.
Create the GitHub App
Section titled “Create the GitHub App”- On GitHub, open Settings → Developer settings → GitHub Apps → New GitHub App (for an organization: the organization’s Settings → Developer settings → GitHub Apps).
- Enter a name (it becomes the commit author, for example
acme-cicord[bot]) and a homepage URL (your public URL). - Webhook is optional. Uncheck Active to rely on polling, or set the webhook URL to
<public-url>/hooks/github, its secret toCICORD_WEBHOOK_SECRET, and subscribe to the Push event (other events are acknowledged and ignored). See Webhooks. - Set the repository permissions of the table above.
- Under Where can this GitHub App be installed?, choose Only on this account, then create the App.
- Note the App ID (General → About). Under Private keys, click Generate a private
key: GitHub downloads a
.pemfile. - Open Install App, install it on the account that owns the configuration repository, choose Only select repositories and pick the configuration repository.
Give the runtime the App
Section titled “Give the runtime the App”| 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:
cicord secret set CICORD_GITHUB_APP_ID --data-dir /data # type the App ID, then Entercicord secret set CICORD_GITHUB_APP_PRIVATE_KEY --data-dir /data < acme-cicord.private-key.pemIn 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.
Commit statuses
Section titled “Commit statuses”With provider: github and credentials, every commit the runtime evaluates gets a commit
status with the context cicord/sync:
pendingwhile the revision is validated and applied;successonce it is applied to every server;failurewhen 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).
Webhooks
Section titled “Webhooks”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.
- Go through the security checklist.
- Set up backups.
- Wire your repository’s CI: Your first change.