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:
@@ -1 +0,0 @@
|
||||
postgresql
|
||||
@@ -0,0 +1 @@
|
||||
postgres
|
||||
@@ -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
|
||||
|
||||
@@ -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`.
|
||||
|
||||
@@ -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@
|
||||
@@ -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
|
||||
@@ -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}}"
|
||||
Reference in New Issue
Block a user