- Dockerfile with a check target (typecheck and tests) and one image per service on a pinned Node 22.20 Alpine base, each with only its own production dependencies and a health check. - deploy/compose.yaml: gk-content, gk-admin and gk-site on homelab_network with no host ports, read-only root filesystems, no capabilities, the vault's Site folder mounted into the content service, and backup.dump=sqlite on it. - deploy/deploy.sh builds and checks the commit, restarts the stack, and goes back to the last good tag if it doesn't come up healthy; rollback.sh swaps tags. .gitea/workflows/deploy.yml runs it on a host runner on Cosmos. - docs/deploy.md runbook (settings, runner, mirror, NPM hosts, Turnstile, Healthchecks, backups, cutover) and the stack's inventory note in vault-kit. - Site: trusts X-Forwarded-Host/Proto for gregkilmer.com hosts so form posts pass Astro's origin check behind the proxy; rate limits read CF-Connecting-IP; site URL set for absolute links. - Content service: the held-change webhook carries a Discord-ready message; .env.example lists the core settings. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012aSbo2D1qP8cMFQCykf7kx
7.1 KiB
Deploying on Cosmos
The stack is three containers on homelab_network, none with a host port:
| Container | Image target | Port | Reached as | Who can reach it |
|---|---|---|---|---|
gk-content |
content |
4310 | content.gregkilmer.com (API and /mcp), http://gk-content:4310 on homelab_network |
Tailnet only |
gk-admin |
admin |
4320 | admin.gregkilmer.com |
Tailnet only |
gk-site |
site |
4321 | beta.gregkilmer.com until cutover, then gregkilmer.com |
Tailnet only until cutover, then public through Cloudflare |
The old site keeps serving gregkilmer.com until phase 8 (cutover).
Files in the repo:
Dockerfile: one target per service, pluscheck(typecheck and every test). Node is pinned tonode:22.20.0-alpine.deploy/compose.yaml: the stack. Containers run as the vault's owner, with a read-only root filesystem, no capabilities andno-new-privileges.deploy/deploy.sh: buildscheck, then the three images tagged with the commit, and restarts the stack. If the new containers aren't healthy within two minutes, it puts the last good tag back. Run it again on the same commit and it does nothing (FORCE=1rebuilds).deploy/rollback.sh: switches to the previous tag. Run it again to roll forward..gitea/workflows/deploy.yml: runsdeploy.shon Cosmos for each new commit to master.
On Cosmos
Everything lives in /home/greg/homelab/gregkilmer:
/home/greg/homelab/gregkilmer/
compose.yaml copied from deploy/compose.yaml by every deploy
.env GK_TAG, GK_PREVIOUS_TAG, VAULT_SITE, PUID, PGID
content.env content service secrets and sync settings
admin.env ADMIN_TOKEN
site.env site secrets: tokens, Turnstile, SMTP
data/content/ content.db and submissions/ (backed up)
Kopia already covers /home/greg, so the .env files and data/ are in the encrypted backups.
First-time setup
-
Folder and settings. Run these from a checkout of the repo:
mkdir -p /home/greg/homelab/gregkilmer/data/content cd /home/greg/homelab/gregkilmer cp <repo>/deploy/stack.env.example .env cp <repo>/services/content/.env.example content.env cp <repo>/deploy/admin.env.example admin.env cp <repo>/services/site/.env.example site.env chmod 600 .env *.envIn
.env, check thatPUIDandPGIDmatchid -u gregandid -g greg, so the content service can write notes back into the vault. -
Tokens. Make one per role with
openssl rand -hex 24:- In
content.env, setCONTENT_TOKENS=reader:<r>,admin:<a>,intake:<i>,agent:<g>. - In
admin.env, setADMIN_TOKEN=<a>. - In
site.env, setCONTENT_TOKEN=<r>andCONTENT_INTAKE_TOKEN=<i>. - Give agents
<g>.
Leave
CONTENT_URLout ofsite.env; compose sets it. - In
-
The rest of the settings. Fill in Healthchecks, the Discord webhook, Turnstile, SMTP and the sync logins. The list is in
/mnt/project-files/website/phase6/setup-on-cosmos.mdand in each.env.example. -
Gitea runner. The workflow needs an
act_runneron Cosmos with the labelcosmosrunning in host mode (cosmos:host). It runs as a user in thedockergroup with write access to/home/greg/homelab/gregkilmer.- A runner with the Docker socket is root-equivalent. Register it for this repository only, not for the whole instance.
-
Gitea mirror. Mirror
github.com/Patiun/com.gregkilmer.wwwinto Gitea as a pull mirror and turn Actions on for it.- A pull mirror's sync may not raise a push event. The workflow therefore also runs every 15 minutes and deploys only when master has moved.
- Check once that a new commit reaches Cosmos. If the schedule doesn't fire on a mirror either, run the workflow by hand from the Actions tab.
-
First deploy. Run it from the Actions tab, or by hand from a checkout:
./deploy/deploy.sh. Then check:docker compose -f /home/greg/homelab/gregkilmer/compose.yaml psshows three healthy containers.docker logs gk-contentsaysContent service on 0.0.0.0:4310: N notes.
-
Nginx Proxy Manager. Add a proxy host for each hostname. Force SSL on each. For
content, addproxy_buffering off;under Advanced, because MCP streams its responses.Host Forward to Access list admin.gregkilmer.comhttp://gk-admin:4320Tailnet only content.gregkilmer.comhttp://gk-content:4310Tailnet only beta.gregkilmer.comhttp://gk-site:4321Tailnet only - DNS: an A record for each pointing at 100.99.111.16 (TTL 300), the same as other tailnet hosts.
- Certificates: Let's Encrypt can't reach a tailnet-only host over HTTP, so use NPM's DNS challenge with your DNS provider. This is the same open item as the
*.patiun.comcertificate. - Agents already on homelab_network can skip NPM and use
http://gk-content:4310/mcp.
-
Turnstile. Add
beta.gregkilmer.comandgregkilmer.comto the widget's hostnames. -
Healthchecks. Create these checks:
- one for the content service's full scan (
HEALTHCHECK_URL), every 5 minutes; - one per sync job you turn on (Archidekt, Suwayomi, Bambuddy and Homebox hourly; BGG and Kavita daily; covers every 15 minutes).
- one for the content service's full scan (
-
Inventory note. Copy
vault-kit/24.01_PersonalWebsite/GregKilmer.com stack.mdinto the vault's24.01_PersonalWebsitefolder, socosmos-inventorystops listing the containers as undocumented.
Backups
gk-contentcarriesbackup.dump=sqlite.cosmos-dumpfindscontent.dbin its/datamount and copies it withVACUUM INTObefore Kopia runs.content.dbholds note history, the review queue, saved inquiries and orders, and the sync cache.- The vault mount has no SQLite files, so nothing else is dumped.
- Form attachments are plain files in
data/content/submissions/, which Kopia picks up with the rest of/home/greg. - The plan called for a cache folder in
exclusions.conf. None is needed: the sync cache and search index live insidecontent.dband are small. gk-adminandgk-sitekeep no data.
Cutover (phase 8)
- In NPM, point
gregkilmer.comandwww.gregkilmer.comathttp://gk-site:4321with no access list, and retire the oldgreg-profile-sitecontainer. - Turn on Cloudflare's proxy for both records with SSL mode Full (strict). Cloudflare doesn't cache HTML by default, which is what the site needs: pages change within a minute of a note changing.
- The site already trusts
X-Forwarded-HostandX-Forwarded-Protofor gregkilmer.com and its subdomains (security.allowedDomainsinservices/site/astro.config.mjs), so form posts pass Astro's origin check behind the proxy. It reads the visitor's address fromCF-Connecting-IPfor the form rate limits.
Day to day
- Deploy: merge to master on GitHub; Gitea mirrors it and the workflow deploys it.
- Roll back:
GK_STACK_DIR=/home/greg/homelab/gregkilmer ./deploy/rollback.shfrom a checkout, or setGK_TAGin.envto any image tag still on the host and rundocker compose up -d. - Logs:
docker logs gk-content. Sync runs also appear on the admin page's Overview. - Restart one service:
docker compose -f /home/greg/homelab/gregkilmer/compose.yaml restart gk-site.