cms: add openbureau-core CMS (DB-less, auth: local) — vendored at cms/core

kgva can now be edited through openbureau-core instead of Decap: a small Node CMS
(git subtree at cms/core) with a schema-driven editor at /admin, file-based login
(no Supabase/Postgres), Markdown on disk. cms/kgva.config.js models the content
(portfolio/pages/sections); docker-compose builds the core image (Hugo 0.163.3,
no VITE_SUPABASE_URL → local-auth admin) and mounts the repo as the site. seed an
admin via cms/seed-admin.mjs; deploy/provision-lxc.sh + ADMIN.md updated.

Verified DB-less end-to-end on real content (staged): local login → schema-driven
editor → 42 entries (de/en) → stats → create/preview/cleanup; unknown frontmatter
(image galleries) preserved on save. The LIVE static site (CT130 timer→hugo→nginx)
is unaffected — hugo ignores cms/; the CMS is dormant until provisioned.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 01:52:49 +02:00
parent c8ee284ba6
commit 51a94b85d3
7 changed files with 139 additions and 65 deletions
+26 -58
View File
@@ -1,68 +1,36 @@
# Admin (Decap CMS)
# Admin (openbureau-core CMS)
A lightweight, git-based editor at `/admin`. It commits markdown straight to the
Gitea repo — no database, no server. The public site stays static; rebuilding it
after an edit is a separate step (see *Deploy* below).
The site is edited through **openbureau-core** — a small Node CMS (vendored at
`cms/core`) that builds the Hugo site and serves it together with an editor at
`/admin`. It is **DB-less**: file-based login (`auth: 'local'`) and Markdown on
disk. No Supabase, no Postgres.
## 1. Put the repo on Gitea
## What's where
The site must live in a Gitea repo (e.g. `git.kgva.ch/karim/kgva`). Set the same
`repo` and `branch` in `static/admin/config.yml`.
- `cms/kgva.config.js` — the content model (collections + fields) the editor renders.
- `cms/core/` — the engine (git subtree of `git.openbureau.ch/karim/openbureau-core`).
Update it with:
`git subtree pull --prefix=cms/core https://git.openbureau.ch/karim/openbureau-core.git main --squash`
- `cms/.env``JWT_SECRET` (sign-in secret) + `ADMIN_EMAILS`. Copy from `.env.example`.
- `cms/users.json` — the user store (bcrypt hashes). Git-ignored. Seed with:
`docker compose run --rm cms node /site/cms/seed-admin.mjs you@mail yourpass`
## 2. Create a Gitea OAuth app
In Gitea: **Settings → Applications → Create OAuth2 application**.
- Redirect URI: `https://<your-site>/admin/`
- Copy the **Client ID** into `static/admin/config.yml``backend.app_id`.
Decap uses PKCE, so no client secret and no auth proxy are needed.
## 3. Edit
Open `https://<your-site>/admin/`, log in with Gitea. New project:
*Portfolio → New Project*; images upload into `static/img` and are referenced as
`/img/...`. Saving commits to the repo on the configured branch.
## 4. Deploy (rebuild after an edit)
Because the site is baked into the Docker image, a commit must trigger a rebuild.
Pick one:
- **Manual:** on the host, `docker compose up -d --build`.
- **Gitea Actions** (`.gitea/workflows/deploy.yml`), sketch:
```yaml
on: { push: { branches: [main] } }
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker compose up -d --build # on a runner with access to the host
```
(Adjust to your Proxmox/LXC setup — same place OPENBUREAU deploys.)
- **Webhook:** point a Gitea webhook at a tiny script on the host that runs the
`docker compose` line.
## Local editing (no auth)
## Run
```
npx decap-server # in one terminal
# uncomment `local_backend: true` in config.yml
hugo server # in another
# open http://localhost:1313/admin/
cp cms/.env.example cms/.env # set JWT_SECRET (openssl rand -hex 32)
docker compose build
docker compose run --rm cms node /site/cms/seed-admin.mjs karim@gabrielevarano.ch <pw> # once
docker compose up -d
```
## Self-hosting the CMS bundle (optional)
Open `http://<host>:8080/admin/`, log in, edit. *Speichern* writes the Markdown,
*Vorschau* builds a draft preview, *Publizieren* rebuilds the public site.
To avoid the CDN (in the spirit of the colophon), download the bundle once and
point `static/admin/index.html` at it:
## Deploy
```
curl -L https://unpkg.com/decap-cms@^3.3.3/dist/decap-cms.js \
-o static/admin/decap-cms.js
# then in index.html: <script src="/admin/decap-cms.js"></script>
```
A single container (Hugo build + Node serve). See `deploy/`
`provision-lxc.sh` stands up an LXC and does all of the above (incl. a seeded
admin whose password lands in `cms/ADMIN_PASSWORD.txt`); `Caddyfile` terminates
TLS and reverse-proxies the domain. Safe cutover: provision a NEW container on a
temporary IP, verify, point Caddy at it, then retire the old one.