From 529e80242fd26d43ead35effecc4c8cb6875de1c Mon Sep 17 00:00:00 2001 From: Adam French Date: Thu, 15 Oct 2026 17:54:03 +0100 Subject: [PATCH] Set Gitea's SSH_DOMAIN and DOMAIN from GITEA_SSH_DOMAIN in .env Moving hosts meant hand-editing the live app.ini, which the template cannot reach once it exists. Gitea's environment-to-ini now writes the value on every start, so a move is a one-line .env change. Co-Authored-By: Claude Opus 5.5 --- .env.example | 4 ++++ DEPLOYMENT.md | 2 +- docker-compose.yml | 6 ++++++ gitea/config/app.ini.template | 6 +++--- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index bb1571b..9cce303 100644 --- a/.env.example +++ b/.env.example @@ -63,6 +63,10 @@ GITEA_INTERNAL_TOKEN= GITEA_LFS_JWT_SECRET= GITEA_OAUTH2_JWT_SECRET= POSTGRES_GITEA_DB=gitea +# The host's Tailscale MagicDNS name (e.g. stpvm.tailf20278.ts.net), shown in +# Gitea's SSH clone URLs. Not the public domain: 2222 is reachable only over +# the tailnet. Becomes Gitea's SSH_DOMAIN and DOMAIN. Blank means localhost. +GITEA_SSH_DOMAIN= # --- Gitea Actions runner ---------------------------------------------------- # The runner is NOT a container; it runs on the Pi via gitea-runner/run.sh. diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 0bfb9c4..1c17c20 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -297,7 +297,7 @@ Setup, once: that wants the public site. Pushing from another machine still goes through Cloudflare and its cap; use the host's Tailscale name for that. - **Gitea SSH (2222).** Not HTTP, so not tunnelled. Already Tailscale-only: - `SSH_DOMAIN` in `gitea/config/app.ini.template` is the host's MagicDNS name + `GITEA_SSH_DOMAIN` in `.env` (Gitea's `SSH_DOMAIN`) is the host's MagicDNS name and 2222 has never been forwarded. Nothing changes. - **The radio harbor (8001).** Also a raw source protocol, so a DJ client pointed at `:8001` stops connecting once the domain resolves to diff --git a/docker-compose.yml b/docker-compose.yml index 788e3c8..eb47508 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -646,6 +646,12 @@ services: - 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. diff --git a/gitea/config/app.ini.template b/gitea/config/app.ini.template index d98309a..72cb7ae 100644 --- a/gitea/config/app.ini.template +++ b/gitea/config/app.ini.template @@ -20,7 +20,9 @@ ; 22 and cannot use the host's sshd, so Gitea runs its own Go SSH server. ; 2222 is published in docker-compose.yml; the deploy workflow clones over ; ssh://git@localhost:2222. -; SSH_DOMAIN is the Pi's Tailscale MagicDNS name, not the public domain: SSH +; SSH_DOMAIN and DOMAIN are not set here: they come from GITEA_SSH_DOMAIN in +; ./.env (see docker-compose.yml). The value is the host's Tailscale +; MagicDNS name, not the public domain: SSH ; (22 and 2222) is not forwarded by the router, so the SSH clone URL Gitea ; shows only works from a device on the tailnet. HTTPS clones go through ; nginx at ROOT_URL and stay public. @@ -50,7 +52,6 @@ TEMP_PATH = /tmp/gitea/uploads [server] APP_DATA_PATH = /var/lib/gitea -SSH_DOMAIN = stpvm.tailf20278.ts.net HTTP_PORT = 3000 ROOT_URL = https://adam-french.co.uk/gitea/ DISABLE_SSH = false @@ -60,7 +61,6 @@ SSH_PORT = 2222 SSH_LISTEN_PORT = 2222 BUILTIN_SSH_SERVER_USER = git LFS_START_SERVER = true -DOMAIN = stpvm.tailf20278.ts.net LFS_JWT_SECRET = OFFLINE_MODE = true