coreapp: make, deploy and test apps on the Core in the VM
Apps are folders in Federated Core's generic services format (service, docker-compose.yml.in, env.in, install, uninstall, icon.png) plus their own Dockerfile. coreapp new scaffolds one from templates/app with an address in 192.168.200.x; deploy builds the image, copies it to the Core over SSH, installs it with installapp (and starts it, since the Core's start only knows its own apps) or updates it keeping .env; check, status, logs, shell and remove work on the Core. Apps in development aren't registered with Federated's monitoring: deploy drops MONITOR from the Core's copy of service. installapp/uninstallapp traces go to private logs, not the terminal. update.sh installs docker and docker-buildx and links coreapp into ~/.local/bin. PLAN.md: how the Core runs apps, and corrected evidence for the Core's timers running their jobs at every boot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
.git
|
||||
service
|
||||
*.in
|
||||
install
|
||||
uninstall
|
||||
icon.png
|
||||
README.md
|
||||
@@ -0,0 +1,7 @@
|
||||
# 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).
|
||||
FROM busybox:stable
|
||||
COPY www /www
|
||||
EXPOSE 8080
|
||||
CMD ["httpd", "-f", "-v", "-p", "8080", "-h", "/www"]
|
||||
@@ -0,0 +1,45 @@
|
||||
# {{TITLE}}
|
||||
|
||||
An app for Federated Core, made with
|
||||
[coreapp-dev](https://gitea.federated.computer/Federated_Computer/coreapp-dev).
|
||||
|
||||
## Develop
|
||||
|
||||
Change the app (`Dockerfile`, `www/`), then, in this folder:
|
||||
|
||||
```
|
||||
coreapp deploy # build the image, copy it to the Core in your VM, install or update
|
||||
coreapp check # https://{{NAME}}.<domain>/ answers, with a valid certificate
|
||||
coreapp logs -f # its log
|
||||
coreapp status # its container, address and URL
|
||||
coreapp shell # a shell in its container
|
||||
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) |
|
||||
|
||||
In `docker-compose.yml.in` and `env.in`, the Core replaces, once at install:
|
||||
|
||||
- `@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
|
||||
|
||||
`${...}` is left for Docker Compose, which reads it from `.env`.
|
||||
|
||||
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`.
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
@@ -0,0 +1,5 @@
|
||||
# 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@
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 566 B |
Executable
+4
@@ -0,0 +1,4 @@
|
||||
. /federated/lib/helpers.sh
|
||||
installGeneric {{NAME}}
|
||||
# .env holds secrets
|
||||
chmod 600 /federated/apps/{{NAME}}/.env
|
||||
@@ -0,0 +1,9 @@
|
||||
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"
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
# 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}}
|
||||
@@ -0,0 +1,8 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head><meta charset="utf-8"><title>{{TITLE}}</title></head>
|
||||
<body>
|
||||
<h1>{{TITLE}}</h1>
|
||||
<p>Running on Federated Core, deployed with coreapp-dev.</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user