From 31b84b06d4e7ecb475eca42d80703d29d13e4f45 Mon Sep 17 00:00:00 2001 From: Adam French Date: Tue, 24 Nov 2026 16:01:23 +0000 Subject: [PATCH] Keep the pre-move Gitea in .deprecated/gitea as the rollback The old stpvm service is kept as a compose override with its state mounts pointed at .deprecated/gitea/, where the pre-move data now lives (gitignored), so rolling back is one layered 'up' rather than a revert. Co-Authored-By: Claude Opus 5.5 --- .deprecated/README.md | 25 +++++++ .deprecated/gitea/docker-compose.gitea.yml | 84 ++++++++++++++++++++++ .gitignore | 4 ++ DEPLOYMENT.md | 13 ++-- 4 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 .deprecated/gitea/docker-compose.gitea.yml diff --git a/.deprecated/README.md b/.deprecated/README.md index e1dc188..6c625b8 100644 --- a/.deprecated/README.md +++ b/.deprecated/README.md @@ -49,3 +49,28 @@ host, valid until 2027-01-20. To bring them back: revert the commit that moved them here and then `daa2a46`; DEPLOYMENT.md §7 ("Roll back to nginx") has the commands. + +## gitea/ + +Gitea as it ran inside this stack on stpvm until 2026-11-24, when it moved to +its own Proxmox LXC (`stpgit`, `gitea/docker-compose.yml`) and stpvm's +`gitea` service became a forwarder to it. + +- `docker-compose.gitea.yml` — the old service, with its state mounts + repointed at this directory. +- `data/` and `config/app.ini` (gitignored, on stpvm only) — the pre-move + copy of the repositories and the live config, moved here from `gitea/`. + Gitea's pre-move database is still the `gitea` database in stpvm's `db`. + +To bring it back on stpvm: stop Gitea on stpgit, copy anything pushed since +the move back (its `gitea/data`, and a `pg_dump` of `gitea-db` restored into +`db`'s `gitea` database), then +`docker compose -f docker-compose.yml -f .deprecated/gitea/docker-compose.gitea.yml up -d gitea`. +The service still reads `POSTGRES_GITEA_DB` and the three `GITEA_*` +secrets from `.env`; stpvm's `.env` still has them, so keep them there until +this copy is deleted. Delete `data/`, `config/app.ini` and the old database once the LXC has run +cleanly for a few weeks (from about 2026-12-08). + +The laptop's own leftovers (an old dev `gitea/data` and `app.ini`, and a +stale `gitea-runner/.runner`) are under `dev-leftovers/` here, also +gitignored, and can simply be deleted. diff --git a/.deprecated/gitea/docker-compose.gitea.yml b/.deprecated/gitea/docker-compose.gitea.yml new file mode 100644 index 0000000..20ab632 --- /dev/null +++ b/.deprecated/gitea/docker-compose.gitea.yml @@ -0,0 +1,84 @@ +# ============================================================================= +# .deprecated/gitea/docker-compose.gitea.yml — Gitea as it ran on stpvm until +# 2026-11-24, kept as the rollback from the move to its own LXC. +# +# STATUS: not live. Gitea runs on stpgit (gitea/docker-compose.yml); stpvm's +# `gitea` service is an haproxy forwarder to it. +# +# This is the old service verbatim except for the two state mounts, which now +# point at the pre-move copy moved in beside this file (gitignored). Layered +# over docker-compose.yml it replaces the forwarder under the same name; +# compose merges the forwarder's GITEA_UPSTREAM and haproxy.cfg mount in +# too, and both are harmless to Gitea. Relative paths resolve against the +# project directory (the repo root), not this file. See README.md here and +# DEPLOYMENT.md §7, "Gitea LXC", for the full rollback. +# ============================================================================= +services: + # Self-hosted git, served at /gitea/ and on port 3000 directly. Also the CI + # server: .gitea/workflows/deploy.yaml redeploys this whole stack on push to + # main, executed by the act_runner that lives outside docker (gitea-runner/). + # + # ROOTLESS image: runs as an unprivileged user, so config lives in /etc/gitea + # and data in /var/lib/gitea (not /data as in the root image) — that is why + # the bind mounts look unlike most Gitea compose examples. + # + # The GITEA__section__KEY environment convention is Gitea's own: each maps to + # an app.ini key and overrides the file at runtime, which is how the secrets + # stay in .env instead of in the committed app.ini.template. + # + # entrypoint is overridden to run our wrapper (which materialises app.ini + # from the template on first boot) before handing off to Gitea's real + # docker-entrypoint.sh. dumb-init is kept as PID 1 for correct signal/zombie + # handling, exactly as the stock image does it. + gitea: + image: docker.gitea.com/gitea:1.25.4-rootless + container_name: "${GITEA_HOST}" + entrypoint: ["/usr/bin/dumb-init", "--", "/etc/gitea/entrypoint.sh"] + networks: + - app-network + environment: + - GITEA__database__DB_TYPE=postgres + - GITEA__database__HOST=${POSTGRES_HOST} + - GITEA__database__NAME=${POSTGRES_GITEA_DB} + - GITEA__database__USER=${POSTGRES_USER} + - GITEA__database__PASSWD=${POSTGRES_PASSWORD} + - GITEA__server__LFS_JWT_SECRET=${GITEA_LFS_JWT_SECRET} + - GITEA__security__INTERNAL_TOKEN=${GITEA_INTERNAL_TOKEN} + - GITEA__oauth2__JWT_SECRET=${GITEA_OAUTH2_JWT_SECRET} + # The host's own name, which Gitea prints in SSH clone URLs. It lives in + # .env, not app.ini, so moving to another host is a one-line change; + # environment-to-ini writes it into the live app.ini on every start. + # localhost suits dev. + - GITEA__server__SSH_DOMAIN=${GITEA_SSH_DOMAIN:-localhost} + - GITEA__server__DOMAIN=${GITEA_SSH_DOMAIN:-localhost} + # Webhooks are refused to private addresses by default ("external"). + # The usaco site's push hook targets http://usaco:8080 on the Docker + # network, so that one host is allowed by name. + - GITEA__webhook__ALLOWED_HOST_LIST=external,usaco + - USER_UID=1000 + - USER_GID=1000 + restart: always + volumes: + # PERSISTENT: repositories, LFS objects, avatars, sessions. The git data + # itself. (Gitea's *relational* data is in Postgres, not here.) + - ./.deprecated/gitea/data:/var/lib/gitea + # PERSISTENT: app.ini is generated into this host directory on first boot + # and then edited by Gitea itself, so it is gitignored — only the + # template is committed. + - ./.deprecated/gitea/config:/etc/gitea + # Mounted over the config dir so the wrapper script is available at the + # path the overridden entrypoint points at. + - ./gitea/entrypoint.sh:/etc/gitea/entrypoint.sh:ro + # Match the Pi's clock/zone so commit and CI timestamps are local time. + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + ports: + # 2222 = Gitea's *built-in* SSH server (the rootless image cannot use 22). + # Clones use ssh://git@host:2222/... — including the deploy workflow, + # which fetches from ssh://git@localhost:2222. + - "2222:2222" + # 3000 = HTTP, published directly as well as proxied at /gitea/, because + # the act_runner registers against http://localhost:3000 from the host. + - "3000:3000" + depends_on: + - db diff --git a/.gitignore b/.gitignore index a7922d9..979ffd8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,10 @@ usaco-data/ .compose.lock gitea/data/* +# Gitea's pre-move state, kept as the rollback (.deprecated/gitea/README) +.deprecated/gitea/data/ +.deprecated/gitea/config/ +.deprecated/gitea/dev-leftovers/ gitea/config/app.ini gitea/.env diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 9acee1e..1bed0ed 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -421,8 +421,8 @@ of deleting the directory: | `${OBSIDIAN_DIR}` | The Obsidian vault (a git clone of the notes repo) | Read-write to backend and silverbullet, **read-only** to silverbullet-public | Gitea's state (`gitea/data`, `gitea/config`, the `gitea_db` volume) is on -the Gitea LXC, not here; see "Gitea LXC" in §7. stpvm's own `gitea/data` and -`gitea/config` are the pre-move copy, kept as the rollback. +the Gitea LXC, not here; see "Gitea LXC" in §7. The pre-move copy is in +stpvm's `.deprecated/gitea/` (gitignored), kept as the rollback. **Ephemeral:** anything else inside a container. Notably the Vue build, the rendered icecast config, and the Gitea runner's downloaded binary @@ -708,10 +708,11 @@ the LXC, so pull and `up -d` here afterwards. `GITEA_UPSTREAM` at the new address and `docker compose up -d gitea` on stpvm. The SSH host key is in `gitea/data`, so clients' `known_hosts` still match. -- *Rollback to running it on stpvm:* revert the commit that made `gitea` a - forwarder, restore its database into stpvm's `db`, and `docker compose up - -d gitea` with stpvm's own `gitea/data` (the pre-move copy, so anything - pushed since the move has to be copied back from the LXC first). +- *Rollback to running it on stpvm:* stop it on the LXC, copy its + `gitea/data` and database back over the pre-move copy in + `.deprecated/gitea/` and stpvm's `db`, then + `docker compose -f docker-compose.yml -f .deprecated/gitea/docker-compose.gitea.yml up -d gitea`. + `.deprecated/README.md` has the details. **Set up the CI runner on a fresh host:**