Files
coreapp-dev/README.md
T
davidandClaude Opus 5.5 284f52fc29 coreapp new --sso: sign-in through the Core's Authelia
A template overlay (templates/sso) registers the app as an OpenID Connect
client in Authelia's idproviders.yml (between markers, secret hashed by
the running Authelia), checks the configuration before restarting
Authelia and restores it if the check fails; uninstall removes the client.
The app reaches Authelia's https address through traefik (@TRAEFIK_IP@,
provided by the template's install and by redeploys). The example is a
standard-library Python OIDC client (code flow with PKCE). Tested by
install, redeploy, remove and reinstall, and a real sign-in in a browser.

Also: the postgres overlay appends to the base install, uninstall and
env.in; database names get a coreapp_ prefix (PostgreSQL reserves pg_*);
deploy waits until the app answers on its own address.

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

116 lines
4.9 KiB
Markdown

# coreapp-dev
A software development kit for building apps that run as Docker containers on
[Federated Core](https://documentation.federated.computer/self-hosted/cores/provisioning-a-core/).
It runs a real Core in a KVM virtual machine on your own computer, so you can
build and test apps against it.
It's a CoreDesktop sibling project: CoreDesktop installs it and keeps it up to
date.
## Install
On a CoreDesktop computer with hardware virtualization (VT-x/AMD-V) turned on:
```
sibling add https://gitea.federated.computer/Federated_Computer/coreapp-dev.git
```
This installs libvirt and QEMU/KVM, adds you to the `libvirt` group (log out
and back in afterwards), sets up the `coreapp` VM network (10.123.0.0/24) and
installs Docker and the `coreapp-vm` and `coreapp` commands. CoreDesktop's `update` keeps them current.
## A Core in a VM
1. Put the SSH public key from Federated's dashboard (Cores) in
`~/.config/coreapp-dev/authorized_keys`, so the Provisioner can log in.
2. Create the VM:
```
coreapp-vm create
```
The first time, it downloads the CoreServer image (1.3 GB) to
`~/.local/share/coreapp-dev/images/`. The VM is called `coreserver` and
gets 10.123.0.10.
3. Log in with `coreapp-vm ssh`, or run a command on it:
`coreapp-vm ssh docker ps`.
4. Federated's Provisioner has to reach the VM over SSH, and the Core must be
reachable from the internet. Behind a home router, use
[corerelay](https://gitea.federated.computer/Federated_Computer/corerelay)
to give it a VPS's public IP.
5. Provision the Core with `core-create`
([Provisioning a Core](https://documentation.federated.computer/self-hosted/cores/provisioning-a-core/)),
with the public IP as `ip`.
## Make an app
```
coreapp new my-app # makes ./my-app from the template
cd my-app
coreapp deploy # build, copy to the Core, install (or update)
coreapp check # https://my-app.<domain>/ answers, valid certificate
```
An app is a folder in the format Federated Core installs apps from
(`/federated/services/<app>/` on the Core): `service`,
`docker-compose.yml.in`, `env.in`, `install`, `uninstall`, `icon.png`, plus
the app's own `Dockerfile`. The README in each new app explains the files.
| Command | Does |
|---|---|
| `coreapp new <name>` | Make an app in `./<name>`; it gets an address in 192.168.200.x on the Core |
| `coreapp new --postgres <name>` | The same, with its own database on the Core's PostgreSQL (a Python example app that uses it) |
| `coreapp new --sso <name>` | The same, with sign-in through the Core's Authelia (OpenID Connect; a Python example app) |
| `coreapp deploy` | Build its image, copy it to the Core over SSH, install it, or update it keeping its `.env` |
| `coreapp check` | It answers at its `MONITOR` URL with a valid certificate |
| `coreapp status` / `logs [-f]` / `shell` | Its container, its log, a shell in it |
| `coreapp remove` | Uninstall it from the Core (asks first) |
`COREAPP_VM` picks the VM (default `coreserver`).
Installing and removing an app go through the Core's own `installapp` and
`uninstallapp`. Those would also add its `MONITOR` URL to Federated's
external monitoring, so `coreapp deploy` copies `service` to the Core without
the `MONITOR` line: apps in development aren't monitored. `coreapp check`
uses the line from your folder.
## VM commands
| Command | Does |
|---|---|
| `coreapp-vm create [name]` | Create a VM (downloads the image if it's missing) |
| `coreapp-vm list` | VMs, their state and address |
| `coreapp-vm ip [name]` | A VM's address |
| `coreapp-vm ssh [name] [cmd]` | Log in as root, or run a command |
| `coreapp-vm start` / `stop [name]` | Start / shut down |
| `coreapp-vm delete [name]` | Delete a VM and its disk (asks first) |
`name` defaults to `coreserver`. Before deleting a VM that has a Core on it,
delete the Core in Federated's dashboard, or at least before putting another
VM behind the same public IP: deleting a Core makes Federated log in to its
IP and tear down whatever it finds there.
## Uninstall
`sibling remove` only deletes the clone, so first run
```
bash ~/.local/share/siblings/coreapp-dev/uninstall.sh
```
It removes `coreapp-vm`, the `coreapp` network and its firewall rules, and
asks before deleting VMs, the downloaded image and your keys. libvirt and QEMU
stay installed.
## Files
| Path | What it is |
|---|---|
| `install.sh`, `update.sh` | Run by CoreDesktop's `sibling add` and `update` |
| `libvirt/network-hook.sh` | NAT and firewall rules for the `coreapp` network |
| `bin/coreapp-vm` | Creates and manages CoreServer VMs (`coreapp-vm help`) |
| `bin/coreapp` | Makes, deploys and tests apps (`coreapp help`) |
| `templates/app/` | What `coreapp new` starts from |
| `templates/postgres/`, `templates/sso/` | Laid over it by `--postgres` / `--sso` (`*.append` files are added to the base file; `.remove` lists base files to drop) |
| `uninstall.sh` | Removes what coreapp-dev set up |
| [PLAN.md](PLAN.md), [TEST.md](TEST.md) | What's next, and how to test it |