Skip to content

Deploying Academy

How an installation is laid out, and how it gets new versions. Setting a server up for the first time is installing the portal with ./install.sh; this page starts once that has run.

  • Each repository installs and updates from its own checkout (ADR 0444). It builds there and delivers only the runtime to APP_DIR. There is no signed release and no registry for the code.
  • Nothing deploys from CI. No CI job and no CI key reaches a server; an administrator runs every update by hand.
  • The database server is a provision (PostgreSQL 17 with pgvector, Redis over TLS): nothing of the portal’s is installed there. Each repository sets up its own part over the network with the admin access (deploy/db/setup.sh), kept nowhere.
  • Lab nodes run learners’ code on machines of their own, in the private network (lab nodes).

Point these names at the portal server’s public address (examples for the base academy.example.com; here the server is 203.0.113.10):

portal.academy.example.com A 203.0.113.10 # the web app
api.academy.example.com A 203.0.113.10 # the API
admin.academy.example.com A 203.0.113.10 # the admin console
content.academy.example.com A 203.0.113.10 # SCORM, cmi5, xAPI and H5P packages
docs.academy.example.com A 203.0.113.10 # the handbooks
git.academy.example.com A 203.0.113.10 # the Git area
rtc.academy.example.com A 203.0.113.10 # media server for live sessions
relay.academy.example.com A 203.0.113.10 # live relay (live conversations, real-time recognition)
*.preview.academy.example.com A 203.0.113.10 # lab previews

and the marketing site’s own names. Add AAAA records if the server has IPv6. Open ports 80 and 443; the API (4000) and the web app (3001) listen on 127.0.0.1 only. For live sessions, also open the media ports listed under Live sessions. The database server and the lab nodes need no public names.

After ./install.sh, natively:

What Where
The checkout the portal is built in e.g. /srv/i3-academy-portal (root’s; every update runs from it)
The runtime in use APP_DIR/current (/opt/academy/portal/current), a link to releases/<commit>; the two releases before it stay
The API’s settings, with its own secrets /etc/i3-academy-api.env (every setting with its default: configuration)
The keys shared with the console /etc/academy/keys/console-kms-key.env, /etc/academy/keys/mail-settings-key.env (the console makes them; the API’s unit reads them after its settings, ADR 0481)
The installers’ answers /etc/academy/answers.env (no secrets; the defaults of the next run of any installer here)
The database part’s settings CONFIG_DIR (/etc/academy/portal): db-roles.env (the roles’ passwords), database.env (the services’ addresses), root only
The dumps before a migration BACKUP_DIR (/var/backups/academy/portal), the last five
The services i3-academy-api.service (port 4000, user academy-api), academy-portal.service (port 3001, user academy-portal), and the modules’ units
What deploy/update.sh needs to know /etc/academy-portal-deploy.env
Files (uploads, videos, generated media) STORAGE_DIR (backups says what to keep)

The database role academy_portal owns the core schema and bypasses row-level security, but is no superuser (ADR 0263); tenant requests run as academy_app, which deploy/db/database-role.sql creates.

Back up KMS_MASTER_KEY from the settings file and /etc/academy/keys/. Encrypted data (AI conversations, mentoring notes, sealed credentials, the mail settings) can’t be read without them.

Production refuses to start without JWT_SECRET, KMS_MASTER_KEY, CONSOLE_KMS_KEY and AUTH_MODE=standard. The installer sets the first two from its answers; CONSOLE_KMS_KEY and MAIL_SETTINGS_KEY come from the console’s key files only. One source per key: a copy in the portal’s settings can drift from the console’s file or get lost, and without MAIL_SETTINGS_KEY no mail goes out, so the portal keeps none. Email is set in the admin console under Mail and read live (ADR 0452, ADR 0455). Without a way set there the API starts and logs that sign-in links can’t go out.

An update runs from the checkout, by hand, as root. You pull; deploy/update.sh never does:

Terminal window
sudo git -C /srv/i3-academy-portal pull --ff-only && sudo /srv/i3-academy-portal/deploy/update.sh
sudo /srv/i3-academy-portal/deploy/update.sh <commit> # an older commit of origin/main
sudo /srv/i3-academy-portal/deploy/update.sh rollback # back to the release before

deploy/update.sh (with deploy/app-update.sh) goes in this order, and goes back by itself when the new version doesn’t hold:

  1. The code. It deploys the checkout’s HEAD, or the commit given, and says so first (Deploying <short sha> <subject>). It refuses local changes to tracked files. It never pulls and never fetches, so it never asks for Git credentials: it compares with origin/main as your git pull left it in the checkout (a checkout without origin/main is deployed as it is; a git bundle on stdin counts as origin: deploy/update.sh "deploy <commit> bundle"). Behind that origin/main (a git fetch without the merge) it stops (this checkout is N commits behind origin/main: git pull first), and so with commits that aren’t on origin/main (HEAD isn't on origin/main). A commit given must be on origin/main; it is built where it is, and the checkout is back on its branch afterwards, also when the update stops. The branch never moves. If that commit runs and is healthy, it only sets up the services beside it again.
  2. The shared keys (deploy/keys.sh, ADR 0481). CONSOLE_KMS_KEY and MAIL_SETTINGS_KEY are the console’s files in /etc/academy/keys/. An installation from before has copies in the API’s settings (or an older console in its admin.env): they are taken over once into the files. A copy that differs from its file stops the update (one of them opens what is sealed, the other doesn’t; it never guesses), and so do missing keys (“update the admin console first”). The portal never makes a key: one of its own would leave everything the console sealed unreadable. Then the API’s unit gets one EnvironmentFile= line per key file (an older unit is patched, systemd reloaded), the copies go from the API’s settings, and every node the update starts (the migrations, the console’s rekey, the dumps’ seal, the lab’s registration) gets the key files with --env-file too.
  3. The maintenance gate. Once the console switched it on, a portal update runs only while a maintenance window is locked (below).
  4. The build in the checkout: pnpm install --frozen-lockfile, pnpm build. What runs keeps serving meanwhile; a failed build changes nothing.
  5. Delivery (scripts/deliver.mjs) into APP_DIR/releases/<commit>: the built workspace without the checkout’s node_modules, Git, .env files (.env.example stays), caches, tests and the sources the bundles already hold. There pnpm install --prod --frozen-lockfile, a load check of every production dependency of the API, the web app, the connector host and the relay (scripts/release/load-check.mjs), and .release/manifest.json (the commit, when it was built, Node and pnpm).
  6. Backup. With pending migrations, pg_dump -Fc of every schema the database has (public, platform, admin, site) over the network, each as the role that owns it: public as academy_portal, platform and admin as the console’s role (its settings: BACKUP_ADMIN_ENV, else /etc/academy/admin/admin.env), site as the website’s role (BACKUP_SITE_ENV, else /etc/academy/site/site.env), into BACKUP_DIR (<time>-<commit>.dump for public, <time>-<commit>.<schema>.dump for the others; each sealed, the last five sets stay). A failed backup, or a schema whose owner’s settings are not on this server, stops the update before anything changes; BACKUP_SKIP_SCHEMAS="site" goes on without a schema (never public) and says so.
  7. Migrations from the new release (migrate-cli; afterwards it moves the console’s secrets to CONSOLE_KMS_KEY, ADR 0442), then deploy/db/grants.sql as the portal’s own role: the relay’s and the monitor’s rights on what the migrations made.
  8. Switch the link current, restart the services, check their health addresses. Then the history keeps the commit and releases older than the two before go.
  9. The services beside the portal (deploy/update.sh companions APP_DIR/current, below).

On a failure in 7 or 8 the dump of public goes back into the schema (pg_restore --clean --single-transaction; the portal’s migrations change only public, so the other schemas stay as they are and their dumps wait beside it), current points at the release before and the services restart on it; with nothing before, they stop. rollback switches to the release before from the history and restarts; when the release in use moved the console’s secrets and the one before can’t read them, it moves them back first (console-keys-cli back). It names the newest dump: a rollback across a migration that changed data needs that dump put back by hand, during a locked window.

Which release runs, and how the units stop. The API’s /readyz names the running release: "release": { "commit", "builtAt", "ciRun" } from the release’s .release/manifest.json, read once at start (ciRun is null: the server built it). Only this machine and the admin console may ask it: nginx answers /readyz to loopback and to ADMIN_ADDRS and THIS_ADDR of /etc/academy/roles.env and refuses everyone else (deploy/update.sh, readyz_access); /healthz stays open. On the console’s own machine its FLEET_EXPORTER_READY_URL is http://127.0.0.1:4000/readyz. On a stop (KillSignal=SIGTERM) the API takes no new requests, lets running ones finish for up to 15 seconds, closes Redis and the database, and ends itself within 25 seconds (apps/api/src/ops/shutdown.ts). The web app’s next start closes the same way. Both units wait TimeoutStopSec=30 before systemd sends SIGKILL.

Several portal servers. Update the first one; its migrations run there. Each further one runs the same command; its migrations are already applied. A portal server without the console has root-only copies of the console server’s /etc/academy/keys/. A lab node updates from its own checkout (the repository i3-academy-lab-node) with git pull --ff-only and sudo ./install.sh again.

The console and the website update the same way from their own checkouts (sudo git -C <checkout> pull --ff-only && sudo <checkout>/deploy/update.sh, the same rules about git in all three). The console comes first: it installed first and owns the schemas admin and platform, and the portal reads what it configures. A console update that moves tables (sudo ./install.sh --db-setup) runs after the portal that can read them in both places (the order).

Beside the apps, every update sets up what they need on the server: nginx and certificates, the media server, the document reader, the malware scanner, the lab, the docs site, maintenance pages, the relay, the fleet agent and more (release_companions in deploy/update.sh).

  • It runs from APP_DIR/current as it is: root’s, read-only, without Git. It builds, installs and migrates nothing. sudo deploy/update.sh companions /opt/academy/portal/current runs it again by hand.
  • Node.js first (release_node):
    • Where install.sh laid Node out from nodejs.org (/etc/academy/node-from-nodejs), the update brings it to exactly the version of the commit’s deploy/node-release.env. Only an archive with the pinned SHA-256 is installed; scripts/pin-node.sh checked the release keys’ signature when it set the pin.
    • Node as it was is kept first (/var/lib/academy/node-previous/). Then the services are restarted on the new one and checked (API /readyz and the web app, 60 s).
    • If they don’t come up, the Node before goes back and they are restarted on it. The update then ends failed and says so; the release keeps running.
  • The Git area’s image and, where this server runs code itself, the lab’s images are built here from the runtime’s infra/ folder (below).
  • A database on another machine is left to deploy/db/setup.sh and deploy/db/grants.sql.
  • A companion that fails is reported, but the release stays.

The commands an administrator runs in the runtime’s folder (/opt/academy/portal/current), as root, without Git and without pnpm:

Command What it does
deploy/update.sh "maintenance-backup <window id>" the backup during a locked maintenance window (below); it runs the console’s academy-maintenance backup (ADR 0458)
deploy/update.sh "maintenance-restore <backup id>" puts that backup back during the same lock (the console’s academy-maintenance restore)
deploy/update.sh restore-check hands over to the console’s academy-restore-check: the newest backup of the backup service brought back beside the running Academy and compared (ADR 0380); the monthly timer runs the same command
deploy/update.sh preview-certificate the lab preview’s wildcard certificate with a TXT record (ADR 0186)
deploy/update.sh "verify-compliance <commit>" reads the running API’s compliance status back (ADR 0374)

The recipes are in infra/lab-images/ (one folder per language, and the relay) and infra/git/. Every FROM names its base by digest. A pull request that changes a recipe runs the workflow Lab recipes (infra/ci/lab-recipes.sh): the build goes through and a lab image has what the lab’s wrapper needs. Nothing is pushed anywhere. The update reads the recipes into the console’s tables as templates; a key’s first image comes from its template, later ones are the operator’s (Admin console → Lab → Images). Lab nodes build the images assigned to them themselves (Code lab below, ADR 0493); a server that runs code itself, and the Git area, build theirs on the deploy. To raise a base: its new digest in the FROM line (node scripts/check-pins.mjs shows which have moved); the console then offers the newer template as a new version.

academy-network (the admin console’s: its installer and its update put it in /usr/local/sbin/; this repository’s deploy/academy-network, byte for byte the console’s, is for the servers without the console, lab nodes, media and TURN servers, whose installer puts it there; ADR 0007 of the console) reads /etc/academy/roles.env, which the installer writes with the private addresses (THIS_ADDR, PORTAL_ADDRS, DB_ADDRS, LAB_ADDRS, ADMIN_SSH_FROM, SSH_PORT). Everything coming in is dropped except:

  • SSH (from ADMIN_SSH_FROM);
  • a portal server’s public ports;
  • LiveKit’s media ports, to everyone, on a machine with the role rtc: a media server of its own, or the portal’s server once LiveKit runs there. These are TCP 7881 and UDP 3478, 50000–60000 and 30000–40000 (ADR 0480).
  • A TURN server’s ports, to everyone, with the role turn: TCP 80, 3478 and 5349, and UDP 3478 and 49152–65535 (ADR 0484).
  • The host probe’s 9100, from the console’s servers only;
  • lab nodes (ADR 0213, LAB_NODES in roles.env):
    • internal (the default: the nodes sit in the private network): on a portal server the lab door (LAB_DOOR_PORT, 4443, TLS) from LAB_ADDRS only; on a lab node its dispatch port 7071 from PORTAL_ADDRS only;
    • wireguard (nodes over the internet): on a portal server the tunnel’s hub (UDP 51820), on a lab node its dispatch port inside the tunnel only.

The database server’s firewall is the provision’s: PostgreSQL (5432) and Redis with TLS (6380) from the portal, console and website servers only, never from a lab node. The traffic to the database is encrypted by the services themselves (PostgreSQL and Redis with TLS; no WireGuard).

Terminal window
sudo academy-network check # the rules, checked by nft; nothing changes
sudo academy-network apply # loaded; gone again by themselves after 3 minutes …
sudo academy-network confirm # … unless confirmed from a new SSH session: then they stay

A pull request that changes only the web app (apps/web/), the docs site (apps/docs/), the docs (docs/), the deploy scripts (deploy/, install.sh, install.env.example) or the README-type files skips the API’s test suite, the learning standards checks, the lab sandbox test and the failover drill (ADR 0323). It still runs the typecheck, the dependency checks, the build, the portal smoke test, every other package’s tests and the API tests that read those files (REPO_FILE_TESTS in scripts/ci-changes.mjs). Any other change, every push to main and every manual run test everything. The step Decide what this run tests says in its log which way a run went and which file decided it; node scripts/ci-changes.mjs main shows the same for a local branch.

The installation itself is tested end to end only by hand (Installer e2e, .gitea/workflows/installer-e2e.yml, started on main).

An API test or source file that reads a file outside apps/api must be named in scripts/ci-changes.mjs; apps/api/test/ci-changes.test.ts fails otherwise.

The API suite runs in 4 workers, each with a copy of the test database and a Redis database of its own (ADR 0360); the repository variable API_TEST_WORKERS changes the number. To look for a test that passes only after another one, start the workflow by hand with a number as shuffle: the files then run in a mixed order, the same for the same number.

Main’s runs also record which API test file runs which source file (the test impact map, ADR 0361). A pull request reads the newest map, and Choose the API test files prints which files its changes need (ADR 0391):

  • “some” or none: the Test step runs only those API test files, and the other packages’ tests only for the changed packages and their dependents (pnpm -r --filter "...[origin/main]") when every change lies in a package or in docs/. The learning standards checks run only when the choice holds test/learning-tools.test.ts or test/learning-packages.test.ts, the lab sandbox test only with test/labs.test.ts, ffmpeg is installed only when a chosen file reaches it.
  • “all”: a change in the toolchain, the test setup or the CI, a migration that changes what is there, a start function of app.ts, config.ts, services.ts or src/db/ (or one that registers no routes), more than 60 % of the files, or no map younger than 3 days: the whole suite runs, as before. Check the API test choice against the whole suite then warns for a failed file the choice would have left out, and notes the failed files the rules without their fallback would have missed.
  • On every pull request the failover drill runs only when apps/api/src/db/ changed, pnpm audit and the NVD check only when the dependencies changed. The typecheck, the build and the portal smoke test always run (together about a minute).

Main’s runs and manual runs always run everything, whatever a pull request skipped. node scripts/test-impact.mjs select --map <map.json> --base main shows the choice for a local branch.

Planned work that interrupts the portal runs in a maintenance window (ADR 0284): the platform team plans and announces it in the admin console (Operations → Maintenance), everyone with an account gets a mail, and at its start the portal locks itself: nobody signs in, everyone is signed out, the background work rests and nothing writes. The console stays open. The lock ends only when a platform administrator ends it.

The steps during a window (wait until the portal is quiet, take the maintenance backup with sudo academy-maintenance backup <window id>, update, test with named test accounts, end the lock or restore with sudo academy-maintenance restore <backup id>) are the platform team’s: the admin console’s handbook, Runbooks → Backups and restore and Operations → Maintenance. deploy/update.sh "maintenance-backup <id>" and "maintenance-restore <id>" hand over to the console’s command (ADR 0458, the console’s ADR 0005). After a long or busy lock, check in Mangopay’s dashboard that its hooks are still valid; the other providers send their webhooks again by themselves (ADR 0284, “Payment providers during a lock”).

Updates only in a window. Once the platform team switches it on (Operations → Maintenance → “Portal deploys only in a maintenance window”, for platform administrators), a portal update runs only while a window is locked. Otherwise the server keeps the running version, notes the commit as waiting (the console lists it) and the update ends without a change. During the next lock, update to the newest commit. A commit whose subject begins with Hotfix: may go at once. The console and the website update as before: their restarts are short, and nginx shows its maintenance page meanwhile.

When something is down (ADR 0355). nginx shows a static maintenance page on every host (portal, API, content, docs, the admin console and the website) whenever it gets no answer: the app isn’t running, it restarts, it crashes or times out. Browsers get the page (in English, German, French, Spanish, Italian or Estonian, from the browser’s language or the switch at the top), every other caller a JSON 503 unavailable. The page needs nothing else on the server. While a window is locked it says it is the planned maintenance, with its planned end and its public note: academy-maintenance-state.timer (the admin console’s, its ADR 0007) writes them from the database every 30 seconds to /var/www/academy-maintenance/academy-maintenance.json (journalctl -u academy-maintenance-state if the page doesn’t show them). Each repository’s update installs its own copy of the page and the snippet (/etc/nginx/academy-maintenance/) with nginx -t, and puts the files back if nginx refuses. Not covered: the whole server or nginx down; that needs a second server (see the ADR).

The website’s schema site is not part of the backup: it keeps running during a lock. If the console or the website was updated during the window and must go back too, roll them back from their checkouts (sudo deploy/update.sh rollback).

Moving the data of an old installation (academy-move)

Section titled “Moving the data of an old installation (academy-move)”

academy-move (ADR 0443) is the admin console’s (the console’s ADR 0007): deploy/academy-move in the console’s checkout, installed as /usr/local/sbin/academy-move by its update. The steps, the order of the updates afterwards and the way back are in the console’s docs/install.md, “Moving the data of an old installation”. This repository keeps no copy; infra/ci/installer-move-e2e.sh runs the console’s file.

ADR 0501. The new names go into the settings as usual (PUBLIC_WEB_URL, PUBLIC_API_URL, CORS_ORIGINS, PASSKEY_ORIGINS, ACADEMY_DOMAIN); the deploy then sets up their sites and certificates. The old names keep answering, for good, because certificates, emails, QR codes and Content Credentials carry the old links:

Where Setting What it does
/etc/academy-portal-deploy.env ACADEMY_LEGACY_HOSTS="api.old.example.org=api.academy.example.com portal.old.example.org=portal.academy.example.com …" One pair per old name. The API’s old name serves the API as before (its own site under that name, deploy/nginx-api.conf), so company sign-ins, LTI, webhooks, SCIM, access tokens and the learning app need no redirect. Every other old name sends each request to its new name with the same path and query (301, deploy/nginx-legacy.conf). certbot gets each old name its certificate; a name without a DNS entry is set up on a later deploy; a name nginx serves already is left alone.
API settings LEGACY_API_URL=https://api.old.example.org, HOSTS_MOVED_AT=<day of the move> Company sign-ins made before the move keep sending the old redirect URI (or SAML entity ID and reply URL) until an administrator confirms the new one with Test with the new address, at most three months; the learning app’s DPoP proofs and Teams tokens for the old address still count.
API settings PASSKEY_RP_ID=<new web host>, PASSKEY_LEGACY_RP_ID=<the old PASSKEY_RP_ID, else the old web host> New passkeys are made for the new host. Passkeys made before keep working in browsers that support WebAuthn related origins: the old relying party’s host answers /.well-known/webauthn (from the web app, listing PASSKEY_ORIGINS); its pair must be in ACADEMY_LEGACY_HOSTS on this server. People whose passkeys are all old and who have no authenticator app see a notice to add one.

Lab previews (*.preview.) get no redirect: their addresses last only as long as a session. Outside the server: DNS and CAA for both names, the providers’ redirect and webhook addresses (Stripe, the platform’s own Microsoft, Google, Slack and Teams apps), and a notice to the organisations: their administrators see the new sign-in address in Admin → Sign-in, LMS administrators add the new LTI addresses, and organisations with the Teams app upload the new app package.

Sign in with Google, Microsoft, GitHub (optional)

Section titled “Sign in with Google, Microsoft, GitHub (optional)”

The platform’s apps at Google, Microsoft and GitHub are set in the admin console (Settings → Sign-up and sign-in → Sign-in apps: the client id, the secret, sealed, and Microsoft’s directory), which shows the redirect URL to register at each provider, <PUBLIC_API_URL>/v1/auth/oauth/<google|microsoft|github>/callback. The switches on the same page decide whether the buttons show. The portal reads the apps every minute; OAUTH_* in its settings are no longer read, except OAUTH_ENDPOINTS for sovereign clouds and test doubles.

Provider Where to make the app
Google Google Cloud console → APIs & Services → Credentials → OAuth client (Web)
Microsoft Entra admin center → App registrations → New (Web platform)
GitHub Settings → Developer settings → OAuth Apps

Academy sends invitations, sign-in links and password resets. The portal, the website and the admin console each send by themselves, the way Admin console → Mail → Sending sets it (ADR 0455): one SMTP server (host, port, TLS from the start or STARTTLS, user, password) or Microsoft 365. Nothing goes into api.env but MAIL_SETTINGS_KEY, which the deploy takes over from the console’s settings; SMTP_URL and M365_* are no longer read. TLS is required; only a relay on the same machine or in the private network (given by its address) may be reached without it. Admin console → Mail → Applications shows when each application last sent, or why it failed.

With Microsoft 365, the applications send as an app through Microsoft Graph, so no SMTP and no user password are involved. Enter the values below under Admin console → Mail → Sending → Microsoft 365 (the secret is sealed there).

  1. Mailbox. Pick the sender, e.g. no-reply@example.org. A shared mailbox is fine and needs no licence.
  2. App registration. Go to Entra admin center → Identity → Applications → App registrations → New registration. Use the name “Academy mail”, single tenant, no redirect URI. Note down the Application (client) ID and the Directory (tenant) ID.
  3. Permission. Under API permissions → Add a permission → Microsoft Graph → Application permissions, add Mail.Send. Then click Grant admin consent.
  4. Secret. Under Certificates & secrets → New client secret, copy the Value, not the secret ID. Note its expiry date and renew it before then.
  5. Recommended: limit the app to the sender mailbox. Mail.Send alone allows sending as any mailbox in the organisation. In Exchange Online PowerShell, scope it to the sender:
    Terminal window
    New-ApplicationAccessPolicy -AppId <client id> -PolicyScopeGroupId no-reply@example.org `
    -AccessRight RestrictAccess -Description "Academy may only send as no-reply"
    Newer tenants can use RBAC for Applications instead (New-ManagementScope / New-ManagementRoleAssignment -Role "Application Mail.Send").
  6. In the console. Choose Microsoft 365, fill in the tenant ID, the app’s ID, the mailbox and the secret, and Save. The applications take it within 30 seconds.

Test it: Send a test to me on the same page. If sending fails, the page (and Applications) names the cause:

  • AADSTS… on sign-in: wrong tenant ID, client ID or secret;
  • ErrorAccessDenied: permission or admin consent missing, or the access policy excludes the mailbox.

The portal runs no mail server (ADR 0460). Answers to tickets by email are received by the admin console: under Admin console → Mail → Answers it reads an IMAP or Microsoft 365 mailbox, or a Maildir that a mail server on the console’s own machine delivers into, and writes each answer into its ticket. The reply addresses are plus addresses of the address set there (support+<token>@…). The console’s docs/answers-by-email.md has the steps.

A Postfix that an earlier deploy installed on this server is left as it is; it is no longer the platform’s. The deploy stops its old job academy-mail-relay.timer and says so once. Stop or remove Postfix yourself (sudo systemctl disable --now postfix), or keep it as the console’s local mail server.

The server’s configuration holds no AI key (ADR 0018). Each organisation connects its own language model under Admin → Integrations → Language model; its AI features (practice questions, answer drafts after live sessions, video scripts, the analysis of knowledge sources and course drafts) use it. Until an organisation connects one, these are off: the web app hides or disables them, the API answers 409 ai_not_connected, and knowledge documents wait for their analysis.

The one exception is the AI learning companion (“Ask AI”), which serves learners across organisations and runs on the platform’s own model. Platform administrators set it in the web app under Admin console → AI learning companion (vendor, key, model, an own server’s address, on/off; stored in the database with the key sealed under the platform key, so nothing is needed at start). Until it is set and switched on, nobody sees the companion and the API answers 409 platform_ai_off; organisations still decide whether their students and mentees may use it, and its use counts towards each organisation’s AI budget.

Vendor Key Default model Citations
Anthropic required claude-opus-5-5 built in
OpenAI required gpt-5 numbered passages
Mistral AI required mistral-large-latest numbered passages
Google Gemini required gemini-2.5-pro numbered passages
Own OpenAI-compatible server (Azure OpenAI, vLLM, Ollama, a gateway) if the server needs one named by the admin numbered passages

The key and model are checked with one tiny request before they are stored (encrypted under the organisation’s key, or sealed under the platform key for the companion). An own server must be public https, like the speech and embeddings servers. Model names change over time; admins pick another in the same card.

AI_PROVIDER, AI_MODEL and the providers’ keys (ANTHROPIC_API_KEY, OPENAI_API_KEY, OPENAI_BASE_URL, GEMINI_API_KEY, MISTRAL_API_KEY) are a development fallback only: locally and in tests, organisations without a model of their own use it (the deterministic fake provider when nothing is set). In production they are ignored, and the API logs a warning at start when one is still set; remove them from /etc/academy/api.env.

The organisations’ default budget (tokens a day) and requests per person and minute are set in the admin console (Settings → Defaults; one organisation’s own under Organisations); AI_EFFORT (thinking effort for Claude) stays on the server. Existing conversations continue after an organisation switches its model.

Cost estimates under Insights are in euros and know the prices of Claude and Mistral’s -latest models. For other models, or when prices change, add AI_PRICES={"<model>":{"input":<EUR per 1M>,"output":<EUR per 1M>}}.

Public catalog and selling courses (Stripe)

Section titled “Public catalog and selling courses (Stripe)”

Courses can be offered to the public: the main page shows one organisation’s catalog, and every organisation has its own at https://academy.example.org/o/<slug>. Visitors register (free courses) or pay with Stripe (paid courses), and get the course right away.

Main page: visitors land on the platform’s start page: the public courses of all organisations on this server that published their page (Admin → Organisation → Publish the page), and a searchable directory of these providers. To show one organisation’s catalog there instead, choose it in the admin console (Settings → Defaults → Public catalogue); its page must be published. With no published organisation, the main page sends visitors to sign-in.

Which courses: on a course’s page under Teach, an administrator turns on Show in the public course catalog and sets a price, or leaves it free. Only published courses appear.

Stripe (needed only for paid courses). Each organisation connects its own Stripe account in the portal; nothing has to change on the server:

  1. In Academy, open Admin → Sales → Online payment (Stripe). It shows the webhook address for your organisation (https://api.academy.example.org/v1/payments/stripe/webhook/<organisation id>) and the events to select.
  2. In the Stripe dashboard:
    • Developers → API keys: copy the secret key (sk_live_…; sk_test_… for a trial run with test cards).
    • Developers → Webhooks → Add endpoint: paste the webhook address and select checkout.session.completed, checkout.session.async_payment_succeeded, checkout.session.async_payment_failed, checkout.session.expired and charge.refunded. Save it, then copy its signing secret (whsec_…).
  3. Back in Academy, paste both and choose Connect Stripe:
    • Academy checks the key with Stripe before saving it, and shows the account name and whether it’s in test or live mode.
    • The keys are stored encrypted with your organisation’s data key, and are never shown again.
  4. Optional, on the same card:
    • Add VAT with Stripe Tax: activate Stripe Tax and set your tax registrations first. Prices are then treated as including tax.
    • Email an invoice after each purchase.

The platform’s own account: Premium, organisation plans and the learning companion’s orders are paid into the platform’s Stripe account. A platform administrator or accounting connects it under Admin console → Finanzen → Stripe: the same steps as above, with the webhook address shown there (https://api.academy.example.org/v1/payments/stripe/webhook). The keys are checked with Stripe and stored in the database, sealed with the master key; nothing goes into /etc/academy/api.env. STRIPE_* settings there are no longer read; deploy/update.sh names them, to be removed.

Marketplace (off by default): under Admin console → Finanzen → Marktplatz a platform administrator can let organisations sell through the platform’s account instead of their own. It takes confirming a notice: the platform then becomes seller or intermediary, with the legal and tax duties that brings, and Academy doesn’t pass the money on to the organisations yet. The defaults say what organisations may use (their choice, the marketplace only, or their own account with the marketplace as an exception), and exceptions per organisation override them. Without the marketplace, an organisation without its own account can’t sell paid offers.

How it works:

  • Buyers pay on Stripe’s own checkout page, so card details never reach this server.
  • Access is granted when Stripe confirms the payment through the webhook. For bank payments, that can take a few days.
  • A full refund in the Stripe dashboard removes access again; a partial refund keeps it.
  • Unpaid checkouts expire after an hour.
  • Administrators see all orders under Admin → Sales.
  • A course with a price must be bought by everyone, members included, unless it is assigned to them (personally or through a class).

Test it: use sk_test_… keys and the card 4242 4242 4242 4242. The Stripe CLI can forward webhooks to a test server: stripe listen --forward-to localhost:4000/v1/payments/stripe/webhook/<organisation id>.

People who register from the catalog are customers:

  • They see only what they registered for, bought, or were assigned.
  • Courses open to “everyone in the organisation” stay internal to your members.
  • Under Admin → People they carry a Customer badge.

Audio, video and screen sharing in live sessions go through LiveKit, an open-source media server (SFU) that runs on this server next to the API. It stays here until it is moved on purpose (rtc-servers.md). Everyone sends their media once, to the server, which forwards it; it also enforces who may speak or present. Nothing goes to a third party, and the server doesn’t store audio or video.

Without it (LIVEKIT_URL unset), sessions fall back to a peer-to-peer mesh: fine for a handful of people, without screen sharing or enforced moderation. The mesh is relayed through a TURN server of the installation’s own only, so participants never see each other’s address and no outside STUN server is asked (ADR 0336): set TURN_URLS and TURN_SECRET for your coturn (use-auth-secret, static-auth-secret = TURN_SECRET; the API hands each person credentials for the session). Without LiveKit and without a TURN server, live rooms carry no audio or video (chat, questions, polls and boards still work), which is also what happens while a deploy has LIVEKIT_URL switched off. LiveKit hands its clients only its own TURN (which answers STUN too) as long as turn.udp_port stays set in livekit.yaml; without it LiveKit would fall back to public STUN servers.

  1. DNS: rtc.academy.example.org pointing at the server (see DNS).

  2. Firewall: open these ports (nginx serves the WebSocket on 443):

    Port Protocol What
    50000–60000 UDP audio and video
    7881 TCP audio and video when UDP is blocked
    3478 UDP TURN, for networks that block the UDP range
  3. The rest happens on the next deploy: when /etc/academy/livekit.yaml doesn’t exist and the API’s settings have no LIVEKIT_URL, deploy/update.sh makes a key and secret on the server, writes /etc/academy/livekit.yaml, adds the LIVEKIT_* settings to the API’s settings file (the old one stays as ….before-livekit), installs and starts LiveKit and serves the rtc site: with Caddy its block from deploy/Caddyfile, with nginx deploy/nginx-rtc.conf plus a certificate from certbot --nginx (either kept as before if the web server rejects it). As long as https://rtc.academy.example.org doesn’t answer, the deploy switches LIVEKIT_URL off (commented, marked # off:), so live sessions keep running peer to peer, and on again once it answers; then it restarts the apps. sudo /opt/academy/portal/current/deploy/update.sh companions /opt/academy/portal/current does this too, without a new release.

By hand instead:

  1. Key and secret:
    Terminal window
    echo "API$(openssl rand -hex 6)" # key
    openssl rand -base64 36 # secret
  2. Settings: copy the example and enter key and secret:
    Terminal window
    sudo cp deploy/livekit.yaml /etc/academy/livekit.yaml && sudo nano /etc/academy/livekit.yaml
    Put the same pair into the API’s settings (/etc/i3-academy-api.env) as LIVEKIT_API_KEY / LIVEKIT_API_SECRET, together with LIVEKIT_URL=wss://rtc.academy.example.com and LIVEKIT_API_URL=http://127.0.0.1:7880.
  3. Install and start:
    Terminal window
    sudo deploy/install-livekit.sh # downloads the pinned version, checks its SHA-256, starts livekit.service
    sudo systemctl restart i3-academy-api

Check: curl https://rtc.academy.example.org answers OK. journalctl -u livekit -f shows people joining and leaving rooms.

From then on, deploy/update.sh keeps LiveKit at the version in deploy/install-livekit.sh on every deploy. A LiveKit problem doesn’t undo an Academy deploy; it is reported in the deploy log.

With academy-network on this server (the database elsewhere), the deploy names the role rtc in /etc/academy/roles.env once LiveKit runs here, and says so: then sudo academy-network check, apply and confirm, so the media ports above open (ADR 0480). LiveKit on a server of its own, or a cluster: rtc-servers.md.

Locally: download livekit-server for your system from the releases, run livekit-server --dev --bind 127.0.0.1, and set LIVEKIT_URL=ws://127.0.0.1:7880, LIVEKIT_API_KEY=devkey, LIVEKIT_API_SECRET=secret in apps/api/.env.

Live relay (live conversations and real-time recognition)

Section titled “Live relay (live conversations and real-time recognition)”

Browsers never connect to an AI provider (ADR 0334): a live conversation and real-time recognition go through a relay node of the installation. deploy/update.sh sets one up on the main server (database role academy_relay, /etc/academy/relay.env, the unit academy-relay, the site relay.<base> with a certificate). Without it the conversation mode goes turn by turn. More nodes on more servers, and switching one off: relay-nodes.md.

Check: journalctl -u academy-relay shows “relay node listening”, and select name, public_url, last_seen_at from relay_nodes; a fresh beat.

Organisations connect their own data sources (file servers, SharePoint, S3, …) through connectors; the portal keeps only what it derives from them, never the originals (ADR 0016). A connector sends a document either as Markdown it read itself or, where the source allows it, as the file. Files are read by Docling (MIT), which runs on this server next to the API, on 127.0.0.1:5001 only. Files are posted to it and never stored.

Automatic: on every deploy, deploy/update.sh runs deploy/install-docling.sh. It installs deploy/docling-requirements.txt into its own Python environment (/opt/docling, a link to /opt/docling-<the lock's hash>, PyTorch for CPU). That lock holds every package at one version with its hashes, and pip takes only those files, only as wheels (--require-hashes --no-deps --only-binary :all:), so no build script runs. A new lock gets a new environment beside the old one, which goes once the new one runs. deploy/docling-requirements.in says how the lock is made. Then it puts the models into /var/lib/docling/models exactly as deploy/docling-models.lock names them (deploy/docling-models.py, on every run). Each Hugging Face repository comes from its pinned commit and every file is checked against its hash; RapidOCR’s models are copied out of the hash-locked rapidocr package. Any difference stops the installation, and a new environment whose models don’t match never goes into use. docling.service reads only that folder and runs offline (HF_HUB_OFFLINE=1). scripts/pin-docling-models.py writes a new models lock from the Hub’s metadata, without downloading a model; the first live installation confirms it. Then it makes an API key (/etc/docling.env, never leaves the server), starts docling.service and puts DOCLING_URL and DOCLING_API_KEY into the API’s settings, restarting the apps when they change. The first installation takes several minutes and needs about 4 GB of memory and 6 GB of disk; on a smaller server it is skipped and reported in the deploy log. A Docling problem doesn’t undo an Academy deploy; knowledge sources then take only Markdown.

Sandbox (ADR 0393): deploy/docling-sandbox.conf goes in as the drop-in /etc/systemd/system/docling.service.d/sandbox.conf: no network beyond the loopback (the models are loaded at install, Hugging Face runs offline), no devices, no kernel settings, no capabilities, the system calls of @system-service, at most 256 tasks and two cores. After every change the installer reads deploy/docling-selftest.pdf through Docling. When that fails under the sandbox, it takes the drop-in away, starts Docling without it and prints !! Docling could not read under its sandbox … in the deploy log; the next deploy tries again.

Files are checked before Docling sees them: their bytes must be what their name says (a PDF a PDF, an Office file a zip with Office’s parts, a picture a picture of that kind, a text without NUL bytes), an Office file must not unpack into more than allowed, a picture must not have more pixels than allowed. A refused file is deleted at once, its document is marked (file_type_mismatch, unpacked_too_large, image_too_large) and it doesn’t count as a file read. The limits are the platform’s setting knowledgeFiles (maxFileMb, maxUnpackedMb 500, maxEntries 10,000, maxImageMegapixels 40), read live; KNOWLEDGE_MAX_FILE_MB stays the ceiling no setting goes above.

Malware scan (ADR 0394): on every deploy deploy/install-clamav.sh installs ClamAV from EPEL (clamd@scan on the local socket /run/clamd.scan/clamd.sock) or, on Debian and Ubuntu, from the distribution (clamav-daemon on /run/clamav/clamd.ctl, whose systemd socket a drop-in narrows to mode 0660), only for the group virusgroup, which academy-api joins; freshclam keeps the signatures current) and runs clamd in its own sandbox (deploy/clamd-sandbox.conf: no network, 2 GB of memory). It checks that clamd finds the EICAR test string, as the API’s user; only then does it put CLAMD_SOCKET into the API’s settings. From then on every file is streamed to clamd before it is read: malware is deleted unread (malware_found, in the organisation’s log), a file past the scanner’s limits is skipped (unpacked_too_large), and while clamd doesn’t answer, files wait for the next sync (scanner_unavailable): none is read unscanned. The same scanner checks every other upload too (ADR 0407): pictures, documents, course files, ticket attachments, packages. Malware is refused (malware_found); while clamd doesn’t answer, uploads are refused (scan_unavailable); past 100 MB only recordings and films are taken, unscanned and logged. It needs about 1.5 GB of memory and is skipped on servers with less than 6 GB. #CLAMD_SOCKET= switches it off.

Without ClamAV no uploads: in production the API refuses every upload while CLAMD_SOCKET is not set (503 scanner_missing). install-clamav.sh skips ClamAV on a server with less than 6 GB of memory: give such an API server more memory, or point CLAMD_SOCKET at a clamd on another host (tcp://host:3310), before it takes uploads.

Active content and pictures: Office files with macros, ActiveX controls or embedded programs, and PDFs with scripts, launch actions, embedded files, rich media or XFA forms (also hidden in compressed object streams) are refused as active_content. Pictures are decoded and drawn anew as PNG before Docling sees them, so metadata and anything appended to them are dropped; BMP is no longer read.

Pictures as knowledge (ADR 0398): Docling hands the pictures of a document over (image_export_mode=embedded), and the organisation’s own model for knowledge work describes each different one (steps of a diagram, what a chart shows, the text in it; never who a person is). The description becomes a passage where the picture stood; the picture itself isn’t kept. At most knowledgeFiles.maxPictures (20) per document, on the organisation’s AI budget; icons and decoration are left out. Without a model that reads pictures, documents are read as before.

Recordings and films (ADR 0399): sound files (mp3, wav, m4a, ogg/opus, flac) and films (mp4, mov, webm, mkv) are checked like every file, then ffmpeg (guarded as in the media pipeline) takes their sound out and the organisation’s own speech recognition hears it, never the platform’s. The transcript, sectioned by time, becomes the passages; a film’s stills (one at least every 30 seconds, at most maxPictures) are described like pictures and placed at their time. At most knowledgeFiles.maxMediaMinutes (120). Nothing of the recording is kept. Without speech recognition of its own an organisation’s recordings are skipped as no_speech_recognition.

Instructions to an AI (ADR 0395): a document’s invisible characters (Unicode tag characters, bidirectional overrides, runs of zero-width characters) are dropped before it is stored. A document whose text seems to steer an AI, or hid such characters, waits in the review list as instructions_suspected until an administrator releases it. Models that read material never get tools, and the course factory fetches no address a model wrote unless the job already read it or the register holds it.

Switch it off: put the line #DOCLING_URL= into /etc/academy/api.env.

Search by meaning (pgvector): knowledge search combines full text with vectors when the database has pgvector (ADR 0017). When the database runs on this server, every deploy makes sure postgresql-<version>-pgvector (the cluster’s version) is installed and creates the extension as the postgres superuser before migrating; the vector tables are made then, or at the next API start. Without it (a managed database without pgvector, or KNOWLEDGE_VECTORS=off), search is full text only. By hand: sudo apt install postgresql-17-pgvector && sudo -u postgres psql -d academy -c 'create extension if not exists vector', then restart the API. When PostgreSQL runs in a Docker container on this server, use an image with pgvector of the same major version as the data volume (e.g. pgvector/pgvector:pg17 for a volume made by PostgreSQL 17); the deploy finds the container by the port in DATABASE_URL and creates the extension as its superuser (POSTGRES_USER). By hand: docker exec -i <container> psql -U postgres -d academy -c 'create extension if not exists vector'. Every deploy log says which applies, in a line starting with pgvector. Organisations choose their embeddings model under Manage → Integrations → Embeddings.

Connector host: connectors organisations let the portal run (SharePoint/OneDrive, S3) run in academy-connectors.service (apps/connector-host). The first deploy sets it up: a secret made on the server goes into the API’s settings (CONNECTOR_HOST_SECRET) and /etc/academy/connectors.env, the unit is installed and started; later deploys restart it with the apps. It runs under its own throwaway user and reaches only public https addresses. #CONNECTOR_HOST_SECRET= in the API’s settings switches it off; organisations then run every connector themselves (docs/connectors.md).

Who may use it: platform administrators switch knowledge sources on per organisation (Admin console → Organisations), since reading and analysing documents costs processing time and the organisation’s AI budget. KNOWLEDGE_WORKERS (default 1) sets how many documents are processed at once, KNOWLEDGE_MAX_FILE_MB (default 50) the largest file the server takes at all. The analysis uses the organisation’s language model; without one, documents wait until it is connected.

Locally: python -m venv .local/docling && .local/docling/bin/pip install docling-serve (on Windows .local\docling\Scripts\pip), start it with docling-serve run --port 5001, and set DOCLING_URL=http://127.0.0.1:5001 in apps/api/.env.

Pictures, videos and lesson audio the AI made carry the IPTC label “trainedAlgorithmicMedia” in their XMP, always, and signed Content Credentials where they are set up (EU AI Act Art. 50 (2), ADR 0290).

Automatic: on every deploy, deploy/update.sh runs deploy/install-c2pa.sh. It fetches the native part of @contentauth/c2pa-node with deploy/c2pa-binary.mjs, which refuses it unless its SHA-256 is the one pinned in deploy/c2pa-binaries.json, into /var/lib/academy-c2pa. Where the library loads on the server, the API signs itself. On AlmaLinux 9 it doesn’t (its C++ runtime is too old), so the signer runs in a container, academy-c2pa.service (node:26-trixie-slim fixed by its digest; no network, read-only, no capabilities), on /run/academy-c2pa/sign.sock, and the API gets C2PA_SIGNER_SOCKET. A problem here doesn’t undo an Academy deploy; AI media then carry the XMP label only.

From the admin console (ADR 0364): Operations → Content Credentials sets how the server signs without a deploy: the mode, the key in OVHcloud’s Key Management Service with the access to it, the certificate chain, a time-stamp authority and compression. The API reads the settings every minute and writes back whether the signer loaded. For a key in the key service the page has a test chain made (to try the whole way before a certificate is bought) and a certificate request (to hand to a certification authority); the returned chain is put in there. No private signing key is ever entered: the key stays in the key service, and what is kept is the access to it, sealed. Until the page is filled in, the settings of this file and the test certificate below apply.

The certificate: while C2PA_SIGNING_CERT and C2PA_SIGNING_KEY aren’t set, the script makes a test certificate of the server’s own in /etc/academy/c2pa (test-chain.pem, test-key.pem; the key readable by the group academy-api only). Verifiers show such credentials as valid, with the signer untrusted. It signs until the console’s page is filled in. For trusted credentials the key is made in the key service and a certification authority on the C2PA trust list issues a certificate for it; the steps, and what to do every year and when something goes wrong, are in the runbook. On a server with shell access, files and the two settings work as before.

A provider’s own Content Credentials: a picture that comes signed by its provider is read with the C2PA library and stored unchanged; the portal signs only files that come without a manifest (ADR 0295). Whether a signer or a time-stamp counts as trusted follows the C2PA trust lists that ship with the portal, one for claim signers and one for time-stamp authorities (apps/api/src/media/c2pa-trust-list.ts, ADR 0417); an ingredient’s manifest is checked against them when the portal takes it in. Refresh them about once a month: node deploy/c2pa-trust-list.mjs <commit of c2pa-org/conformance-public>, review which CAs came and went, and commit. C2PA_TRUST_ANCHORS names another PEM file instead.

The key in a KMS (optional): with C2PA_KEY_SOURCE=transit the key stays in a key management system that speaks the transit API, OpenBao or HashiCorp Vault; the signer sends a digest and gets the signature back (ADR 0298). The deploy doesn’t set this up yet. By hand, in the KMS:

  1. Enable the transit engine and make the key: type ecdsa-p256, exportable=false, allow_plaintext_backup=false.
  2. Get the certificate request for it: POST transit/keys/c2pa-claim-signing/csr with a csr that carries your subject as a template. Send the request to your CA.
  3. Store the issued chain with the key (signing certificate first): POST transit/keys/c2pa-claim-signing/set-certificate with certificate_chain.
  4. Give the signer a token whose policy allows read on transit/keys/c2pa-claim-signing and update on transit/sign/c2pa-claim-signing, nothing else, in a file only the signing service reads.
  5. Set C2PA_KEY_SOURCE=transit, C2PA_TRANSIT_ADDR (http://127.0.0.1:8200, https://… or unix:/run/openbao/bao.sock) and C2PA_TRANSIT_TOKEN_FILE.

For a new key: rotate it in the KMS, repeat steps 2 and 3 for the new version; the old one signs until the new chain is stored.

The key in OVHcloud KMS: with C2PA_KEY_SOURCE=okms the key is a service key in the Key Management Service of OVHcloud, in software or on its HSM (ADR 0303). In the KMS: an EC key on P-256 with the operations sign and verify, generated there (not imported), and an access that may read that key and sign with it, nothing else. Settings: C2PA_OKMS_ENDPOINT, C2PA_OKMS_ID, C2PA_OKMS_KEY_ID, and C2PA_OKMS_CLIENT_CERT with C2PA_OKMS_CLIENT_KEY (or C2PA_OKMS_TOKEN_FILE). The certificate request for the CA: node apps/api/dist/media/c2pa-csr-cli.js --country EE --organization "…" --common-name "…" with those settings in the environment (ADR 0308); the issued chain goes into the file C2PA_SIGNING_CERT names. For a new key: a new service key, a new request, then both settings together.

What the providers send: the API keeps a line for every AI file as it goes through the marking, in content_credentials_log (ADR 0310): what it came with (a provider’s own Content Credentials, by whom, trusted or not) and what it left with (the provider’s unchanged, signed by the portal, the label only, or not made). No person, organisation or file is in a line; lines go after 90 days. Read it on the admin console’s Content Credentials page, or in a deploy’s log under “Content Credentials: what AI media came with”. Uploads a person calls AI-made, or that come with credentials saying so, are lines of the kind upload; files the portal makes from an AI file (a cut, a frame) of the kind derived; course narration and reading aloud narration and readAloud (ADR 0317).

Check: journalctl -u academy-c2pa (container mode) shows academy-c2pa: signing at …; a downloaded course cover opened at contentcredentials.org/verify shows the credentials.

Switch it off: put the line #C2PA_LIBRARY_PATH= into /etc/academy/api.env.

Locally: node deploy/c2pa-binary.mjs .local/c2pa prints the library’s path; set it as C2PA_LIBRARY_PATH and a certificate in apps/api/.env (or leave it: the XMP label works without).

Key management (OpenBao) and official time

Section titled “Key management (OpenBao) and official time”

Both are set up by the deploy and switched in two small files (ADR 0300).

Key management: off by default (KMS=off; the signing key for Content Credentials can stay in a KMS elsewhere instead, such as OVHcloud’s, ADR 0303). With KMS=openbao in deploy/kms.conf, deploy/install-openbao.sh keeps OpenBao running in a container, academy-openbao.service: the image fixed by its digest, as the system user academy-kms, no network, read-only, reached only through the socket /run/academy-openbao/bao.sock. Its data is in /var/lib/academy-openbao; it unseals itself with /etc/academy/openbao/unseal.key, made once on the server and never printed. It runs uninitialised; nothing uses it yet. Back up /var/lib/academy-openbao with the server, and keep the unseal key yourself: without both, what the KMS holds is gone. Check: the deploy’s log under “Key management”, or journalctl -u academy-openbao. An installation with a KMS elsewhere, or none: KMS=off.

Official time: with OFFICIAL_TIME=on in deploy/time.conf of the admin console (its update runs deploy/install-time.sh; the console’s ADR 0007), adds the time servers of PTB (Germany), BEV (Austria) and METAS (Switzerland) to chrony, PTB’s and BEV’s authenticated with NTS, next to the sources the server has. It tells chrony to prefer the authenticated sources, so the clock follows PTB and BEV while any of them can be selected. It adds two lines to chrony’s settings (the file as it was is kept as chrony.conf.before-academy) and takes the sources out again if no authenticated one can be reached (NTS needs TCP 4460 outwards). Check: the deploy’s log under “Official time”, or chronyc sources and chronyc authdata. This sets the clock; the time-stamp in a signature comes from a time-stamp authority, not from these.

Lab lessons run learners’ code in Python, JavaScript, Go, Java and PowerShell (ADR 0102). Each run gets a fresh container under gVisor (Apache 2.0): a kernel of its own between the code and the server’s, no network, the user nobody without capabilities, 1 CPU, 512 MB–1 GB of memory, 256 processes and threads, and nothing of the server mounted. Files go in and results come out as tar archives on the container’s standard input and output. Input/output tests are compared in the API, outside the container.

On the lab nodes only: this server runs no learners’ code (ADR 0497). Every run and every session goes to a lab node, which installs from its own repository, i3-academy-lab-node. A node runs gVisor’s runsc (pinned with its SHA-512, with the systrap platform, so no KVM is needed) and the images assigned to it. A server with its own node local of before: the next deploy stops that agent and removes its service; remove the node local under Admin console → Lab nodes.

Free learners (platform accounts, the public catalogue) run code only on a lab node apart from this server: with the lab policy once a remote node is up (the default, admin console: Settings → Defaults) they are let in once a remote node is up, and their code goes only to remote nodes (ADR 0215). Learners of an organisation run code here as before. Always lets free learners run anywhere (development), never not at all. The same policy limits a person’s runs in 24 hours (default 300); LAB_WORKERS (default 4) sets the runs at a time on this server.

Terminal: /v1/lab-terminal (WebSocket, through the same API site) runs a program interactively in a container under gVisor with a pseudo-terminal (ADR 0107): one per person, at most 10 minutes, 3 without input. It needs the container sandbox; the images need script (util-linux), which every Debian and Ubuntu base has.

Lab nodes (ADR 0182): the API runs no code itself; a node’s agent takes the runs from the API. Drain a node or bring it back under Admin console → Lab nodes. A node of another protocol version (NODE_PROTOCOL, ADR 0497) gets no work and shows why in its version; update it (git pull and ./install.sh in its checkout).

Remote lab nodes (ADR 0213): more servers run learners’ code, joined to the main server by a WireGuard tunnel.

  • Off by default. LAB_TUNNEL=on in deploy/lab-tunnel.conf, committed, makes the next deploy set up the hub (section “Lab tunnel” in the deploy log):
    • the interface academy-lab (hub 10.77.0.1/24, UDP 51820, opened in firewalld; a network firewall of the hosting provider must let UDP 51820 through too);
    • nginx for the nodes’ API paths on 10.77.0.1:4080, nothing else;
    • the timer academy-lab-tunnel-sync, which brings the hub’s peers in line with the joined nodes every 30 s;
    • LAB_TUNNEL_* in the API’s settings.
  • Nodes in the private network (the default; no tunnel, TLS as for the database and Redis). With ACADEMY_LAB_NODES=internal and ACADEMY_LAB_DOOR_ADDR=<this server's private address> in the deploy settings, the deploy sets up the lab door (section “Lab door” in the deploy log):
    • the lab CA: its key in /etc/academy/lab-ca/ (root only, never on a node), its certificate in /etc/academy/lab-ca.crt (nodes get it when they join); it signs the door’s certificate for the private address (an IP SAN; anew when the address changes or within 30 days of its end);
    • nginx on <address>:4443 (ACADEMY_LAB_DOOR_PORT) with TLS 1.3 as the nodes’ only way in: the nodes’ API paths, nothing else;
    • LAB_DOOR_URL and LAB_DOOR_CA_FILE in the API’s settings (it hands the door and the CA to nodes when they join; the console reads them for the pairing).
    • What the image registry of before left (ADR 0488) goes on the next deploy: the container academy-registry, /var/lib/academy-registry, its write key, /etc/academy/lab-join.env and port 5000 in the tunnel’s firewall zone. A node joins through the door with its private address and the certificate of its dispatch server (made on the node, its key never leaves it). The API pins it in lab_nodes.dispatch_cert and connects to the node only with exactly that certificate (TLS 1.3); removing a node drops it (a trigger, whoever removes it). A node in the private network joins only through its pairing (ADR 0492); a token by hand is refused there. A tunnel node’s join without the console, as root on the portal server: cd apps/api && sudo node --env-file=/etc/i3-academy-api.env dist/labs/join-cli.js --name lab-1 prints LAB_JOIN_TOKEN=… once; good once for an hour, written to the platform audit log (lab_node_join, via join-cli), never over HTTP.
  • Add a server with AlmaLinux, Rocky, Debian or Ubuntu: clone i3-academy-lab-node on it and run sudo ./install.sh. It shows a pairing code; paste it under Admin console → Lab nodes → Add a node. The console checks the node’s certificate and hands it the join, the door and the lab CA; the node appears within a few minutes. A tunnel node: make a join there and run its command in the checkout on the new server.
  • Updates: in the node’s checkout, sudo git pull --ff-only, then sudo ./install.sh. The node keeps its token and certificates; its new release that doesn’t keep running is switched back. The portal hands out no agent and no installer any more.
  • Images (ADR 0493): the database holds only descriptions (a Dockerfile and small files, at most 1 MB, and a smoke test), never images. Under Admin console → Lab → Images choose per node which image and version it is to have; the node fetches the description through its API, builds it itself (through its build proxy if one is set, else directly), tests it under gVisor without network, and only then runs it. A failed build keeps the version before. The node drops images it is no longer to have once no run uses them; an active version is built anew after 30 days, so its base’s security fixes arrive. Organisations the console enables build their own images for their own nodes (Manage → Lab images).
  • Lab time (ADR 0215): sessions in an environment are part of courses and classes. A free or Pro learner has the course’s planned minutes plus 30; a class’s trainers set hours per participant under Class → Programmieraufgaben. Organisations’ plans have no lab hours.
  • Remove a node: “Remove” under Admin console → Lab nodes; it leaves the tunnel within 30 s. Then cancel the server.

Preview of lab sessions (ADR 0186): each session has its own host s-….preview.<web app's host>, served by the API’s preview server on port 4010.

  • DNS: a wildcard A record *.preview.<web app's host> pointing at this server.
  • Certificates: PREVIEW_CERTIFICATES in the API’s settings picks one of three ways (ADR 0186, addendum). The deploy sets up what the mode needs, then installs the nginx site and sets PREVIEW_DOMAIN.
    • wildcard-manual (the default): one wildcard certificate by hand.
      • On the portal’s server: sudo /opt/academy/portal/current/deploy/update.sh preview-certificate. It shows a TXT record: add it under _acme-challenge.preview.<host> in the DNS zone, and it continues once public DNS has it.
      • Renewal: run it again about every 60 days; the companions’ log warns 21 days before the end.
      • For a DNS zone without an API (Microsoft 365, for example).
    • wildcard-auto: the same wildcard through a certbot DNS plugin; certbot’s timer renews it.
      • Install the plugin (for example python3-certbot-dns-cloudflare, -dns-ovh, -dns-rfc2136) and put its credentials file on the server, 0600 root.
      • Set PREVIEW_DNS_AUTHENTICATOR (as certbot names it: dns-cloudflare, dns-ovh, dns-rfc2136, …) and PREVIEW_DNS_CREDENTIALS (the file’s path), optionally PREVIEW_DNS_PROPAGATION_SECONDS.
      • A zone without an API can hand the record over: a CNAME _acme-challenge.preview.<host> to a zone that has one (acme-dns, or a small zone with RFC 2136), with that zone’s plugin.
      • Nothing secret goes into the repository or the API’s settings, only the plugin’s name and the file’s path.
    • single: a certificate for each project’s host over HTTP-01, with no DNS record per certificate (the wildcard A record is enough).
      • A project keeps one host for all its sessions, p-<16 hex>.preview.<host>. Its certificate is made the first time someone opens its preview, then only renewed by certbot’s timer.
      • The root service academy-preview-certs gets them (the API has no rights itself). It makes at most PREVIEW_CERT_WEEKLY new ones a week (default 20): Let’s Encrypt allows 50 a week for the whole registered domain, shared with every other host of it.
      • Until a project’s certificate is there (or when the budget or a rate limit stops it), the lab says so and the session keeps running.
  • Switch it off: #PREVIEW_DOMAIN= in the API’s settings.

Git area (ADR 0188): private repositories, cloned and pushed with a Git token from Lab → Git.

  • Server: the deploy builds the image academy-git from infra/git and runs it as one container under gVisor, without network, with a read-only root, seeing only /srv/academy-git. It then sets GIT_SERVER=container and GIT_ROOT=/srv/academy-git. Without gVisor, Git stays off. The deploy log has the section “Git area”.
  • Clone address: an A record git.<web app's host> pointing at this server. The deploy installs the nginx site (deploy/nginx-git.conf), certbot adds HTTPS, and GIT_PUBLIC_URL=https://git.<host> follows on the next run. Until then clients clone from the API’s /git.
  • Backups: /srv/academy-git holds the repositories, one folder per repository id; back it up with the database.
  • Switch it off: #GIT_SERVER= in the API’s settings; the repositories stay on the disk.

Libraries: runs have no network, so what a course needs goes into its language’s Dockerfile (Python has numpy and pandas). PowerShell is PowerShell 7 on Linux: no registry, services, Active Directory or WMI.

Locally: the API’s tests run code in a process sandbox of their own (apps/api/test/process-sandbox.ts). To run code in the portal on your machine, start a lab node’s agent against it (the lab node repository’s README, “Develop”).

The community is the portal’s own board at /community (ADR 0082); it needs nothing on the server.

The platform is run from the admin console, its own program from its own repository (i-Academy/admin), with its own staff accounts, sign-in and host (admin.<domain>). The portal has no platform area any more (ADR 0264). The console works on the portal’s tables directly and asks the portal for what only the portal can do through platform jobs. Its docs/install.md describes it.

The platform’s team has no portal accounts (ADR 0450). Everything it did inside the portal is in the console now: the community’s general areas, reports and mutes, the platform’s Creative Space (switch and trainers), the lab’s reference authors and projects, and the platform’s tickets. What needs the portal’s own services (statements of reasons, mail, trash) the console asks for as a platform job.

The portal mails the console’s support team (its administrators and support, the view platform.support_team) about new platform tickets and replies, with a link to the console at ADMIN_CONSOLE_URL (default https://admin.<the web app's host>). Those emails have no reply address: the platform’s side answers in the console, with its sign-in and second step. PLATFORM_OPERATORS is no longer read.

Nothing to configure: the MCP server is part of the API at https://<api host>/v1/mcp, and nginx passes it through. People create their own access tokens under My account. See docs/mcp.md.

  • Backups: back up PostgreSQL (pg_dump) and /var/lib/academy/storage (videos, recordings).
  • No root for the API: the API runs as its own user academy-api, without sudo or capabilities (ADR 0265), and listens on 127.0.0.1 only. Learners’ code runs on the lab agent; git runs in its container through the Git gate (academy-git-gate). Every deploy logs API user: ….
  • More servers: for more capacity, put further portal servers beside the first (--roles portal on each, with the same database); deploy on the migrating one first. The API instances coordinate through Redis.