coreapp new --postgres: apps with their own database
A template overlay (templates/postgres) adds DEPENDS="postgresql", DB_* settings with a random password, an install that creates the user and database on the Core's PostgreSQL (safe to re-run), an uninstall that drops them, and a Python example that counts visits. Tested with a throwaway app: deploy, redeploy and a reboot of the Core keep the data, remove drops the database and user. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -169,3 +169,18 @@ no `blackboxregistrar` request.
|
||||
`~/.local/share/coreapp-dev/logs/hello-remove.log` (mode 600).
|
||||
7. Collisions: an app named like one of Federated's (`coreapp new nextcloud`,
|
||||
deploy) is refused; so is an `INTERNAL_IP` another container uses.
|
||||
|
||||
### With a database
|
||||
|
||||
1. `coreapp new --postgres guest-book`: has `app.py`, no `www/`;
|
||||
`service` has `DEPENDS="postgresql"`; `env.in` has `DB_NAME=guest_book`
|
||||
and a random `DB_PASSWORD`; the README has a Database section.
|
||||
2. `coreapp deploy`, `coreapp check`. Loading the page several times
|
||||
(`curl -s https://guest-book.<domain>/ | grep visits`) counts up. On the
|
||||
Core, `docker exec postgresql psql -U postgres -l` lists `guest_book`,
|
||||
owned by `guest_book`.
|
||||
3. Change `app.py`, `coreapp deploy`: the change shows, the count continues.
|
||||
4. `virsh -c qemu:///system reboot coreserver`: once the Core is up, the
|
||||
app answers and the count continues (its log may show "Waiting for the
|
||||
database" first).
|
||||
5. `coreapp remove`: the `guest_book` database and user are gone too.
|
||||
|
||||
Reference in New Issue
Block a user