Move Gitea to its own LXC; keep a forwarder on stpvm
Gitea (git, Actions, the registry) now runs from gitea/docker-compose.yml on a separate Proxmox LXC with its own Postgres, deployed by hand. The stack's gitea service becomes an haproxy TCP forwarder from stpvm's 3000 and 2222 to the LXC (GITEA_UPSTREAM), under the same container name, so Caddy, the backend feed, usaco, the runner, Renovate and every repo's CI keep their addresses. Webhooks from the LXC reach Caddy over the LAN. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+41
-72
@@ -8,7 +8,7 @@
|
||||
# Dev layers docker-compose.dev.yml on top of it (see that file).
|
||||
#
|
||||
# WHEN IT RUNS
|
||||
# On the Raspberry Pi, via the Gitea Actions deploy workflow
|
||||
# On stpvm, via the Gitea Actions deploy workflow
|
||||
# (.gitea/workflows/deploy.yaml) on every push to main, and by hand.
|
||||
#
|
||||
# ENV VARS
|
||||
@@ -21,9 +21,8 @@
|
||||
# app config from env_file.
|
||||
#
|
||||
# Required by this file: POSTGRES_{USER,PASSWORD,DB,PORT,HOST},
|
||||
# POSTGRES_GITEA_DB, BACKEND_HOST,
|
||||
# ICECAST_HOST, GITEA_HOST, OBSIDIAN_DIR, and the GITEA_*
|
||||
# secrets. PYTHON_HOST/PYTHON_PORT/TFL_APP_KEY/LIQUIDSOAP_HARBOR_PORT have
|
||||
# BACKEND_HOST, ICECAST_HOST, GITEA_HOST, GITEA_UPSTREAM and
|
||||
# OBSIDIAN_DIR. PYTHON_HOST/PYTHON_PORT/TFL_APP_KEY/LIQUIDSOAP_HARBOR_PORT have
|
||||
# inline defaults.
|
||||
#
|
||||
# NAMING CONVENTION / WHY container_name IS SET FROM env
|
||||
@@ -35,8 +34,8 @@
|
||||
# the other.
|
||||
#
|
||||
# WHAT IS PUBLISHED TO THE HOST
|
||||
# Only caddy (80, 443), gitea (3000 HTTP, 2222 SSH) and the liquidsoap harbor
|
||||
# port. Everything else is reachable only from inside app-network, which is
|
||||
# Only caddy (80, 443), gitea (3000 HTTP, 2222 SSH: the forwarder to the
|
||||
# Gitea LXC) and the liquidsoap harbor port. Everything else is reachable only from inside app-network, which is
|
||||
# why the backend, db, silverbullet and python have no `ports:` — they are
|
||||
# deliberately not exposed and are reached through Caddy. Web traffic can
|
||||
# also arrive through the `cloudflared` tunnel, which publishes nothing.
|
||||
@@ -63,13 +62,14 @@ networks:
|
||||
# PERSISTENT vs EPHEMERAL state
|
||||
# Named volumes below survive `docker compose down` and container rebuilds;
|
||||
# they are only destroyed by `docker compose down -v` or an explicit
|
||||
# `docker volume rm`. Bind mounts (./gitea/data, ./backend/token, ./logs,
|
||||
# ./caddy/data) live in the repo checkout on the Pi and survive everything
|
||||
# `docker volume rm`. Bind mounts (./backend/token, ./logs, ./caddy/data)
|
||||
# live in the repo checkout on the host and survive everything
|
||||
# short of deleting the directory. Anything inside a container's own
|
||||
# filesystem is ephemeral and gone on rebuild.
|
||||
volumes:
|
||||
# Postgres database — PERSISTENT. Holds the app DB *and* the Gitea DB.
|
||||
# Deleting this wipes posts, users, messages and every git repo's metadata.
|
||||
# Postgres database — PERSISTENT. Holds the app DB and the job and activity
|
||||
# trackers' DBs. Deleting this wipes posts, users and messages. (Gitea's
|
||||
# database moved to its own Postgres in the Gitea LXC.)
|
||||
dbdata:
|
||||
# File upload — PERSISTENT. Written by the backend at /backend/uploads,
|
||||
# served read-only by Caddy at /uploads/. Shared so Caddy can serve user
|
||||
@@ -299,10 +299,11 @@ services:
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
# Single Postgres instance serving TWO databases: ${POSTGRES_DB} for the Go
|
||||
# backend and ${POSTGRES_GITEA_DB} for Gitea. The postgres image only creates
|
||||
# POSTGRES_DB on first init, so the Gitea database was created by hand once;
|
||||
# a from-scratch restore must `createdb` it before Gitea will start.
|
||||
# Single Postgres instance: ${POSTGRES_DB} for the Go backend, plus the job
|
||||
# and activity trackers' databases. The postgres image only creates
|
||||
# POSTGRES_DB on first init; the others are created by hand (see their
|
||||
# READMEs). Gitea's database is not here any more: it has its own Postgres
|
||||
# in the Gitea LXC (gitea/docker-compose.yml).
|
||||
# Schema for the app DB comes from GORM auto-migration at backend start —
|
||||
# there are no migration files.
|
||||
db:
|
||||
@@ -474,7 +475,8 @@ services:
|
||||
# The vault's remotes are ssh://git@DOMAIN:2222/..., but Caddy's network
|
||||
# aliases make DOMAIN resolve to Caddy on app-network, which has no :2222,
|
||||
# so every pull and push was refused. /etc/hosts wins over Docker's DNS, so
|
||||
# this sends DOMAIN back to the host, where gitea publishes 2222. The name
|
||||
# this sends DOMAIN back to the host, where the gitea forwarder publishes
|
||||
# 2222. The name
|
||||
# is unchanged, so known_hosts still matches.
|
||||
extra_hosts:
|
||||
- "${DOMAIN}:host-gateway"
|
||||
@@ -834,71 +836,38 @@ services:
|
||||
volumes:
|
||||
- ./garage/garage.toml:/etc/garage.toml:ro
|
||||
|
||||
# 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/).
|
||||
# Gitea's ports on this host, forwarded to Gitea itself, which runs in its
|
||||
# own LXC (gitea/docker-compose.yml; DEPLOYMENT.md §7, "Gitea LXC"). A
|
||||
# plain TCP forwarder (gitea/forwarder.cfg), kept under the old service and
|
||||
# container name so nothing that talked to Gitea here had to change:
|
||||
# Caddy's /gitea/ and /v2/ upstream and the backend's feed (GITEA_HOST,
|
||||
# GITEA_PORT), usaco's pulls, and on the host the runner and Renovate
|
||||
# (localhost:3000) and every repo's CI and the obsidian checkout
|
||||
# (localhost:2222, or DOMAIN:2222 pinned to the host).
|
||||
#
|
||||
# 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.
|
||||
# Gitea is 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/). Recreating this container drops git and
|
||||
# registry connections in flight for a moment, which is why its config is
|
||||
# small and rarely changes; Gitea itself is never restarted by a deploy.
|
||||
#
|
||||
# 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_UPSTREAM is the LXC's LAN IP. Dev has no Gitea: it points at a dummy
|
||||
# address and /gitea/ answers 502.
|
||||
gitea:
|
||||
image: docker.gitea.com/gitea:1.25.4-rootless
|
||||
image: haproxy:3.2.27-alpine
|
||||
container_name: "${GITEA_HOST}"
|
||||
entrypoint: ["/usr/bin/dumb-init", "--", "/etc/gitea/entrypoint.sh"]
|
||||
restart: always
|
||||
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
|
||||
- GITEA_UPSTREAM=${GITEA_UPSTREAM:?set GITEA_UPSTREAM in .env to the Gitea LXC's LAN IP}
|
||||
volumes:
|
||||
# PERSISTENT: repositories, LFS objects, avatars, sessions. The git data
|
||||
# itself. (Gitea's *relational* data is in Postgres, not here.)
|
||||
- ./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.
|
||||
- ./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
|
||||
- ./gitea/forwarder.cfg:/usr/local/etc/haproxy/haproxy.cfg: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 = Gitea's built-in SSH server; 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 = HTTP, published as well as proxied at /gitea/, because the
|
||||
# act_runner registers against http://localhost:3000 from the host.
|
||||
- "3000:3000"
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
Reference in New Issue
Block a user