Files
coreapp-dev/skills/coreapp/SKILL.md
T
davidandClaude Opus 5.5 89585e81aa Apps get 192.168.5.0/24; keep a copy of each Authelia client
Addresses now come from 192.168.5.0/24, the range Federated's Core
developer set aside for custom apps. Apps installed in 192.168.200.x get
a new address on their next update.

Like Federated's apps, the sso need keeps a copy of its Authelia client in
/federated/apps/<name>/.<name>.oidc-client.yml, so Authelia's start
(reconcile_authelia_sso) restores it if Authelia is reinstalled. Removing
an app deletes the copy before restarting Authelia, which would otherwise
add the client back. Needs can have an update step, run on every update;
sso's writes the copy for apps installed before this.

Fixed: an update of an app with no needs failed at its end (a test that
found nothing to run set the exit status), leaving the app on its old
address.

PLAN.md: the Core developer's guidance and where coreapp-dev stands on
each point.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 14:10:43 -07:00

13 KiB

name, description
name description
coreapp Build, port and test apps ("Coreapps") for Federated Core with coreapp-dev. Use this whenever someone wants to make an app run on a Federated Core, package an existing web app or repository for a Core, write or fix a coreapp.toml, give an app sign-in with Core accounts (Authelia) or a database on the Core's PostgreSQL, or deploy and test an app on the Core in the local coreapp-dev VM (coreapp deploy, coreapp check), even if they just say "make this work on our Core" or "Coreapp".

Making apps for Federated Core

A Federated Core is a self-hosted server that runs many apps as Docker containers behind one domain. A Coreapp is an app anyone can publish and a Core's owner can install. coreapp-dev is the kit for making them: it runs a real Core in a VM on this computer, and the coreapp command deploys the app you're working on to it.

How a Coreapp works

An app is a repository with:

File What it is
coreapp.toml What the Core needs to know (below)
Dockerfile Builds the app's image
the app's code Whatever the Dockerfile uses
icon.png Its icon in the Core's dashboard (PNG, up to 1 MB; optional)

That's all. The app has no scripts and no compose file: a trusted installer on the Core (coreapps) reads coreapp.toml and makes the rest: the container on the Core's network, the HTTPS route and certificate for https://<name>.<domain>, the app's settings and secrets, and whatever it needs (its database, its sign-in client). This is deliberate: a Core installs apps from other people's repositories, so an app gets to declare what it needs, never to run commands on the Core. Don't try to get around it (SSHing into the Core to edit files, adding scripts the Core should run): whatever you change by hand there is lost on the next deploy and won't exist on anyone else's Core.

What the Core gives every app:

  • One container, from the app's image, serving plain HTTP on one port. Traefik on the Core terminates HTTPS at https://<name>.<domain> and forwards to that port.

  • /data inside the container: kept on the Core across updates, restarts and reboots. The Core makes it belong to the user the image runs as (USER in the Dockerfile) before starting the container, so the image doesn't need to create or chown /data itself (what the image has at /data is hidden by the mount anyway). Everything else in the container is thrown away on each update, so anything the app must keep (uploads, SQLite files, generated keys) goes under /data.

  • Environment variables (from a .env file made once at install; updates keep the values and add new ones):

    Variable Value
    APP_URL https://<name>.<domain>, the app's public address
    APP_SECRET 32 random letters and digits, for signing cookies, sessions
    IMAGE_VERSION The installed version

    plus the ones each need adds (below).

coreapp.toml

name = "my-app"                      # id and hostname: https://my-app.<domain>
title = "My App"                     # shown in the Core's dashboard
description = "What it does, in a sentence"
docs = "https://example.com/docs"    # optional
image = "localhost/coreapp/my-app"   # image name; the Core runs image:version
version = "0.1.0"                    # the image tag; raise it for each release
port = 8080                          # the port the app serves HTTP on (any; 8080 is usual)
health = "/health"                   # a path that answers once it's up
needs = ["postgres", "sso"]          # what it needs from the Core, or []

The installer is strict, because these values end up in files on the Core that are read by shell and YAML:

  • name: 2-31 lowercase letters, digits and -, starting with a letter, not ending with -. Names of Federated's own apps (nextcloud, gitea, ...) and the Core's hostnames (www, mail, ...) are refused.
  • title: up to 40 letters, digits, spaces and . , ! ? ( ) & + _ -.
  • description: up to 200 characters, no ", $, backtick, \, @ or line breaks.
  • image: must start with its registry. While developing, use localhost/coreapp/<name>: coreapp deploy builds it here and copies it to the Core, and it can't be pulled from anywhere by mistake. (A name without a registry, like me/app, would mean Docker Hub, so it's refused.)
  • version: letters, digits, ., _, -.
  • port: a number, not a string. Use whatever port the app already listens on; for a new app, 8080. It's only reachable inside the Core.
  • health: a path starting with /. Deploy waits until it answers with any status below 500 (so / is fine for an app without a health endpoint, even if it redirects to a sign-in page); coreapp check wants a 2xx there, so prefer a path that returns 200 without signing in.
  • Unknown settings are refused, so a typo doesn't go unnoticed.

coreapp deploy checks the file first and says exactly what's wrong.

Needs

postgres: its own database

The Core makes a PostgreSQL user and database just for this app, and adds:

Variable Value
DB_HOST postgresql.<domain> (resolves only on the Core's network, which the app is on)
DB_PORT 5432
DB_NAME, DB_USER coreapp_<name> with - as _ (e.g. coreapp_my_app)
DB_PASSWORD random

The server is PostgreSQL shared with the Core's other apps; the app owns its database and nothing else. There's no superuser access, so the app creates its own tables (migrations at startup are the usual way). At boot the database may come up after the app: retry the connection instead of exiting. Many apps want a URL; build it from these variables in the entrypoint or the app's config (e.g. postgresql://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME).

sso: sign-in with Core accounts

The Core registers the app as an OpenID Connect client with its Authelia, and adds:

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

The client is fixed, so the app has to fit it:

  • Redirect URI: exactly https://<name>.<domain>/auth/callback ($APP_URL/auth/callback). If the app's library uses another callback path, configure the library, or route /auth/callback to it.
  • Authorization code flow, PKCE with S256 required, client authentication client_secret_basic (secret in the Authorization header).
  • Scopes: openid profile email groups. Userinfo gives sub, preferred_username, name, email, groups (the person's Core groups: use them for roles, e.g. admins).
  • Discovery: $OIDC_ISSUER/.well-known/openid-configuration. The Core routes authelia.<domain> from inside the app's container to the real HTTPS endpoint, with a valid certificate, so normal TLS verification works.
  • Sign-out in the app ends the app's session; the person stays signed in to the Core.

Use the app's own OpenID Connect support or its framework's library where it has one: most self-hosted apps have "generic OIDC" settings that map onto these variables. For a standard-library Python example of the whole flow, coreapp new --sso example makes one (oidc.py).

Not available yet

Email (sending mail through the Core), the Core's AI features (offering tools to its AI agent, or using its model), extra services such as Redis or a second container, extra hostnames, and public ports other than HTTPS. If the app can't work without one of these, say so plainly in your report rather than working around it; the gap is useful to know. If it's optional (e.g. email notifications), leave it off and note it.

Workflow

1. Check the tools

command -v coreapp && coreapp-vm list

coreapp-vm list should show the VM coreserver running. If coreapp is missing or the VM isn't running, stop and tell the user: setting those up (installing coreapp-dev, creating and provisioning the Core) is theirs to do (coreapp-vm start only starts an existing VM).

2a. A new app

coreapp new my-app                    # plain (a static page on busybox)
coreapp new --postgres my-app         # with a database (Python example)
coreapp new --sso my-app              # with sign-in (Python example)
coreapp new --postgres --sso my-app   # both

It makes ./my-app with a working example, coreapp.toml and a README. Replace the example with the real app.

2b. An existing app (porting)

Work in the app's repository. Add coreapp.toml (copy the example above), and make the Dockerfile fit the Core:

  • Listen on 0.0.0.0 and on port, plain HTTP. No TLS in the app.

  • Know its public address: APP_URL (many apps need a "base URL" or "trusted host" setting; it's behind a proxy that sends X-Forwarded-Proto: https and X-Forwarded-For).

  • Keep state in /data: point upload folders, SQLite files and generated keys there. If the app needs a directory structure under /data, create it at startup (it starts empty).

  • Read settings from the environment, mapping the Core's names to the app's in an entrypoint script or config file if they differ (SECRET_KEY="$APP_SECRET", DATABASE_URL=...).

  • Run as a non-root user if the image allows. /data is given to whatever user the image runs as, so this is enough:

    RUN useradd --system --uid 1000 --home-dir /data app   # Debian-based images
    USER app
    

    (adduser -S -u 1000 -h /data app on Alpine.) Many upstream images already have a user; use it.

  • Answer on health once ready (a dedicated health endpoint, or / if it returns 2xx-4xx without signing in).

  • One container. If the upstream project ships a compose file with several services, keep only the app, use needs = ["postgres"] for its database, and stop if it needs other services (see "Not available yet").

Keep the app's other files as they are; add .dockerignore entries for coreapp.toml, icon.png and .git so they don't bust the build cache.

3. Deploy and test

coreapp deploy      # check coreapp.toml, build, copy the image, install or update
coreapp check       # https://<name>.<domain><health> answers with a valid certificate

Deploying again updates the app in place: same address, same secrets, same data and database. Change something, deploy, look. A new version isn't needed for each try; raise it when you release.

A deploy only replaces the container when something changed (the image or the settings). To test that data really survives a new container, use coreapp deploy --recreate, which always starts a fresh one.

coreapp deploy may ask before installing on a Core whose plan bills apps as add-ons. That question is for the user; don't answer it yourself.

Then test it like a person would: open https://<name>.<domain>/ (curl it, or ask the user to use a browser), sign in if it has sso, and check that what it stores survives coreapp deploy --recreate (data in /data and the database). Signing in needs a real Core account and a browser: ask the user to do that step and tell you what happened.

4. When something fails

Command Shows
coreapp status Its container, address, port, needs, URL
coreapp logs / coreapp logs -f The app's own log
coreapp shell '<command>' Run one command in its container, e.g. coreapp shell 'id; env; ls -l /data' (without a command it opens an interactive shell, which needs a terminal)
coreapp list All apps on the Core installed this way
coreapp remove Uninstall it (asks first; deletes its data and database)

Common causes:

  • "doesn't answer at http://192.168.5.x:PORT/...": the app crashed (see coreapp logs), listens on another port or on 127.0.0.1, or health points at a path that fails or redirects to an error.
  • coreapp check fails but deploy worked: a new certificate can take a minute; it retries for two. It also tries the VM directly, which tells the app apart from the way in.
  • Sign-in fails with "redirect_uri" errors: the app isn't using $APP_URL/auth/callback. "invalid_client": it isn't sending the secret with client_secret_basic, or isn't using PKCE.
  • Permission denied under /data: the app switches to another user after starting (the Core gives /data to the image's USER), or it writes somewhere else in the container (coreapp shell 'id; ls -ld /data').

The installer's own log (the Core's install scripts) is on the Core in /federated/logs/coreapps/. It contains secrets, so don't print it in full; look at the end of it with coreapp-vm ssh tail -n 40 /federated/logs/coreapps/<name>-install.log only when a deploy fails in the installer itself.

Reporting back

When you're done, tell the user:

  • what you changed in the repository (coreapp.toml, Dockerfile, config),
  • what you tested and how (deploy, check, which pages, a redeploy keeping data), and what they still need to test themselves (signing in in a browser),
  • anything the app needs that the Core doesn't offer yet, and how you handled it,
  • anything in coreapp-dev that got in the way or was unclear. coreapp-dev is new, and this is how it gets better.