Skip to content

Installing the portal

The portal is the learning platform with its API (ADR 0261). ./install.sh sets it up on a server from this checkout, either natively (systemd, nginx with certbot, Node 26, the database on a server of its own) or with Docker Compose (everything on one machine, its own database included). The admin console and the website come from their own repositories, each with its own install.sh; the admin console is installed first, the portal on top (ADR 0449). Decision records: ADR 0444 (this installation), ADR 0263 (the database role).

  • A server for the portal.
    • Native: AlmaLinux, Rocky or RHEL 9 or 10, Debian 12 or 13, or Ubuntu 24.04.
    • Docker: any Linux with Docker and the compose plugin, from Docker’s own repository (docs.docker.com/engine/install: docker-ce and docker-compose-plugin); a distribution’s older docker.io lacks fixes.
    • At least 4 GB of memory (8 GB with the code lab or the document reader) and 20 GB free disk, more for videos. The build runs on this server, in the checkout; what runs is only the built runtime in APP_DIR.
    • Ports 80 and 443 free. An nginx that is already running is fine; the sites are added to it.
  • A database server (native only), as a provision. Nothing of the portal’s is installed there. It needs:
    • PostgreSQL 17 with the extension pgvector available, reachable from the portal server over TLS (sslmode=require at least);
    • max_locks_per_transaction = 1024 (a restore of a whole schema in one transaction needs it; deploy/db/setup.sh warns when it is lower);
    • an admin user (by default postgres) that may create databases, roles and extensions. Its password is used only for the setup. It is asked for hidden and kept nowhere;
    • Redis (or Valkey), by default over TLS on port 6380, with a password;
    • optionally, the CA certificate of both, as files on the portal server (DB_CA_FILE, REDIS_CA_FILE) for verify-full.
  • DNS names pointing at the portal server:
    • the portal, e.g. portal.academy.example.com;
    • the API, by default api.<base>, e.g. api.academy.example.com;
    • per module: rtc.<base> (live), relay.<base> (relay), content.<base> (SCORM), docs.<base> (the handbooks, static; the deploy copies the build to /var/www/academy-docs), git.<base> (Git area), *.preview.<base> (lab previews; certificates as PREVIEW_CERTIFICATES says: a wildcard by hand or through a certbot DNS plugin, or one per project over HTTP-01, see docs/deploy.md).
  • A mail server to send through (one SMTP server or Microsoft 365), set in the admin console under Mail (its ADR 0002); the portal reads it from there and sends itself. Sign-in links and invitations go by mail.
  • Optional, set up after the installation:
    • a Stripe account, for payments;
    • AI provider keys (OpenAI, Anthropic, Mistral, …), for the AI features;
    • a DeepL key, for translations;
    • OAuth apps for signing in with Google, Microsoft or GitHub, each with the redirect address https://<API host>/v1/auth/oauth/<google|microsoft|github>/callback, entered in the admin console (Settings → Sign-up and sign-in → Sign-in apps);
    • your own LiveKit, if you don’t want the built-in one;
    • your legal texts in Termly. The portal ships no texts of its own: imprint, privacy policy, terms of use and cookies are yours. The withdrawal information can also be your own text in the admin console, from the portal’s German template.
  1. Clone the repository onto the portal server. The installation and every update run from this checkout:

    Terminal window
    sudo dnf install -y git # AlmaLinux, Rocky, RHEL; on Debian and Ubuntu: sudo apt-get install -y git
    sudo git clone https://github.com/i-Academy/portal.git /srv/i3-academy-portal
    cd /srv/i3-academy-portal
  2. Check the server: sudo ./install.sh --check (with --answers <file> to check those answers). It checks:

    • the system, memory and disk;
    • ports 80 and 443;
    • that every DNS name points at an address of this server (PUBLIC_IP when the server is behind NAT);
    • that PostgreSQL and Redis on the database server answer;
    • outgoing connections to the npm registry, Let’s Encrypt and the mail server.
  3. Install:

    • interactively: sudo ./install.sh, which asks each question, the admin password hidden;
    • unattended: copy install.env.example, fill it in, and run sudo ./install.sh --answers install.env. Every answer is explained there. The admin password is never an answer (DB_ADMIN_PASSWORD is refused): name a root-only file with it in the environment, sudo DB_ADMIN_PASSWORD_FILE=/root/db-admin ./install.sh --answers install.env, and delete the file afterwards.

The native installation goes in this order:

  1. System packages from the distribution: nginx, certbot and ffmpeg. For the database server only its clients: psql and pg_dump of PostgreSQL 17 (postgresql-client-17, from the PostgreSQL project’s repository where the distribution has an older one: an older pg_dump can’t dump a 17 server) and redis-tools. Node 26 comes from nodejs.org, checked against its checksums, unless the system already has 26 or newer; the build uses the checkout’s pnpm through corepack (ADR 0441). On RHEL, SELinux lets nginx reach the local services, and firewalld opens HTTP and HTTPS. With the modules lab or git, Docker comes too, from Docker’s own repository on every system; the first deploy adds gVisor to it.

  2. Secrets: JWT_SECRET, KMS_MASTER_KEY and IDENTITY_PEPPER, made by the installer. The keys it shares with the admin console are the console’s: CONSOLE_KMS_KEY (ADR 0442) and MAIL_SETTINGS_KEY (ADR 0455), one root-only file each in /etc/academy/keys/ (console-kms-key.env, mail-settings-key.env; ADR 0481). The installer never makes them and writes no copy into the portal’s settings; it stops without them: install or update the admin console first, or, on a server without it, copy /etc/academy/keys/ from the console’s server, root only.

  3. The database part (deploy/db/setup.sh, also on its own: sudo ./install.sh --db-setup). Over the network, with the admin user:

    • the database DB_NAME (by default academy), with the admin console’s schema platform and its roles academy_platform_reader and academy_platform_writer: the console made them, and without them the setup stops (“install the admin console first”); the extensions btree_gist and vector where missing;
    • the role academy_portal (deploy/db/database-role.sql): it owns the core schema public and bypasses row-level security, but is no superuser and doesn’t own the database; tenant requests run as academy_app. Both get academy_platform_reader and academy_platform_writer, and the search path public, platform: the operator’s tables are the console’s, which the portal reads and writes back to only where the writer role lets it (ADR 0449);
    • the relay’s role academy_relay, without rights on tables yet.

    The roles’ passwords are made once and kept in CONFIG_DIR/db-roles.env (root only, by default /etc/academy/portal); a second run keeps them. The addresses the services use go to CONFIG_DIR/database.env (DATABASE_URL, RELAY_DATABASE_URL). The admin password reaches psql only in its environment (PGPASSWORD): never as an argument, in a file or in the log. The grants on tables come later from the portal’s own role (deploy/db/grants.sql, on every update), so no update needs the admin access.

  4. Settings in /etc/i3-academy-api.env, readable by root and the API’s user only (root:academy-api 0640), with the database’s address from the setup, Redis’s, and the CAs (DATABASE_SSL_CA_FILE, REDIS_TLS_CA_FILE: only the API’s PostgreSQL and Redis clients trust them). Modules you didn’t choose are switched off there with #<setting>=. No shared key is in it: the API’s unit reads the key files after it (EnvironmentFile=).

  5. Services:

    • i3-academy-api.service (port 4000) runs as the user academy-api, without sudo or capabilities (ADR 0265). Learners’ code runs on the lab agent, git through the Git gate.
    • academy-portal.service (port 3001) runs as the user academy-portal.
    • Both listen on 127.0.0.1 and start from APP_DIR/current (by default /opt/academy/portal/current), the release in use. /etc/academy-portal-deploy.env holds what deploy/update.sh needs: the services, their health addresses, APP_DIR, CONFIG_DIR and BACKUP_DIR.
    • deploy/provision.sh puts every unit into academy.slice and gives it the limits from /etc/academy/sizing.env (below).
  6. The network’s settings: /etc/academy/roles.env with the private addresses, and academy-network, which makes the firewall from it (deploy).

  7. The first update from this checkout, deploy/update.sh (deploy): it builds, delivers the runtime to APP_DIR/releases/<commit>, migrates the new database, switches current, starts the services and sets up those beside them (nginx with a Let’s Encrypt certificate for the portal and the API, the modules chosen). With the module relay the relay gets its address from the setup and starts too.

  8. Summary: addresses, services, where the settings are, and what is left to do by hand.

The Docker installation builds the images (deploy/docker/Dockerfile), starts PostgreSQL and Redis, sets up the role academy_portal, migrates, and starts the API, the web app and Caddy, which gets the certificates (deploy/docker/compose.yml). The settings are in deploy/docker/.env and deploy/docker/api.env, both readable by root only. The modules need the host (systemd, gVisor), so they stay off with Docker for now. Code exercises run on lab nodes there.

An existing installation is never overwritten. The installer stops when /etc/i3-academy-api.env (native) or deploy/docker/.env (Docker) exists, and names the update instead: sudo git -C <checkout> pull --ff-only && sudo <checkout>/deploy/update.sh.

The answers. Every question goes through deploy/answers.sh, the same file in the console, the portal and the website. What an installer on this machine was told is kept in /etc/academy/answers.env (root only, no passwords, keys or tokens) and is the default of the next run, whichever installer runs then: the portal’s installer after the console’s offers the database server, the addresses and DATA_DIR the console was given.

--db-setup alone asks only the database’s questions (deploy/db/ask.sh: the server, its port, the database, TLS, the CA file only with verify-full, the admin user), then the admin password hidden (deploy/db/setup.sh). Their defaults: the answers of before, else this portal’s own settings (CONFIG_DIR/database.env, else the API’s DATABASE_URL and DATABASE_SSL_CA_FILE). TLS is DB_SSLMODE as given.

The order with the console and the website

Section titled “The order with the console and the website”

Each repository installs itself from its own checkout, on its server (ADR 0444):

  1. The admin console (https://github.com/i-Academy/admin.git): its own install.sh. It makes the database with its extensions, its roles, its schemas admin and platform with the operator’s tables (settings, operator data, legal texts, prices, beta codes, maintenance, platform jobs, lab nodes; the beta mode on) and the shared keys CONSOLE_KMS_KEY and MAIL_SETTINGS_KEY in /etc/academy/keys/ (ADR 0449, ADR 0481).
  2. The portal (this page), on top. Its migration 0491 drops the copies of the operator’s tables its earlier migrations make. Then, in the console’s checkout, sudo ./install.sh --db-setup (its grants on the portal’s tables, which exist now) and sudo ./install.sh --portal-settings.
  3. The website: its own install.sh, the same way.
  4. Lab nodes (below).
  5. Media servers of their own when the live sessions outgrow LiveKit beside the portal (below).

An installation whose operator’s tables are still in public (from before ADR 0449) keeps its data: after the portal’s update, the console’s sudo ./install.sh --db-setup moves the operator’s tables into platform (the update says when it is due; ADR 0449).

The database server stays a provision: each installer reaches it over the network with the admin access for its own roles, and leaves nothing there but its roles, its schema and its data.

A server with a small system disk and a disk of its own for data (e.g. mounted at /data) answers DATA_DIR=/data (ADR 0447); the installer offers /data when a disk is mounted there, else a bigger disk than the system’s (/data on another disk than /, or the largest other mount with at least 50 GB; ADR 0487), and none keeps everything on the system disk. A lab node without a data folder and with less than 100 GB free in /var/lib gets a warning: its lab images would fill the system disk; an installed node moves them with sudo deploy/data-dir.sh move /data, then confirm. Everything the portal keeps goes there: uploads, videos and recordings, the erasure log’s copy (/var/lib/academy), the dumps before migrations (/var/backups/academy), docker’s data for the Git area and the code lab, Docling’s environments and models, ClamAV’s signatures, a lab node’s sessions (the list: deploy/data-dirs.list).

Every folder keeps its path: /data/var/lib/academy is bind-mounted on /var/lib/academy through /etc/fstab, so settings, units, SELinux’s labels and AppArmor’s profiles stay as they are. The console’s and the website’s installers find DATA_DIR in /etc/academy/data-dir.env and put their folders there too.

  • sudo academy-data-dir status: each folder, where it is, its size; the free space.
  • An installation from before moves once: sudo deploy/data-dir.sh move /data. It names the services it stops and asks, copies, checks, switches and starts them again; the old copies stay as <folder>.before-data-dir. Once everything runs: sudo academy-data-dir confirm deletes them; before that, sudo academy-data-dir undo goes back with what was written since. Updates never move data; they name a folder still on the system disk.
  • A backup service has to include the data folder: the bind mounts are other file systems to it.
  • The monitoring gets each folder’s size and the free space hourly (academy_data_dirs.prom in the fleet agent’s textfile folder).

A lab node runs learners’ code for the portal (ADR 0213). It installs from its own repository, i3-academy-lab-node, not from this one (ADR 0497). Its README describes the install, the update and how a node installed from this repository before moves over. In short:

  1. Clone i3-academy-lab-node on the node and run sudo ./install.sh. It asks for this machine’s private address (THIS_ADDR) and the portal servers’ (PORTAL_ADDRS). Nothing of the portal’s is needed.
  2. At the end it shows a pairing code (good once, for an hour; ADR 0492). Paste it under Admin console → Lab nodes → Add a node. The console checks the node’s certificate against the code and hands it the join, the door and the lab CA. The node joins through the door, trusting only the lab CA, and its agent runs with TLS both ways.
  3. Under Admin console → Lab → Images, choose the images the node is to have. It builds and tests them itself (ADR 0493).

The update order matters for the lab images: the console first, then the portal.

  • The portal’s update writes the image templates and the environments’ catalogue into the console’s tables.
  • Run before the console’s update, it writes nothing (its log says !! lab templates), and Lab → Images stays empty until the portal’s update runs again.

Nodes over the internet: LAB_NODES=wireguard on the portal (its tunnel), and ./install.sh --tunnel lj_… on the node.

The portal server runs no learners’ code itself: with the module lab, /etc/academy-portal-deploy.env gets the door on its private address. Once a node has joined, assign it its images under Admin console → Lab → Images: a node runs a language only once it built that image.

The firewall between the machines: portal reaches the database server on 5432 and 6380, lab reaches the portal’s door (TCP 4443, TLS) and the portal reaches lab’s dispatch port (TCP 7071, TLS), lab never reaches the database. academy-network makes these rules from /etc/academy/roles.env on the portal server and the lab nodes; the database server’s firewall is the provision’s.

LiveKit (audio, video and screens of live sessions) runs beside the portal with the module live. When it outgrows that, it goes to a server of its own, or to a cluster: sudo ./install.sh --roles rtc --answers rtc.env from a checkout of this repository on that server, then a LiveKit target in the admin console (Operations → Live → RTC targets) and the old one set to draining (ADR 0480). The whole way, the cluster with its own Redis included: rtc-servers.md.

A TURN server of its own (rooms without LiveKit): sudo ./install.sh --roles turn, on a machine of its own, then a TURN target in the console (ADR 0484; rtc-servers.md).

In the server status: lab nodes, media and TURN servers set up the console’s host probe when the installer gets HOST_PROBE_CLIENT_CERT (a copy of the console’s /etc/academy/admin/host-probe/client.crt); then their address goes into LIVE_ADDRS (media, TURN) or LAB_ADDRS of the console’s roles.env (rtc-servers.md).

The firewall of a media server, and of a portal server with LiveKit beside it: the role rtc in roles.env opens LiveKit’s media ports to everyone (TCP 7881, UDP 3478, 50000–60000 and 30000–40000), which academy-network 3 knows. Without them a live session connects and carries no audio or video.

No service has a fixed size. On every run deploy/sizing.sh reads the machine’s memory and CPUs and the roles on it, and writes /etc/academy/sizing.env: MemoryMax/MemoryHigh and the Node heap of each service, the lab’s parallel runs and a swap size. The rules:

  • At most 85 % of the memory goes to services, and at least 10 % (512 MB or more) stays free for the system and sshd.
  • Each service first gets its floor. The rest goes by weight, never past a ceiling.
  • MemoryHigh is 85 % of MemoryMax, and a Node heap 75 % of it.

If the floors alone need more than the machine has, the summary says so (TOO_SMALL). deploy/provision.sh turns the file into systemd drop-ins (50-academy-sizing.conf) for the units of this installation: every unit joins academy.slice, where systemd-oomd stops a process first when memory runs short, and sshd is the last thing anything stops. deploy/sizing.sh --roles portal --mem-mb 16000 --cpus 8 shows what another machine would get. The database server’s own sizing is the provision’s.

What the installer puts on the server stays current by itself, so a server doesn’t keep the state of the day it was installed:

  • The system’s security updates every day: dnf-automatic with security updates on AlmaLinux, Rocky and RHEL, unattended-upgrades on Debian and Ubuntu. Services and the server aren’t restarted; dnf needs-restarting -r or /var/run/reboot-required say when that is due. AUTO_UPDATES=no in the answers leaves the updates to you. Every update (deploy/update.sh) sets them up too where they aren’t yet; ACADEMY_AUTO_UPDATES=no in /etc/academy-portal-deploy.env leaves them to you there.
  • Server and access logs 30 days: every update sets the journal and nginx’s log rotation to it (Retention); ACADEMY_LOG_RETENTION=no in /etc/academy-portal-deploy.env leaves them to you.
  • Node.js from nodejs.org: the version and the SHA-256 of its archives are pinned in deploy/node-release.env, and install.sh puts exactly that version on the server. Every update brings it to the pin of the commit it deploys (release_node): it keeps the Node before, restarts the services on the new one and checks them, and puts the old one back if they don’t come up (deploy). A new Node version is a commit; scripts/pin-node.sh <version> sets a new pin after checking the release signature against nodejs/release-keys, and the weekly pin check (scripts/check-pins.mjs) says when a security release is out. A Node that came from the distribution or was there before stays as it is (and is updated with the system).
  • Docker comes from Docker’s own repository on every system, not from the distribution: Debian’s docker.io and runc lag behind.
  • The code lab’s and the Git area’s images come from the recipes in the checkout. The update reads the lab’s into the console as templates. Lab nodes build the images assigned to them themselves, and anew every 30 days (the console says when a template is newer than an image’s version). The Git area builds its image on the deploy, anew every 30 days with fresh bases. gVisor is a fixed release with the SHA-512 of its archives in deploy/install-gvisor.sh (the lab node’s repository has the same script). The weekly pin check says when it is more than a month behind.
  • With Docker: sudo git -C <checkout> pull --ff-only && sudo <checkout>/install.sh --update pulls the newer patch releases of PostgreSQL, Redis and Caddy and builds the images of the checkout’s HEAD on fresh base images (--update itself never pulls the code).
  • Pinned versions (pnpm, LiveKit, docling-serve, PowerShell and Go in the lab) move with the repository. A weekly CI run (scripts/check-pins.mjs) says when one is behind upstream or has known advisories, and every CI run refuses dependencies with known high or critical advisories (pnpm audit).
  1. Keep a copy of KMS_MASTER_KEY from the settings and of /etc/academy/keys/ (the console’s keys). Encrypted data (AI conversations, mentoring notes, stored keys, the mail settings) can’t be read without them.
  2. The platform’s team signs in to the admin console with the accounts its installation made (its ADMIN_FIRST_EMAIL); the portal has no platform administrators of its own (ADR 0450). People register at https://<portal>/register, while the beta mode is on with a beta code from the console.
  3. Set up the platform in the admin console (the portal has no platform area, ADR 0264):
    • who runs it (ADR 0269): the product’s name, your company, address, contact and logo; the facts of the data processing agreement (backups, data centres, law and courts); your withdrawal information per language. Until they are set, the portal shows neutral placeholders and the contracts stay drafts;
    • your service providers under Operations → Providers (ADR 0359): each company that receives personal data, with its purpose per language, where it processes the data, the safeguard for transfers and how long it keeps them. One list feeds both the privacy policy (where your own text has {providers}, it becomes a table in the text’s language) and, for the rows marked as sub-processors, Annex 3 of the data processing agreement. Until a row is marked, Annex 3 keeps the sub-processors entered before. Changing a sub-processor changes the agreement: raise its revision and tell organisations at least 30 days ahead;
    • how it is run: as a service for organisations (saas, the default) or as your own single instance (single);
    • the legal texts (Termly ids for imprint, privacy policy, terms of use, withdrawal information, cookies);
    • the mail provider;
    • AI providers;
    • prices and the payment provider. The portal registers its Stripe webhook itself.
  4. Create the first organisation at https://<portal>/signup and open the link in the email it sends (the organisation is made only then, ADR 0422; mail must work first). Afterwards set ALLOW_SIGNUP=false in the settings, if only you create organisations. A single instance (single) has no sign-up: create its organisation in the admin console, which invites its owner.

docs/configuration.md lists every setting, and docs/deploy.md describes each module in detail.

  • Updates:
    • native: sudo git -C /srv/i3-academy-portal pull --ff-only && sudo /srv/i3-academy-portal/deploy/update.sh (or … deploy/update.sh <commit>, a commit on origin/main). It never pulls itself. It builds in the checkout, backs up the schema before pending migrations, migrates, switches and checks; anything failing puts the previous release and the database back. sudo deploy/update.sh rollback goes back to the release before (deploy).
    • Docker: sudo git -C /srv/i3-academy-portal pull --ff-only && sudo /srv/i3-academy-portal/install.sh --update.
  • Logs:
    • native: journalctl -u i3-academy-api -u academy-portal;
    • Docker: docker compose -f deploy/docker/compose.yml logs.
  • Restart:
    • native: sudo systemctl restart i3-academy-api academy-portal;
    • Docker: docker compose -f deploy/docker/compose.yml restart.
  • Backups: back up the database (the backup service, pg_dump, or the pgdata volume) and the files (/var/lib/academy/storage, or the storage volume). An update keeps a dump of every schema (public, platform, admin, site) before its migrations in BACKUP_DIR (the last five sets); that is no backup of its own.

The portal’s role is never a superuser: a superuser could read every schema, the admin console’s included. deploy/db/setup.sh makes it that way on the database server, and on every update deploy/update.sh checks the role and logs it in a line starting with database role:.

On a Docker installation, or an old one whose role is a superuser, the update changes that:

  • An ordinary role loses the superuser attribute and keeps BYPASSRLS.
  • A container’s own superuser (POSTGRES_USER) can’t lose it. Instead:
    • the core schema moves to a new role academy_portal (ACADEMY_DB_ROLE to choose another name), and the settings files that held the old address get the new one;
    • once the portal is healthy, the old superuser gets a new password, kept in /root/academy-postgres-superuser.txt. Set ACADEMY_KEEP_SUPERUSER_PASSWORD=1 in /etc/academy-portal-deploy.env if other tools of yours use it;
    • if the portal isn’t healthy, the settings go back.

Extensions need the admin user: deploy/db/setup.sh makes btree_gist and vector. A migration that needs another extension must have it made there first.

The admin user does only the database, the roles, the grants on the schema and the extensions. It never reads or writes the portal’s data. Backups before a migration (pg_dump), the migrations and the grants on tables run as academy_portal.