Files
coreapp-dev/README.md
T
davidandClaude Opus 5.5 bef3b86970 Install apps from their repository, including private ones
coreapps plan|install <https://host/owner/repo>[@tag] reads only
coreapp.toml and icon.png at the tag's commit (depth 1, blobs on demand,
regular files only), with git limited to https and no prompts or system
settings. The default tag is the newest numeric release; version must
match the tag; the image is always pulled. The marker records source,
tag and commit; the same name from another repository is refused.
coreapps update <name> moves to the newest release. On the workstation:
coreapp install <url> (shows the app and its needs, asks) and update.

Private apps: coreapps login <host> <user> keeps a read-only token (from
stdin) in /etc/coreapps/credentials (root only), checked with the host's
registry first. git gets it as an extraHeader for that host only, docker
in a config made for each pull. coreapp login/logout/logins on the
workstation. Tested with a private repository and package on Federated's
Gitea.

Fixed: old images of docker.io/library/... weren't deleted (docker lists
them by short name); remove force-deleted images another app could use;
coreapp help cut off multi-line descriptions.

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

163 lines
8.4 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, the `coreapp-vm` and `coreapp` commands, and the `coreapp`
skill for Claude Code. 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 (its own git repository) with a `coreapp.toml`, a
`Dockerfile`, the app's code and an `icon.png`:
```toml
name = "my-app" # https://my-app.<domain>
title = "My App"
image = "localhost/coreapp/my-app" # where the Core gets the image
version = "0.1.0"
port = 8080 # the port it serves HTTP on
health = "/" # a path that answers when it's up
needs = ["postgres", "sso"] # its own database; sign-in with Core accounts
```
The app has no scripts or compose file: the Core side is made by
coreapp-dev's installer, `coreapps` (`core/` here, `/opt/coreapps` on the
Core). It checks `coreapp.toml`, picks a free address on that Core, writes
the app in the Core's generic format (`/federated/services/<name>/`), and
sets up what it needs: the traefik route and certificate, its settings and
secrets, its database, its Authelia client. So what an app can do on a Core
is decided by the installer, not by whoever wrote the app. The README in
each new app explains the files and the settings it gets.
| Command | Does |
|---|---|
| `coreapp new <name>` | Make an app in `./<name>` |
| `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 new --postgres --sso <name>` | Both: a database and sign-in (the example counts each person's visits) |
| `coreapp deploy [--recreate]` | Build its image, copy it to the Core over SSH, install it, or update it keeping its settings and data (`--recreate`: a fresh container even if nothing changed) |
| `coreapp check` | It answers at `https://<name>.<domain><health>` with a valid certificate |
| `coreapp status` / `logs [-f]` / `shell [command]` | Its container, its log, a shell in it (or one command, without a terminal) |
| `coreapp list` | The apps on the Core installed this way |
| `coreapp install <https://host/owner/repo>[@tag]` | Install a published app from its repository on the Core, as its owner would: shows what it is and needs, asks, then installs (default: the newest release tag) |
| `coreapp update <name>` | Update an app installed from a repository to its newest release |
| `coreapp login <host>` / `logout <host>` / `logins` | Give the Core a token for private apps from a host (asks for the user and token), forget it, list them |
| `coreapp publish [--platform <list>]` | Build the release image, push it to the registry in `coreapp.toml` (`image:version`, never replacing a published version) and tag the commit `v<version>` |
| `coreapp remove` | Uninstall it from the Core, with its database and sign-in client (asks first) |
`COREAPP_VM` picks the VM (default `coreserver`).
To publish, set `image` to your registry (for Gitea,
`<gitea-host>/<owner>/<repo>`), `docker login` to it once, commit, and run
`coreapp publish`. New apps also have a Gitea Actions workflow
(`.gitea/workflows/publish.yml`) that does the same when a `v*` tag is
pushed, for repositories with a runner that can use Docker.
A published app installs on any Core from its repository: `coreapp install
https://gitea.example.com/owner/app` runs the installer there with the URL.
It reads only `coreapp.toml` and `icon.png` at the newest release tag
(`v1.2.3`; or name one with `@v1.2.3`), checks that the tag matches
`version`, and pulls the image from its registry. The repository and the
image can be private: `coreapp login gitea.example.com` gives the Core a
token for that host (for Gitea, one with read access to repositories and
packages), which the installer uses for the repository and the image. It
keeps tokens in `/etc/coreapps/credentials` on the Core (root only); docker
gets the token only for each pull, so the Core keeps no docker login. This
is what Superpanel's Coreapps screen would do.
Installing and removing go through the Core's own `installapp` and
`uninstallapp`, so the app shows up in Superpanel. The installer gives apps
no `MONITOR` line, so they aren't added to Federated's external monitoring.
The Core's scripts print secrets in their traces; their output is kept in
`/federated/logs/coreapps/` on the Core.
## 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`) |
| `core/coreapps` | The installer that runs on the Core (`coreapps help`) |
| `core/templates/` | The Core's generic app files it makes from `coreapp.toml` |
| `core/needs/<need>/` | What each need adds: `env.in` (settings), `setup` and `teardown` (run on the Core), `depends` (the Core app it uses), `compose` (added to the container) |
| `templates/app/` | What `coreapp new` starts from |
| `templates/postgres/`, `templates/sso/` | Example apps laid over it by `--postgres` / `--sso`: their files replace the base's; `*.append` files are added to the base file, `.remove` lists base files to drop, `.needs` goes into `needs` |
| `templates/postgres-sso/` | The example app when both are used |
| `skills/coreapp/` | A Claude Code skill for making apps; `update.sh` links it into `~/.claude/skills/` |
| `uninstall.sh` | Removes what coreapp-dev set up |
| [PLAN.md](PLAN.md), [TEST.md](TEST.md) | What's next, and how to test it |