# Installing Superbrain

> For administrators: add Superbrain to a Core, or run it on its own with Docker.

- Web page: https://documentation.federated.computer/superapps/superbrain/installing/

On a We host Core, Federated installs and updates Superbrain for you, and you can skip this page. It's for You host administrators and for anyone running Superbrain on their own server.

There are three ways to run Superbrain:

| Where | How | Sign-in |
|---|---|---|
| On a Core | The Core installer, run on the Core | Core SSO (Authelia) only |
| On any Docker host | Docker Compose | Accounts in Superbrain, or your own OpenID Connect provider |
| On a standalone server | The deploy script, which adds nginx, Let's Encrypt certificates, and database backups | Accounts in Superbrain, or your own OpenID Connect provider |

## On a Core

> **You host only**
>
> Run this as root on the Core.
>
> Command-line access is available only when Federated Core was installed with the You host option. [What this means](https://documentation.federated.computer/getting-started/command-line-access/)

```
sudo bash -c "$(docker run --rm --pull always federatedcomputer/superbrain-migrate cat /deploy/install.sh)"
```

The installer uses what the Core already runs: Authelia for sign-in, the shared PostgreSQL database, the Traefik proxy, PowerDNS, and the Core's mail relay. Superbrain is then published at `https://superbrain.example.com`, and people sign in with their Core accounts.

To update it later:

```
/federated/bin/upgrade superbrain
```

## With Docker Compose

You need Docker with Compose v2 or newer.

1. Get the code and create a settings file:

   ```
   git clone https://gitea.federated.computer/Federated_Computer/superbrain.git
   cd superbrain
   cp .env.example .env
   ```

2. Generate a secret and put it in `.env` as `AUTH_SECRET`:

   ```
   docker run --rm node:22-alpine node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))"
   ```

3. Start it:

   ```
   docker compose up -d --build
   ```

4. Open `http://localhost:3000`, sign up, and sign in.

`docker compose down` stops Superbrain and keeps its database.

> **Before you put it on the internet**
>
> Set `ALLOW_BOOTSTRAP_SIGNUP=0` and `NEXTAUTH_URL` to its public address, and serve it over HTTPS. The deploy script in `scripts/deploy.sh` does this for a standalone server.

## Settings

The most important settings in `.env`:

| Setting | What it does |
|---|---|
| `AUTH_SECRET` | Signs sign-in sessions. Required. |
| `NEXTAUTH_URL` | Superbrain's public address. Required in production. |
| `TIER` | `core` allows only single sign-on; `multi` allows people to sign up themselves. Leave it unset to allow both. |
| `ALLOW_BOOTSTRAP_SIGNUP` | Set to `0` on any server others can reach. |
| `ADMIN_EMAILS` | Who is an administrator |
| `OIDC_ISSUER`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET` | Single sign-on with an OpenID Connect provider. Set all three. |
| `SMTP_HOST`, `SMTP_FROM` | Sending email notifications |
| `ENCRYPTION_KEY` | Encrypts stored secrets, such as mailbox passwords |

The full list is in the [Superbrain README](https://gitea.federated.computer/Federated_Computer/superbrain).
