# coreapp.toml reference

> Every setting in a Coreapp's coreapp.toml, and what the Core gives the app for each need.

- Web page: https://documentation.federated.computer/developer-tools/core-app-development-kit/coreapp-toml/

`coreapp.toml`, at the root of the app's repository, is all the Core reads about an app besides its icon. The Core is strict about it, because its values end up in files on the server: an unknown setting or a value it can't use stops the install with a message saying what's wrong.

```toml
name = "timesheets"                  # its address: https://timesheets.example.com
title = "Timesheets"                 # shown in the dashboard
description = "Track time for projects and clients"
docs = "https://example.com/docs"    # optional; linked from the dashboard
image = "gitea.example.com/my-team/timesheets"
version = "1.2.0"                    # the image tag; the release is tagged v1.2.0
port = 8080                          # the port the app serves HTTP on
health = "/health"                   # a page that answers once it's up
needs = ["postgres", "sso", "email"]
```

## Settings

| Setting | Required | What it is |
|---|---|---|
| `name` | Yes | The app's name and address. 2 to 31 lowercase letters, digits, and hyphens, starting with a letter and not ending with a hyphen. Names of Federated's applications (installed or not) and of the Core's own addresses (`www`, `mail`, `admin`, ...) can't be used; `coreapp core` lists them. |
| `title` | Yes | Shown in the dashboard. Up to 40 letters, digits, spaces, and `. , ! ? ( ) & + _ -`. |
| `description` | No | One sentence, up to 200 characters, without `"`, `$`, backticks, `\`, `@`, or line breaks. |
| `docs` | No | An `https://` address for the app's documentation. For an app installed from a repository, it defaults to the repository. |
| `image` | Yes | The image, including its registry, for example `gitea.example.com/my-team/timesheets`. A name without a registry is refused, so an image is never taken from Docker Hub by accident. `localhost/...` images are for development only. |
| `version` | Yes | The image's tag. Letters, digits, `.`, `_`, and `-`. A published release is tagged `v` plus the version. |
| `port` | Yes | The port the app serves plain HTTP on inside its container, as a number. It's reachable only from inside the Core. |
| `health` | No | A path that answers once the app is up (default `/`). The Core waits for it after installing or updating, and rolls an update back if it doesn't answer. |
| `needs` | No | What the app uses from the Core: any of `postgres` or `mysql` (not both), `sso`, and `email`. |

## What every app gets

The app runs in one container, from its image. The Core puts HTTPS in front of it at `https://<name>.<domain>` and keeps `/data` inside the container across updates and restarts. Everything else in the container is replaced on each update.

It gets these environment variables:

| Variable | Value |
|---|---|
| `APP_URL` | The app's address, `https://<name>.<domain>` |
| `APP_SECRET` | A random secret for signing cookies and sessions. It never changes. |
| `IMAGE_VERSION` | The installed version |
| `CORE_DOMAIN` | The Core's domain. Set only on a Core, so an app that also runs elsewhere can tell where it is. |
| `CORE_ADMIN_EMAIL` | The Core's admin account, always an admin of the app |
| `CORE_PROXY` | The address of the Core's proxy, the only one in front of the app. Trust it for `X-Forwarded-For` and `X-Forwarded-Proto`. |

## Needs

### postgres

The app's own database and user on the Core's PostgreSQL. The app owns its database and nothing else, and creates its own tables.

| Variable | Value |
|---|---|
| `DB_HOST`, `DB_PORT` | The Core's PostgreSQL, port 5432 |
| `DB_NAME`, `DB_USER` | `coreapp_<name>`, with hyphens as underscores |
| `DB_PASSWORD` | Random |

Optional settings:

```toml
[postgres]
min_version = "16"       # the oldest PostgreSQL the app works with
extensions = ["vector"]  # extensions the app's own user can't create
```

- `min_version`: a Core with an older PostgreSQL refuses to install the app, instead of the app failing later.
- `extensions`: the Core creates these in the app's database before it starts. Use it for extensions that need an administrator, such as `vector` (pgvector). Extensions like `pg_trgm` or `uuid-ossp` the app can create itself. `coreapp core` lists which are which.

### mysql

The same, on the Core's MariaDB, for apps that need MySQL or MariaDB: the same `DB_*` variables, port 3306, and a `utf8mb4` database. It takes `[mysql] min_version` (in MariaDB's numbering).

### sso

Sign-in with Core accounts, through the Core's Authelia (OpenID Connect). The Core registers the app as a client:

| Variable | Value |
|---|---|
| `OIDC_ISSUER` | `https://authelia.<domain>` |
| `OIDC_CLIENT_ID` | `coreapp-<name>` |
| `OIDC_CLIENT_SECRET` | Random |

By default the client expects the app to send people back to `/auth/callback`, to use PKCE, and to send its secret in the Authorization header. For an app that does it differently:

```toml
[sso]
callback = "/auth/openid/core"     # where the app sends people back (default "/auth/callback")
pkce = false                       # the app doesn't use PKCE (default true)
token_auth = "client_secret_post"  # it sends the secret in the form
```

Scopes: `openid`, `profile`, `email`, and `groups`. The person's details (`email`, `name`, `preferred_username`) come from the userinfo endpoint.

### email

An account on the Core's mail server, only for sending:

| Variable | Value |
|---|---|
| `SMTP_HOST`, `SMTP_PORT` | The Core's mail server, port 587 |
| `SMTP_SECURITY` | `starttls` |
| `SMTP_USER`, `SMTP_PASSWORD` | The app's own account, `coreapp-<name>` |
| `SMTP_FROM` | `<name>@<domain>`, the address to send from |

Mail sent to `SMTP_FROM` isn't delivered anywhere, so set a reply-to address if people should be able to answer.

## Changing needs

Adding a need to an installed app and updating it sets that need up. Removing `sso` or `email` removes the sign-in client or mail account once the new version is running. Removing `postgres` or `mysql` would delete the app's database, so the Core refuses it unless the person installing confirms they want the database deleted.

## Not available yet

Services other than these (such as Redis), a second container, extra host names, and public ports other than HTTPS.
