Apps are a coreapp.toml; a trusted installer makes the Core side

An app's repository now has only coreapp.toml, its Dockerfile, its code
and an icon: no install scripts or compose file, so installing an app
from someone else's repository can't run their code as root on a Core.

core/coreapps runs on the Core (coreapp deploy puts it in /opt/coreapps).
It checks the manifest, refuses Federated's app names and the Core's
hostnames, picks a free address on that Core, writes the generic app
format from its own templates, sets up the needs (postgres, sso) and
installs through installapp. Updates keep the address, secrets and data,
add settings for new needs and delete old images; dropping a need is
refused. remove rebuilds Superpanel's catalog afterwards.

PLAN.md: the Coreapps direction and steps, and what the Core offers apps
(Superpanel's AI features, mcpserver, hermes, email, PowerDNS).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 13:36:47 -07:00
co-authored by Claude Opus 5.5
parent d8c6d1011f
commit b4d47fb1c5
36 changed files with 1046 additions and 413 deletions
+2 -4
View File
@@ -1,7 +1,5 @@
.git
service
*.in
install
uninstall
.gitea
coreapp.toml
icon.png
README.md
+3 -3
View File
@@ -1,6 +1,6 @@
# The app's image. coreapp deploy builds it as coreapp/{{NAME}}:<VERSION>
# and copies it to the Core. Replace this with your own app; keep it
# listening on the port in docker-compose.yml.in (8080).
# The app's image. coreapp deploy builds it as image:version (from
# coreapp.toml) and copies it to the Core. Replace this with your own app;
# keep it listening on the port in coreapp.toml (8080).
FROM busybox:stable
COPY www /www
EXPOSE 8080
+27 -19
View File
@@ -18,28 +18,36 @@ coreapp remove # uninstall it from the Core
## Files
The app is in the format Federated Core installs apps from
(`/federated/services/{{NAME}}/` on the Core):
| File | What it is |
|---|---|
| `service` | Name, description, image (`CONTAINER`), `VERSION`, `INTERNAL_IP`, apps it needs (`DEPENDS`, e.g. `postgresql`), and how to check it's up (`MONITOR`) |
| `docker-compose.yml.in` | The container(s), on the Core's `core` network at `INTERNAL_IP`, with the traefik labels that give it `https://{{NAME}}.<domain>` |
| `env.in` | Its settings, as the `.env` file next to the compose file |
| `install` | Run by the Core's `installapp`; fills in the templates |
| `icon.png` | Its icon in the Core's dashboard |
| `Dockerfile`, `www/` | The app itself (not copied to the Core) |
| `coreapp.toml` | What the Core needs to know: name, title, image and version, port, health path, and what it needs from the Core (`needs`) |
| `Dockerfile`, `www/` | The app itself |
| `icon.png` | Its icon in the Core's dashboard (a PNG, up to 1 MB) |
In `docker-compose.yml.in` and `env.in`, the Core replaces, once at install:
That's all an app has. The Core's side (the container on the Core's `core`
network, the traefik route to `https://{{NAME}}.<domain>`, its settings and
secrets, its database or sign-in client) is made by coreapp-dev's installer,
`coreapps`, from `coreapp.toml`. The app can't run scripts on the Core.
- `@DOMAIN@`: the Core's domain, and any other variable in `/etc/federated`
- `@VERSION@`, `@CONTAINER@`, `@INTERNAL_IP@`: from `service`
- `@SECRET:RANDOM:LLLLLLLL@`: a random value (`L` a letter or digit, `a`
lowercase, `A` uppercase, `0` a digit, `x` hex), also available as
`@SECRET@` further down
## What the app gets
`${...}` is left for Docker Compose, which reads it from `.env`.
Its environment (the `.env` file on the Core, made once at install; updates
keep its values and add new ones):
Raise `VERSION` in `service` for each release. The Core's nightly upgrade
only redeploys an app when `VERSION` differs from `IMAGE_VERSION` in its
`.env`.
| Variable | Value |
|---|---|
| `APP_URL` | `https://{{NAME}}.<domain>` |
| `APP_SECRET` | A random secret, for signing cookies and such |
| `IMAGE_VERSION` | The version that's installed |
`needs = ["postgres"]` adds `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER` and
`DB_PASSWORD`; `needs = ["sso"]` adds `OIDC_ISSUER`, `OIDC_CLIENT_ID` and
`OIDC_CLIENT_SECRET`.
Its files: `/data` in the container is kept on the Core
(`/federated/apps/{{NAME}}/data`) across updates and restarts.
The app serves plain HTTP on its `port`; traefik on the Core handles HTTPS
and the certificate.
Raise `version` in `coreapp.toml` for each release.
+23
View File
@@ -0,0 +1,23 @@
# What a Federated Core needs to know to install {{TITLE}}. coreapp-dev's
# installer (coreapps) makes the rest from it: the container on the Core's
# network, https://{{NAME}}.<domain>, its settings and secrets.
# Its id and hostname: https://{{NAME}}.<domain>
name = "{{NAME}}"
title = "{{TITLE}}"
description = "{{TITLE}}, made with coreapp-dev"
# docs = "https://..."
# The image, as image:version. localhost/... images only exist where
# coreapp deploy copies them; a published app names its registry, e.g.
# gitea.example.com/owner/{{NAME}}. Raise the version for each release.
image = "localhost/coreapp/{{NAME}}"
version = "0.1.0"
# The port the app serves HTTP on, and a path that answers when it's up
port = 8080
health = "/"
# What it needs from the Core: "postgres" (its own database), "sso"
# (sign-in with Core accounts through Authelia)
needs = []
-23
View File
@@ -1,23 +0,0 @@
services:
{{NAME}}:
image: coreapp/{{NAME}}:${IMAGE_VERSION}
container_name: {{NAME}}
hostname: {{NAME}}.@DOMAIN@
restart: always
networks:
core:
ipv4_address: {{IP}}
env_file:
- ./.env
volumes:
- ./data:/data
labels:
- "traefik.enable=true"
- "traefik.http.routers.{{NAME}}.rule=Host(`{{NAME}}.@DOMAIN@`)"
- "traefik.http.routers.{{NAME}}.entrypoints=websecure"
- "traefik.http.routers.{{NAME}}.tls.certresolver=letsencrypt"
- "traefik.http.services.{{NAME}}.loadbalancer.server.port=8080"
networks:
core:
external: true
-5
View File
@@ -1,5 +0,0 @@
# Filled in once, when the app is installed (see README.md). Redeploying
# keeps the result, so secrets don't change.
IMAGE_VERSION=@VERSION@
APP_URL=https://{{NAME}}.@DOMAIN@
APP_SECRET=@APP_SECRET:RANDOM:LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL@
-7
View File
@@ -1,7 +0,0 @@
. /federated/lib/helpers.sh
# Values the templates can use besides /etc/federated's and service's:
# @TRAEFIK_IP@, traefik's address on the core network
TRAEFIK_IP="$(sed -n 's/^INTERNAL_IP=//p' /federated/services/traefik/service)"
installGeneric {{NAME}}
# .env holds secrets
chmod 600 /federated/apps/{{NAME}}/.env
-9
View File
@@ -1,9 +0,0 @@
NAME="{{TITLE}}"
DESCRIPTION="{{TITLE}}, made with coreapp-dev"
DOCS=
CONTAINER=coreapp/{{NAME}}
VERSION=0.1.0
INTERNAL_IP={{IP}}
DEPENDS=""
PORTS=8080
MONITOR="https://{{NAME}}.@DOMAIN@|http_2xx"
-4
View File
@@ -1,4 +0,0 @@
# Sourced by the Core's uninstallapp (so no `exit` here): stop the app and
# delete its settings and data
docker compose -f /federated/apps/{{NAME}}/docker-compose.yml -p {{NAME}} down
rm -rf /federated/apps/{{NAME}}
+3 -3
View File
@@ -1,6 +1,6 @@
# The app's image. coreapp deploy builds it as coreapp/{{NAME}}:<VERSION>
# and copies it to the Core. Replace this with your own app; keep it
# listening on the port in docker-compose.yml.in (8080).
# The app's image. coreapp deploy builds it as image:version (from
# coreapp.toml) and copies it to the Core. Replace this with your own app;
# keep it listening on the port in coreapp.toml (8080).
FROM python:3.13-slim
RUN pip install --no-cache-dir "psycopg[binary]==3.2.*"
COPY app.py oidc.py /app/
-1
View File
@@ -1 +0,0 @@
postgresql
+1
View File
@@ -0,0 +1 @@
postgres
+3 -3
View File
@@ -1,6 +1,6 @@
# The app's image. coreapp deploy builds it as coreapp/{{NAME}}:<VERSION>
# and copies it to the Core. Replace this with your own app; keep it
# listening on the port in docker-compose.yml.in (8080).
# The app's image. coreapp deploy builds it as image:version (from
# coreapp.toml) and copies it to the Core. Replace this with your own app;
# keep it listening on the port in coreapp.toml (8080).
FROM python:3.13-slim
RUN pip install --no-cache-dir "psycopg[binary]==3.2.*"
COPY app.py /app/app.py
+5 -5
View File
@@ -1,12 +1,12 @@
## Database
The app has its own database on the Core's shared PostgreSQL
(`DEPENDS="postgresql"` in `service`):
`needs = ["postgres"]`: the app has its own database on the Core's shared
PostgreSQL.
- `install` creates the user and database `{{DBNAME}}`, with the random
`DB_PASSWORD` from `.env`; `uninstall` drops both (`coreapp remove`
deletes the data).
- At install, the user and database `{{DBNAME}}` are created, with the
random `DB_PASSWORD` from `.env`. `coreapp remove` drops both, with the
data.
- The app reads `DB_HOST` (`postgresql.<domain>`, which only resolves on the
Core's `core` network), `DB_PORT`, `DB_NAME`, `DB_USER` and `DB_PASSWORD`
from its environment. `app.py` shows how, with `psycopg`.
-6
View File
@@ -1,6 +0,0 @@
# Its database on the Core's PostgreSQL, made by install
DB_HOST=postgresql.@DOMAIN@
DB_PORT=5432
DB_NAME={{DBNAME}}
DB_USER={{DBNAME}}
DB_PASSWORD=@DB_PASSWORD:RANDOM:LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL@
-14
View File
@@ -1,14 +0,0 @@
# Its own database and user on the Core's PostgreSQL (DEPENDS=postgresql),
# with the password from .env. Safe to run again: an existing user gets the
# password, an existing database is kept.
DB_PASSWORD="$(sed -n 's/^DB_PASSWORD=//p' /federated/apps/{{NAME}}/.env)"
if docker exec postgresql psql -U postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname = '{{DBNAME}}'" | grep -q 1; then
docker exec postgresql psql -U postgres -qc "ALTER USER {{DBNAME}} WITH PASSWORD '$DB_PASSWORD'"
else
docker exec postgresql psql -U postgres -qc "CREATE USER {{DBNAME}} WITH PASSWORD '$DB_PASSWORD'"
fi
if ! docker exec postgresql psql -U postgres -tAc "SELECT 1 FROM pg_database WHERE datname = '{{DBNAME}}'" | grep -q 1; then
docker exec postgresql psql -U postgres -qc "CREATE DATABASE {{DBNAME}} OWNER {{DBNAME}}"
fi
unset DB_PASSWORD
-3
View File
@@ -1,3 +0,0 @@
# ...and its database
docker exec postgresql psql -U postgres -qc "DROP DATABASE IF EXISTS {{DBNAME}}"
docker exec postgresql psql -U postgres -qc "DROP USER IF EXISTS {{DBNAME}}"
-1
View File
@@ -1 +0,0 @@
authelia
+1
View File
@@ -0,0 +1 @@
sso
+3 -3
View File
@@ -1,6 +1,6 @@
# The app's image. coreapp deploy builds it as coreapp/{{NAME}}:<VERSION>
# and copies it to the Core. Replace this with your own app; keep it
# listening on the port in docker-compose.yml.in (8080).
# The app's image. coreapp deploy builds it as image:version (from
# coreapp.toml) and copies it to the Core. Replace this with your own app;
# keep it listening on the port in coreapp.toml (8080).
FROM python:3.13-slim
COPY app.py oidc.py /app/
USER nobody
+8 -13
View File
@@ -1,20 +1,15 @@
## Sign-in
People sign in with their Core account, through the Core's Authelia
(OpenID Connect, authorization code flow with PKCE):
`needs = ["sso"]`: people sign in with their Core account, through the
Core's Authelia (OpenID Connect, authorization code flow with PKCE).
- `install` registers the client `coreapp-{{NAME}}` in Authelia's
`idproviders.yml` (between `### coreapp-{{NAME}} begin/end` markers), with
the random `OIDC_CLIENT_SECRET` from `.env`, hashed. It checks Authelia's
configuration before restarting it and puts the old one back if the check
fails. `uninstall` removes the client.
- Its redirect URI is `https://{{NAME}}.<domain>/auth/callback`. Change it in
`install` if your app uses another path.
- Authelia decides whether a second factor is needed (the Core's 2FA policy
is applied to every client after each install).
- The app reaches `https://authelia.<domain>` through traefik
(`extra_hosts` in `docker-compose.yml.in`).
- At install, the client `coreapp-{{NAME}}` is registered in Authelia, with
the random `OIDC_CLIENT_SECRET` from `.env`. `coreapp remove` removes it.
- Its redirect URI is `https://{{NAME}}.<domain>/auth/callback`, so the app
has to handle that path.
- Authelia decides whether a second factor is needed (the Core's 2FA
policy).
- `oidc.py` does the whole flow with Python's standard library, and `app.py`
uses it for `/login`, `/auth/callback` and `/logout`. For a real app, use
your framework's OpenID Connect library with `OIDC_ISSUER`,
-27
View File
@@ -1,27 +0,0 @@
services:
{{NAME}}:
image: coreapp/{{NAME}}:${IMAGE_VERSION}
container_name: {{NAME}}
hostname: {{NAME}}.@DOMAIN@
restart: always
networks:
core:
ipv4_address: {{IP}}
# Reach Authelia's https address through traefik on the core network
# (inside it, authelia.@DOMAIN@ is Authelia's own plain-http container)
extra_hosts:
- "authelia.@DOMAIN@:@TRAEFIK_IP@"
env_file:
- ./.env
volumes:
- ./data:/data
labels:
- "traefik.enable=true"
- "traefik.http.routers.{{NAME}}.rule=Host(`{{NAME}}.@DOMAIN@`)"
- "traefik.http.routers.{{NAME}}.entrypoints=websecure"
- "traefik.http.routers.{{NAME}}.tls.certresolver=letsencrypt"
- "traefik.http.services.{{NAME}}.loadbalancer.server.port=8080"
networks:
core:
external: true
-5
View File
@@ -1,5 +0,0 @@
# Sign-in through the Core's Authelia (OpenID Connect); install registers
# the client
OIDC_ISSUER=https://authelia.@DOMAIN@
OIDC_CLIENT_ID=coreapp-{{NAME}}
OIDC_CLIENT_SECRET=@OIDC_CLIENT_SECRET:RANDOM:LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL@
-43
View File
@@ -1,43 +0,0 @@
# Register it with the Core's Authelia as an OpenID Connect client, with the
# secret from .env (hashed), between markers so uninstall can remove it.
# Safe to run again. Authelia is checked with the new client before it
# restarts; if the check fails, its old configuration is put back.
IDP=/federated/apps/authelia/data/config/idproviders.yml
OIDC_CLIENT_SECRET="$(sed -n 's/^OIDC_CLIENT_SECRET=//p' /federated/apps/{{NAME}}/.env)"
OIDC_HASH="$(docker exec authelia authelia crypto hash generate pbkdf2 --password "$OIDC_CLIENT_SECRET" | awk '/Digest:/ {print $2}')"
cp -p "$IDP" "$IDP.coreapp-{{NAME}}.bak"
sed -i '/^ ### coreapp-{{NAME}} begin$/,/^ ### coreapp-{{NAME}} end$/d' "$IDP"
cat >> "$IDP" <<OIDC
### coreapp-{{NAME}} begin
- client_id: 'coreapp-{{NAME}}'
client_name: '{{TITLE}}'
client_secret: '$OIDC_HASH'
consent_mode: 'implicit'
public: false
authorization_policy: 'one_factor'
require_pkce: true
pkce_challenge_method: 'S256'
redirect_uris:
- 'https://{{NAME}}.$DOMAIN/auth/callback'
scopes:
- 'openid'
- 'profile'
- 'email'
- 'groups'
response_types:
- 'code'
grant_types:
- 'authorization_code'
token_endpoint_auth_method: 'client_secret_basic'
userinfo_signed_response_alg: 'none'
### coreapp-{{NAME}} end
OIDC
if docker exec authelia authelia validate-config > /dev/null 2>&1; then
rm -f "$IDP.coreapp-{{NAME}}.bak"
restart_service authelia
else
echo "Authelia rejected the new client; left its configuration as it was." >&2
mv "$IDP.coreapp-{{NAME}}.bak" "$IDP"
fi
unset IDP OIDC_CLIENT_SECRET OIDC_HASH
-4
View File
@@ -1,4 +0,0 @@
# ...and its Authelia client
sed -i '/^ ### coreapp-{{NAME}} begin$/,/^ ### coreapp-{{NAME}} end$/d' \
/federated/apps/authelia/data/config/idproviders.yml
restart_service authelia