Trim comments to the non-obvious why
Drop narration, history and restated-code comments across the repo, keep short ones for security boundaries, upstream quirks and ordering constraints, and record the convention in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+70
-445
@@ -1,106 +1,38 @@
|
||||
# =============================================================================
|
||||
# docker-compose.yml — production topology for the whole site.
|
||||
#
|
||||
# WHAT IT DOES
|
||||
# Defines every container, the single bridge network they share, and the
|
||||
# named volumes that survive restarts. This file alone IS production:
|
||||
# docker compose up --build
|
||||
# Dev layers docker-compose.dev.yml on top of it (see that file).
|
||||
#
|
||||
# WHEN IT RUNS
|
||||
# On stpvm, via the Gitea Actions deploy workflow
|
||||
# (.gitea/workflows/deploy.yaml) on every push to main, and by hand.
|
||||
#
|
||||
# ENV VARS
|
||||
# Everything interpolated as ${VAR} below is read by the docker compose CLI
|
||||
# from ./.env at the repo root (gitignored, and edited by hand on the host).
|
||||
# Note the two distinct mechanisms:
|
||||
# - ${VAR} in this file -> substituted by compose when parsing
|
||||
# - `env_file: ./.env` -> the whole file injected into the container
|
||||
# Many services need both: the container name comes from substitution, the
|
||||
# app config from env_file.
|
||||
#
|
||||
# Required by this file: POSTGRES_{USER,PASSWORD,DB,PORT,HOST},
|
||||
# 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
|
||||
# Service discovery is by container name on app-network. Caddy builds its
|
||||
# upstreams from the same ${*_HOST} variables (the caddy service's
|
||||
# environment list), so naming the containers from .env keeps the proxy and
|
||||
# the containers in sync from one source of truth. Renaming a *_HOST value
|
||||
# renames the container AND repoints Caddy at it — do not change one without
|
||||
# the other.
|
||||
#
|
||||
# WHAT IS PUBLISHED TO THE HOST
|
||||
# Only caddy (80, 443) and the liquidsoap harbor port. (Gitea's 3000 and
|
||||
# 2222 were published here until its forwarder went on 2026-11-24; Gitea
|
||||
# now answers on its own LXC as GITEA_HOST.) 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.
|
||||
# =============================================================================
|
||||
# Production stack. Dev layers docker-compose.dev.yml on top.
|
||||
# Container names come from the *_HOST variables in .env, which Caddy also
|
||||
# uses for its upstreams, so the two always agree.
|
||||
|
||||
networks:
|
||||
# One flat bridge network; every service resolves every other by container
|
||||
# name via docker's embedded DNS at 127.0.0.11 (Caddy resolves an upstream
|
||||
# through it each time it dials one). The subnet is pinned explicitly so it cannot collide
|
||||
# with the Pi's LAN range or wander between compose versions.
|
||||
# Subnet pinned so it cannot collide with the LAN.
|
||||
app-network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.28.0.0/16
|
||||
# The usaco site's code runner and nothing else but the site. internal:
|
||||
# no route out, so code submitted to it cannot reach the internet, and
|
||||
# being off app-network keeps it away from postgres, gitea, garage and the
|
||||
# backend. Docker picks the subnet; nothing here pins an address on it.
|
||||
# internal: code submitted to the usaco runner cannot reach the internet
|
||||
# or anything on app-network.
|
||||
usaco-runner-net:
|
||||
driver: bridge
|
||||
internal: true
|
||||
|
||||
# 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 (./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.
|
||||
# Named volumes survive `down`; only `down -v` deletes them.
|
||||
volumes:
|
||||
# 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.)
|
||||
# Deleting this wipes posts, users and messages.
|
||||
dbdata:
|
||||
# File upload — PERSISTENT. Written by the backend at /backend/uploads,
|
||||
# served read-only by Caddy at /uploads/. Shared so Caddy can serve user
|
||||
# uploads without proxying through the Go process. Since Garage, it holds
|
||||
# private attachments (always), the uploads from before the bucket, and any
|
||||
# upload the backend wrote here because Garage refused it. Caddy serves
|
||||
# /uploads/ from the bucket first and only then from here.
|
||||
# Private attachments, plus any upload Garage refused. Caddy serves
|
||||
# /uploads/ from the bucket first, then from here.
|
||||
uploads:
|
||||
# Garage object store — PERSISTENT, both. garage_meta is the metadata DB
|
||||
# (buckets, keys, the object index, the cluster layout); garage_data is the
|
||||
# object bytes. Lose meta and the bytes in data are unreadable, so back up
|
||||
# the two together. A fresh pair needs garage/bootstrap.sh run once.
|
||||
# Back up meta and data together: the bytes are unreadable without meta.
|
||||
# A fresh pair needs garage/bootstrap.sh.
|
||||
garage_meta:
|
||||
garage_data:
|
||||
# Vue build — EPHEMERAL in spirit but a named volume for handoff: the
|
||||
# one-shot `vue` container writes the built SPA here and exits; Caddy mounts
|
||||
# it at /srv/www and serves it. Repopulated on every rebuild.
|
||||
# Written by the one-shot `vue` build container, served by Caddy.
|
||||
vue_dist:
|
||||
# Caddy's /config: the JSON it autosaves on each config load. Nothing in it
|
||||
# is needed across restarts (the Caddyfile is the source); named only so
|
||||
# the image's VOLUME does not leave an anonymous volume behind on every
|
||||
# recreate. The certificates are in ./caddy/data, not here.
|
||||
# Named only so the image's VOLUME doesn't leave anonymous volumes behind.
|
||||
caddy_config:
|
||||
|
||||
services:
|
||||
# One-shot build container, NOT a long-running service. `vite build` writes
|
||||
# the SPA into the shared vue_dist volume and the container exits 0. That
|
||||
# exit is expected — `docker compose ps` showing vue as Exited is healthy.
|
||||
# In dev this same service is overridden to run the Vite dev server instead
|
||||
# (docker-compose.dev.yml) and does stay up.
|
||||
# One-shot build: Exited (0) is the healthy state.
|
||||
vue:
|
||||
build:
|
||||
context: ./vue
|
||||
@@ -111,22 +43,10 @@ services:
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
# The only public entrypoint: Caddy (caddy/Caddyfile). Terminates TLS,
|
||||
# serves the SPA, reverse-proxies everything else, and obtains and renews
|
||||
# its own certificates over DNS-01 into ./caddy/data, with no reload and no
|
||||
# inbound port. It replaced nginx and the certbot container on 2026-11-17;
|
||||
# both are in .deprecated/ (DEPLOYMENT.md §7 has the rollback).
|
||||
#
|
||||
# ENVIRONMENT: an explicit list, not the whole .env, so the edge never sees
|
||||
# the database password or the JWT secret. A variable the Caddyfile reads
|
||||
# must be added here, or it reaches Caddy empty. The ${X:-default} forms
|
||||
# are the defaults nginx's entrypoint gave the optional services; they live
|
||||
# here because Caddy's own {$X:default} keeps a variable that is set but
|
||||
# empty, which is how a blank line in .env arrives.
|
||||
#
|
||||
# NO depends_on: Caddy resolves an upstream when it dials it, so it starts
|
||||
# with any of them missing (502 until it appears), and there is no Vue
|
||||
# build to wait for: the SPA is files in vue_dist, served as they appear.
|
||||
# Explicit environment list so the edge never sees DB or JWT secrets; a
|
||||
# variable the Caddyfile reads must be added here. Defaults live here, not
|
||||
# in the Caddyfile, because Caddy's {$X:default} keeps a set-but-empty value.
|
||||
# No depends_on: Caddy resolves upstreams per dial.
|
||||
caddy:
|
||||
build:
|
||||
context: ./caddy
|
||||
@@ -151,62 +71,33 @@ services:
|
||||
# A dead port by default, so /receipt/ reads "offline".
|
||||
- RECEIPT_WEB_UPSTREAM=${RECEIPT_WEB_UPSTREAM:-127.0.0.1:9}
|
||||
- RECEIPT_WEB_TOKEN=${RECEIPT_WEB_TOKEN:-}
|
||||
# Partner Radar (radar.DOMAIN): the adamf/cto stack's `web` container,
|
||||
# which joins app-network under this alias (its docker-compose.stpvm.yml).
|
||||
# While that stack is down the name does not resolve and radar.DOMAIN
|
||||
# answers "offline".
|
||||
# The adamf/cto stack's web container; "offline" while that stack is down.
|
||||
- RADAR_UPSTREAM=${RADAR_UPSTREAM:-radar-web:80}
|
||||
# Zone -> Zone -> Read and Zone -> DNS -> Edit; see .env.example.
|
||||
- CLOUDFLARE_DNS_API_TOKEN=${CLOUDFLARE_DNS_API_TOKEN:-}
|
||||
# Gitea runs on its own LXC (the adamf/stpgit repo), and the registry at
|
||||
# the apex's /v2/ is still proxied from here. GITEA_HOST is its public
|
||||
# name; this pins it to the LXC's LAN IP so the hop stays on the LAN
|
||||
# (Docker's DNS cannot see LAN names, and public DNS would send it to
|
||||
# Cloudflare, which has nothing on :3000). Same pin on backend and usaco.
|
||||
# Keeps the Gitea hop on the LAN; public DNS points at Cloudflare.
|
||||
extra_hosts:
|
||||
- "${GITEA_HOST}:${GITEA_UPSTREAM}"
|
||||
networks:
|
||||
app-network:
|
||||
# The site's public names, resolving to this container for everything
|
||||
# on app-network. They exist for cloudflared: its tunnel origin is
|
||||
# https://www.DOMAIN, which lands here over the bridge with a name the
|
||||
# Let's Encrypt certificate actually covers, so the tunnel verifies
|
||||
# TLS with no extra dashboard settings (`https://caddy` would fail the
|
||||
# name check). Any other container that calls the public site now
|
||||
# reaches Caddy directly instead of hairpinning through the internet.
|
||||
# So cloudflared's origin (https://www.DOMAIN) lands here under a name
|
||||
# the certificate covers.
|
||||
aliases:
|
||||
- ${DOMAIN}
|
||||
- www.${DOMAIN}
|
||||
- radar.${DOMAIN}
|
||||
# Fixed for cloudflared's extra_hosts (see there): an alias only
|
||||
# exists while Caddy is running, and this address is pinned to the
|
||||
# same names for when it is not. Top of the /16 beside cloudflared's,
|
||||
# away from docker's dynamic allocations.
|
||||
# Matches cloudflared's extra_hosts.
|
||||
ipv4_address: 172.28.255.251
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
volumes:
|
||||
# The certificates, their keys and the ACME account. PERSISTENT and
|
||||
# private key material: gitignored, never commit. Losing it only costs
|
||||
# a re-issue on the next start (seconds over DNS-01), during which the
|
||||
# tunnel, which verifies the certificate, serves 502s.
|
||||
# Private key material; never commit.
|
||||
- ./caddy/data:/data
|
||||
- caddy_config:/config
|
||||
- uploads:/srv/uploads:ro
|
||||
# The SPA written by the one-shot `vue` container.
|
||||
- vue_dist:/srv/www:ro
|
||||
# The JSON request-body log, kept on the host so it survives rebuilds
|
||||
# and the `traffic` container can tail it. Caddy rotates it itself
|
||||
# (50 MiB, five files kept).
|
||||
- ./logs/caddy:/var/log/caddy
|
||||
# restart: always only acts when the process exits. On 2026-10-19 nginx's
|
||||
# worker stalled while its master lived, and the site was down 4.6 hours
|
||||
# with the container "Up". /caddy-health (http://127.0.0.1 in the
|
||||
# Caddyfile) is answered by Caddy's own server, so a hung server shows
|
||||
# here; Docker only marks it unhealthy, and the `autoheal` label is what
|
||||
# gets it restarted (see the autoheal service). The image has busybox
|
||||
# wget, not curl.
|
||||
# restart: always misses a hung server; autoheal restarts on unhealthy.
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1/caddy-health"]
|
||||
interval: 30s
|
||||
@@ -216,39 +107,19 @@ services:
|
||||
labels:
|
||||
- autoheal=true
|
||||
|
||||
# Cloudflare Tunnel: an OUTBOUND connection from here to Cloudflare's edge,
|
||||
# which then forwards visitors' requests back down it to Caddy. Nothing is
|
||||
# published to the host, so with the tunnel live the router's 80/443
|
||||
# forwards can be closed. The tunnel is "remotely managed": its public
|
||||
# hostnames and origin settings live in the Cloudflare dashboard, and this
|
||||
# container only needs the token. The routing set up there (DEPLOYMENT.md,
|
||||
# "Cloudflare Tunnel") is https://www.DOMAIN, which Caddy's network aliases
|
||||
# resolve to Caddy itself, so the certificate verifies; Caddy's config,
|
||||
# redirects and security headers apply to tunnel traffic exactly as to
|
||||
# direct traffic, and both paths work side by side.
|
||||
#
|
||||
# Fixed address so Caddy can trust the CF-Connecting-IP header from this
|
||||
# container and no other (trusted_proxies in caddy/Caddyfile). It sits
|
||||
# at the top of the /16 because docker hands out dynamic addresses from the
|
||||
# bottom; the two must change together.
|
||||
#
|
||||
# Disabled in dev via the `disabled` profile in docker-compose.dev.yml.
|
||||
# Remotely-managed Cloudflare Tunnel; routes live in the dashboard.
|
||||
# Fixed IP because Caddy trusts CF-Connecting-IP from this address only.
|
||||
cloudflared:
|
||||
image: cloudflare/cloudflared:2026.9.3
|
||||
container_name: cloudflared
|
||||
restart: always
|
||||
command: ["tunnel", "--no-autoupdate", "run"]
|
||||
# Explicit, not env_file: the container only ever needs the token.
|
||||
environment:
|
||||
- TUNNEL_TOKEN=${CLOUDFLARE_TUNNEL_TOKEN:-}
|
||||
depends_on:
|
||||
- caddy
|
||||
# Pins the tunnel origin's names to Caddy's fixed address. Its aliases
|
||||
# vanish while it is stopped (every deploy and the weekly maintenance), and
|
||||
# docker's DNS then forwards the name to public DNS, which answers with
|
||||
# Cloudflare's own IPs: the tunnel sent requests back to the edge and
|
||||
# visitors got error 1000. /etc/hosts wins over DNS, so a stopped Caddy is
|
||||
# now a refused connection, which cloudflared reports as a plain 502.
|
||||
# A stopped Caddy loses its aliases, and public DNS would loop the tunnel
|
||||
# back to Cloudflare (error 1000). Pinning makes it a plain 502 instead.
|
||||
extra_hosts:
|
||||
- "${DOMAIN}:172.28.255.251"
|
||||
- "www.${DOMAIN}:172.28.255.251"
|
||||
@@ -263,18 +134,9 @@ services:
|
||||
dockerfile: Dockerfile
|
||||
container_name: "${BACKEND_HOST}"
|
||||
restart: always
|
||||
# MAP form, not the list form used elsewhere: this waits for db's
|
||||
# healthcheck to pass, not merely for its container to start. Without it
|
||||
# the Go process raced Postgres on every boot, failed its first connection,
|
||||
# died, and relied on `restart: always` to try again — noisy log churn and
|
||||
# a slower cold start in practice.
|
||||
# `restart: always` is deliberately KEPT as the backstop: if db's health
|
||||
# probe were ever to stall past compose's patience, or the DB dropped out
|
||||
# later, the restart policy still recovers the backend.
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
# The Gitea activity feed (GITEA_HOST:GITEA_PORT); see caddy's extra_hosts.
|
||||
extra_hosts:
|
||||
- "${GITEA_HOST}:${GITEA_UPSTREAM}"
|
||||
networks:
|
||||
@@ -282,27 +144,13 @@ services:
|
||||
env_file:
|
||||
- ./.env
|
||||
volumes:
|
||||
# PERSISTENT, and the subtle one: the Spotify OAuth refresh token is
|
||||
# written here as spotify_token.json. Without this bind mount the token
|
||||
# would live in the container filesystem and be destroyed on every
|
||||
# rebuild, forcing a manual re-authorisation of Spotify after each
|
||||
# deploy. Gitignored (it is a credential).
|
||||
# Spotify refresh token; without this every deploy forces a re-auth.
|
||||
- ./backend/token/:/backend/token
|
||||
# The Obsidian vault on the host, read by the backend for the notes API.
|
||||
# Same directory is mounted read-write into silverbullet (the editor) and
|
||||
# read-only into silverbullet-public (the /notes/ site).
|
||||
- ${OBSIDIAN_DIR}:/backend/notes
|
||||
- ./logs:/backend/logs
|
||||
# Same named volume Caddy serves at /uploads/ — backend writes, Caddy reads.
|
||||
- uploads:/backend/uploads
|
||||
# Shared with icecast2, which plays these as the radio fallback playlist;
|
||||
# the backend reads them to report what is queued.
|
||||
- ./icecast2/fallback_music:/backend/fallback_music
|
||||
# Reported to docker only: nothing acts on `unhealthy` since the autoheal
|
||||
# watchdog was retired (.deprecated/autoheal), so this just shows up in
|
||||
# `docker ps`. `restart: always` covers a crashed process, not a hung one.
|
||||
# start_period gives the Go process 10s to bind before failures start
|
||||
# counting.
|
||||
# Informational only: autoheal does not watch this container.
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-qO-", "http://localhost:8080/"]
|
||||
interval: 30s
|
||||
@@ -310,13 +158,7 @@ services:
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
# 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 (the adamf/stpgit repo).
|
||||
# Schema for the app DB comes from GORM auto-migration at backend start —
|
||||
# there are no migration files.
|
||||
# Holds the app DB plus the job and activity trackers' (created by hand).
|
||||
db:
|
||||
image: postgres:16
|
||||
container_name: "${POSTGRES_HOST}"
|
||||
@@ -327,20 +169,8 @@ services:
|
||||
- app-network
|
||||
volumes:
|
||||
- dbdata:/var/lib/postgresql/data
|
||||
# Postgres is the one dependency the backend genuinely cannot start
|
||||
# without, so `backend` gates on this healthcheck (condition:
|
||||
# service_healthy) instead of on mere container start.
|
||||
# TUNED FOR SLOW ARM HARDWARE: on a Raspberry Pi with a cold page cache a
|
||||
# first-boot Postgres can take well over a minute to finish initdb/recovery
|
||||
# and accept connections. start_period is the grace window during which a
|
||||
# failing probe does NOT count against `retries` and does NOT mark the
|
||||
# container unhealthy, so 90s costs nothing on a warm boot and prevents a
|
||||
# false "unhealthy" on a cold one. After that, 10 retries at 10s gives
|
||||
# another ~100s before anything gives up. `pg_isready -U $POSTGRES_USER`
|
||||
# is the cheapest real readiness probe (it does a protocol-level connect,
|
||||
# not just a TCP open). Note $$POSTGRES_USER: the doubled $ escapes
|
||||
# compose's own interpolation so the variable is expanded by the shell
|
||||
# INSIDE the container, from env_file, at probe time.
|
||||
# Long start_period for cold first boots. $$ defers expansion to the
|
||||
# container's shell.
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\" -q"]
|
||||
interval: 10s
|
||||
@@ -348,18 +178,8 @@ services:
|
||||
retries: 10
|
||||
start_period: 90s
|
||||
|
||||
# Internet radio: one container running BOTH icecast2 (the streaming server
|
||||
# listeners connect to, proxied at /radio/) and liquidsoap (the source that
|
||||
# feeds it). See icecast2/entrypoint.sh.
|
||||
#
|
||||
# This is the only non-Caddy service that publishes a host port, and it has
|
||||
# to: LIQUIDSOAP_HARBOR_PORT is the live-DJ input. A broadcasting client
|
||||
# (e.g. butt) connects straight to the Pi on that port, by its Tailscale
|
||||
# name now that the public domain resolves to Cloudflare, with the icecast
|
||||
# source password and pre-empts the fallback playlist. It is NOT proxied
|
||||
# through Caddy because it is a raw source protocol, not HTTP the SPA uses.
|
||||
# Note the host:container mapping uses the same variable on both sides, so
|
||||
# the published port always matches what liquidsoap actually binds.
|
||||
# icecast2 + liquidsoap. The harbor port is a raw live-DJ source input,
|
||||
# so it is published directly rather than proxied.
|
||||
icecast2:
|
||||
build:
|
||||
context: ./icecast2
|
||||
@@ -375,16 +195,7 @@ services:
|
||||
ports:
|
||||
- "${LIQUIDSOAP_HARBOR_PORT:-8001}:${LIQUIDSOAP_HARBOR_PORT:-8001}"
|
||||
|
||||
# Browser-based editor for the vault, so notes are editable from a phone.
|
||||
# Proxied at /sb/ behind Caddy's admin gate. The public site at /notes/ is
|
||||
# a SECOND, read-only SilverBullet over the same folder (silverbullet-public,
|
||||
# below).
|
||||
#
|
||||
# SINGLE-SPACE MODE is auto-detected because the mounted folder is not empty
|
||||
# (the alternative, multi-space, expects /data to be a SilverBullet-owned
|
||||
# folder of spaces). In this mode it treats the mount as the space itself and
|
||||
# writes NO database or metadata files into the vault — the folder stays a
|
||||
# plain directory of markdown that Obsidian still understands.
|
||||
# Vault editor at /sb/ (admin-gated).
|
||||
silverbullet:
|
||||
image: ghcr.io/silverbulletmd/silverbullet:2.11.0
|
||||
container_name: "${SILVERBULLET_HOST:-silverbullet}"
|
||||
@@ -393,58 +204,21 @@ services:
|
||||
- app-network
|
||||
environment:
|
||||
SB_PORT: "${SILVERBULLET_PORT:-3000}"
|
||||
# The app builds its service-worker scope and asset URLs from this, which
|
||||
# is why Caddy must NOT strip the /sb/ prefix. See caddy/routes.caddy.
|
||||
# Caddy must not strip /sb/: the app builds its URLs from this.
|
||||
SB_URL_PREFIX: /sb
|
||||
# Only .obsidian: it is editor config and plugin JS, not notes.
|
||||
#
|
||||
# Deliberately NOT silverbullet-public's list, which also hides private/
|
||||
# and templates/. The two answer different questions: the public
|
||||
# instance hides private/ because it must never be PUBLISHED, whereas
|
||||
# this is the editor, reachable only through the admin gate, and hiding
|
||||
# notes from it just stops you editing them.
|
||||
#
|
||||
# MUST be newline separated: a comma separated list is accepted silently
|
||||
# and does nothing.
|
||||
# Newline separated; commas are silently ignored.
|
||||
SB_SPACE_IGNORE: |
|
||||
.obsidian
|
||||
# Pinned rather than inferred from the mount's owner, so the files it
|
||||
# writes match the vault's ownership on the host.
|
||||
PUID: "1000"
|
||||
PGID: "1000"
|
||||
# Uncomment for a look-but-don't-touch first boot against a real vault:
|
||||
# SB_READ_ONLY: "true"
|
||||
volumes:
|
||||
- ${OBSIDIAN_DIR}:/data
|
||||
|
||||
# The PUBLIC notes site at /notes/ (replaced Quartz): the same SilverBullet
|
||||
# image in read-only mode over the same vault, with no auth. Visitors get the
|
||||
# full client — navigation, backlinks, live queries — but cannot write.
|
||||
# Edits made in the /sb/ editor show up here live, since both watch one folder.
|
||||
#
|
||||
# KEEPING private/ PRIVATE takes three layers, because none is enough alone:
|
||||
# 1. SB_SPACE_IGNORE hides the paths from the file LIST, so they are
|
||||
# never indexed, searched or shown. It does NOT stop
|
||||
# a direct fetch of /.fs/private/x.md, nor the page
|
||||
# URL /notes/private/x (server-rendered with the
|
||||
# note's content), nor /.fs/.git/ — SilverBullet
|
||||
# only applies it to listing (checked in 2.11.0).
|
||||
# 2. Caddy deny rules 404 any private/ or templates/ segment and any
|
||||
# nested dot-folder under /notes/; this is what
|
||||
# actually closes those holes. Keep its folder list
|
||||
# in step with the one below.
|
||||
# 3. SB_REVISIONS the default ("unmanaged") serves history from the
|
||||
# vault's own .git, i.e. every version of every file
|
||||
# including private/ and deleted ones. Disabled here,
|
||||
# and Caddy blocks /notes/.revisions as well.
|
||||
#
|
||||
# SB_READ_ONLY rejects writes server-side and also disables the shell and the
|
||||
# /.proxy endpoint (otherwise an open fetch proxy). The :ro mount is a second
|
||||
# lock on writes. It is flagged "legacy" upstream in favour of multi-space
|
||||
# mode's per-space publish setting, which cannot exclude a folder and would
|
||||
# mean migrating the editor too — revisit if single-space mode is removed.
|
||||
#
|
||||
# Keep the image tag in lockstep with the editor above.
|
||||
# Public read-only notes at /notes/. private/ stays private only with all
|
||||
# three: SB_SPACE_IGNORE (hides from listings, not direct fetches), Caddy's
|
||||
# /notes/ deny regex (keep its folder list in step), and SB_REVISIONS
|
||||
# disabled (else history is served from the vault's .git).
|
||||
# Keep the image tag in step with the editor.
|
||||
silverbullet-public:
|
||||
image: ghcr.io/silverbulletmd/silverbullet:2.11.0
|
||||
container_name: "${SILVERBULLET_PUBLIC_HOST:-silverbullet-public}"
|
||||
@@ -453,14 +227,9 @@ services:
|
||||
- app-network
|
||||
environment:
|
||||
SB_PORT: "${SILVERBULLET_PUBLIC_PORT:-3000}"
|
||||
# Same reason as the editor's SB_URL_PREFIX: Caddy must not strip /notes/.
|
||||
SB_URL_PREFIX: /notes
|
||||
SB_READ_ONLY: "true"
|
||||
SB_REVISIONS: disabled
|
||||
# Newline separated (commas are silently ignored). Gitignore semantics,
|
||||
# so these match at any depth. Must match the folder list in the
|
||||
# /notes/ deny regex in caddy/routes.caddy, or a new entry here is
|
||||
# hidden from the list but still publicly fetchable.
|
||||
SB_SPACE_IGNORE: |
|
||||
private/
|
||||
templates/
|
||||
@@ -470,28 +239,18 @@ services:
|
||||
volumes:
|
||||
- ${OBSIDIAN_DIR}:/data:ro
|
||||
|
||||
# SilverBullet has no concept of git, so this commits and pushes what it
|
||||
# writes, and pulls what Obsidian pushes from elsewhere.
|
||||
#
|
||||
# WHY A SEPARATE CONTAINER and not SilverBullet's own shell backend: enabling
|
||||
# that would give anyone who gets past Caddy's admin gate command execution
|
||||
# inside the container. Since SilverBullet itself runs with no SB_USER, that
|
||||
# gate is the only thing protecting it, so the blast radius stays here.
|
||||
# Commits/pulls the vault. Separate from SilverBullet so its shell backend
|
||||
# stays off (it would give command execution to anyone past the admin gate).
|
||||
silverbullet-git:
|
||||
image: alpine/git:v2.54.0
|
||||
container_name: "${SILVERBULLET_GIT_HOST:-silverbullet-git}"
|
||||
restart: always
|
||||
networks:
|
||||
- app-network
|
||||
# The vault's remote is ssh://git@GITEA_HOST:2222/..., Gitea's SSH on its
|
||||
# own LXC. /etc/hosts wins over Docker's DNS, so this sends the name to
|
||||
# the LXC's LAN IP; public DNS would answer with Cloudflare, which has
|
||||
# nothing on 2222. silverbullet/ssh/known_hosts carries Gitea's host key
|
||||
# under that name.
|
||||
# Gitea SSH on the LAN; public DNS points at Cloudflare.
|
||||
extra_hosts:
|
||||
- "${GITEA_HOST}:${GITEA_UPSTREAM}"
|
||||
# Same uid SilverBullet writes as, so commits don't leave root-owned objects
|
||||
# in .git that the host user can no longer clean up.
|
||||
# Match SilverBullet's uid so .git objects stay host-owned.
|
||||
user: "1000:1000"
|
||||
environment:
|
||||
SYNC_INTERVAL: "${SILVERBULLET_GIT_INTERVAL:-300}"
|
||||
@@ -499,7 +258,6 @@ services:
|
||||
GIT_AUTHOR_EMAIL: "silverbullet@${DOMAIN}"
|
||||
GIT_COMMITTER_NAME: silverbullet
|
||||
GIT_COMMITTER_EMAIL: "silverbullet@${DOMAIN}"
|
||||
# uid 1000 has no home in this image; give git somewhere writable.
|
||||
HOME: /tmp
|
||||
GIT_SSH_COMMAND: "ssh -i /ssh/id_ed25519 -o UserKnownHostsFile=/ssh/known_hosts -o IdentitiesOnly=yes"
|
||||
entrypoint: ["/bin/sh", "/git-sync.sh"]
|
||||
@@ -507,19 +265,9 @@ services:
|
||||
- ${OBSIDIAN_DIR}:/space
|
||||
- ./silverbullet/git-sync.sh:/git-sync.sh:ro
|
||||
- ./silverbullet/ssh:/ssh:ro
|
||||
# ssh will not run for a uid with no passwd entry; see the file's comment.
|
||||
- ./silverbullet/passwd:/etc/passwd:ro
|
||||
|
||||
# FastAPI side-service, proxied at /py/ with the prefix stripped by Caddy.
|
||||
# ROOT_PATH=/py tells FastAPI it is mounted under a prefix so the generated
|
||||
# OpenAPI/Swagger URLs (/py/docs) are correct even though the app's own
|
||||
# routes are written relative to /.
|
||||
# Note this service uses `environment:` with an explicit allow-list rather
|
||||
# than `env_file: ./.env` — it only gets the variables it needs and never
|
||||
# sees the database password, Spotify secrets, or the other API keys.
|
||||
# CLAUDE_API_KEY is the one secret on the list: the rowing photo reader
|
||||
# (POST /internal/rowing/read, called by the backend, blocked at Caddy)
|
||||
# makes its Claude call here.
|
||||
# Mounted at /py/ (prefix stripped). Explicit env list: no DB or other secrets.
|
||||
python:
|
||||
build:
|
||||
context: ./python
|
||||
@@ -541,23 +289,8 @@ services:
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
# The job application tracker, served at /jobs/. Built and published by its
|
||||
# own repo (adamf/job-tracker on this Gitea), whose README covers the
|
||||
# first-time database setup and the cutover from the old in-backend tracker.
|
||||
#
|
||||
# Like python, it gets an explicit `environment:` list rather than the whole
|
||||
# .env: it never sees the site's database password or JWT secret, and has a
|
||||
# database role of its own. A variable the tracker reads must be added to
|
||||
# the list below as well as .env.example.
|
||||
#
|
||||
# It has no login. Caddy's admin gate gates /jobs/ like /sb/ (except the
|
||||
# bearer-token capture API and the userscript), and the tracker checks
|
||||
# again itself: AUTH_VALIDATE_URL is the backend's validate-admin route
|
||||
# (the one Caddy's admin gate uses), which it asks with the visitor's
|
||||
# cookies on each admin request.
|
||||
#
|
||||
# ./jobs-data holds the Microsoft Graph session and the capture token. The
|
||||
# image runs as uid 1000, so the directory must be owned by it.
|
||||
# Job tracker (adamf/job-tracker). No login of its own: it asks
|
||||
# validate-admin with the visitor's cookies. ./jobs-data must be uid 1000.
|
||||
jobs:
|
||||
image: adam-french.co.uk/adamf/job-tracker:${JOBS_IMAGE_TAG:-latest}
|
||||
container_name: jobs
|
||||
@@ -591,34 +324,9 @@ services:
|
||||
volumes:
|
||||
- ./jobs-data:/data
|
||||
|
||||
# The USACO practice log, served at /usaco/. Built and published by the
|
||||
# usaco repo's CI (adamf/usaco on this Gitea; the server is in its site/
|
||||
# directory), which pulls :latest into this service on every push to main
|
||||
# that touches the site. Pin USACO_IMAGE_TAG to hold a version.
|
||||
#
|
||||
# It has no database: git is its store. It keeps a clone of adamf/usaco in
|
||||
# ./usaco-data, pulled from Gitea over the LAN when Gitea's push webhook
|
||||
# fires (USACO_WEBHOOK_SECRET signs it), and commits the admin's edits
|
||||
# (status, link, notes, statement, explanations) back with USACO_GIT_TOKEN.
|
||||
# CLAUDE_API_KEY powers the admin's Explain button (USACO_CLAUDE_MODEL picks
|
||||
# the model; blank is claude-opus-5-5). Recording reviews also need
|
||||
# USACO_OPENAI_API_KEY to transcribe, and keep the audio in Garage's
|
||||
# private usaco-audio bucket when USACO_S3_* is set (the site refuses to
|
||||
# start with only some S3_* set, so all five go together or not at all:
|
||||
# the blank-key case blanks the rest). USACO_CLAUDE_MONTHLY_BUDGET (dollars,
|
||||
# blank for none) stops new Claude jobs once a month's estimated spend
|
||||
# reaches it. ./usaco-data holds that clone, the background jobs' records
|
||||
# and the Claude spend ledger; deleting it is safe (it re-clones) but loses
|
||||
# any answer not yet committed. The image runs as uid 1000, so the
|
||||
# directory must be owned by it.
|
||||
#
|
||||
# On stop it lets running Claude jobs finish for up to SHUTDOWN_GRACE (5m
|
||||
# by default) before exiting, so stop_grace_period must be longer than
|
||||
# that, or Docker kills it mid-job.
|
||||
#
|
||||
# Same explicit `environment:` list as jobs. Like the tracker it has no
|
||||
# login: visitors see solved problems, and AUTH_VALIDATE_URL decides who
|
||||
# is the admin from the visitor's cookies.
|
||||
# USACO log (adamf/usaco). Git is its store, cloned into ./usaco-data
|
||||
# (must be uid 1000). The S3_* vars are all-or-nothing, hence the :+ forms.
|
||||
# stop_grace_period must exceed the app's SHUTDOWN_GRACE (5m).
|
||||
usaco:
|
||||
image: adam-french.co.uk/adamf/usaco:${USACO_IMAGE_TAG:-latest}
|
||||
container_name: usaco
|
||||
@@ -626,7 +334,6 @@ services:
|
||||
stop_grace_period: 6m
|
||||
depends_on:
|
||||
- usaco-runner
|
||||
# Its clone of the repo (GIT_REMOTE_URL); see caddy's extra_hosts.
|
||||
extra_hosts:
|
||||
- "${GITEA_HOST}:${GITEA_UPSTREAM}"
|
||||
networks:
|
||||
@@ -650,27 +357,9 @@ services:
|
||||
volumes:
|
||||
- ./usaco-data:/data
|
||||
|
||||
# The usaco site's code runner (site/Dockerfile.runner in adamf/usaco):
|
||||
# compiles and runs solutions against their tests, and lints them, for the
|
||||
# admin's solve page. It runs submitted code, so it has no secrets (no
|
||||
# environment at all) and is only on usaco-runner-net, which is internal:
|
||||
# no internet, and nothing but the site can reach it. Published by
|
||||
# adamf/usaco's CI, which rolls it before `usaco`; pin
|
||||
# USACO_RUNNER_IMAGE_TAG to hold a version.
|
||||
#
|
||||
# The hardening is the point:
|
||||
# read_only the image is not writable; only /tmp is
|
||||
# tmpfs /tmp one directory per request, removed after. Must NOT be
|
||||
# noexec: the compiled program runs from it. Its pages count
|
||||
# against mem_limit.
|
||||
# mem_limit, cpus
|
||||
# on top of the runner's own per-program limits (512 MB
|
||||
# address space, CPU time, 64 MB files, wall clock)
|
||||
# pids_limit what stops a fork bomb: the runner does not set
|
||||
# RLIMIT_NPROC (it counts the whole uid, the server's own
|
||||
# threads included). The image's tini reaps the leftovers.
|
||||
# cap_drop, no-new-privileges
|
||||
# the runner needs no capabilities, and runs as uid 1000
|
||||
# Runs submitted code: no secrets, no network but the site's.
|
||||
# tmpfs must allow exec (compiled programs run there). pids_limit is the
|
||||
# fork-bomb guard, since the runner can't use RLIMIT_NPROC.
|
||||
usaco-runner:
|
||||
image: adam-french.co.uk/adamf/usaco-runner:${USACO_RUNNER_IMAGE_TAG:-latest}
|
||||
container_name: usaco-runner
|
||||
@@ -688,22 +377,7 @@ services:
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
|
||||
# The activity tracker (time spent per app, site, walk...), served at
|
||||
# /tracker/ with the prefix stripped. Built and published by its own repo
|
||||
# (adamf/ccp on this Gitea), whose CI pulls :latest into this service on
|
||||
# every push to main; pin ACTIVITY_TRACKER_IMAGE_TAG to hold a version.
|
||||
#
|
||||
# Same shape as jobs: an explicit `environment:` list and a database role of
|
||||
# its own, created by hand once (the ccp README has the command). It applies
|
||||
# its own migrations on start. No state outside Postgres.
|
||||
#
|
||||
# Two kinds of auth. Collectors send per-device bearer keys, made on the
|
||||
# tracker's /tracker/setup page or with `docker exec activity-tracker
|
||||
# tracker apikey create`. The dashboard and setup pages have no login of
|
||||
# their own: Caddy's admin gate gates them like /sb/ (everything but
|
||||
# /tracker/api/v1/ and the userscript), and like jobs the tracker also asks
|
||||
# AUTH_VALIDATE_URL (the backend's validate-admin) with the visitor's
|
||||
# cookies and sends anyone else to /admin/login.
|
||||
# Activity tracker (adamf/ccp), at /tracker/ (prefix stripped).
|
||||
activity-tracker:
|
||||
image: adam-french.co.uk/adamf/activity-tracker:${ACTIVITY_TRACKER_IMAGE_TAG:-latest}
|
||||
container_name: activity-tracker
|
||||
@@ -718,11 +392,7 @@ services:
|
||||
- TRACKER_TZ=${TRACKER_TZ:-}
|
||||
- AUTH_VALIDATE_URL=http://${BACKEND_HOST}:${BACKEND_PORT}/auth/validate-admin
|
||||
|
||||
# Echoes Caddy's JSON request-body log to its own stdout, and does nothing
|
||||
# else. It exists so Dozzle shows the payloads as a stream of their own,
|
||||
# rendered as JSON fields, instead of interleaved with Caddy's compact access
|
||||
# log and error output. -F re-opens the file after rotation; -n0 skips the
|
||||
# backlog on restart, which stays in the file on the host.
|
||||
# Tails Caddy's payload log so Dozzle shows it as its own stream.
|
||||
traffic:
|
||||
image: busybox:1.38.0
|
||||
container_name: traffic
|
||||
@@ -732,14 +402,8 @@ services:
|
||||
volumes:
|
||||
- ./logs/caddy:/logs:ro
|
||||
|
||||
# Dozzle: a live, searchable web view of every container's logs, served at
|
||||
# /dozzle/ behind the admin login (caddy/routes.caddy). The
|
||||
# `traffic` container is the one to watch for incoming request bodies.
|
||||
#
|
||||
# The Docker socket is mounted :ro, but that only stops the file being
|
||||
# replaced — the API behind it is still fully usable, which is effectively
|
||||
# root on the Pi. Hence: no published port, the admin auth_request in front,
|
||||
# and container actions and shell left at their default of off.
|
||||
# The Docker socket is root-equivalent even :ro, so: no published port,
|
||||
# admin gate in front, container actions left off.
|
||||
dozzle:
|
||||
image: amir20/dozzle:v11.2.0
|
||||
container_name: dozzle
|
||||
@@ -752,23 +416,9 @@ services:
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
# Restarts any container labelled autoheal=true once Docker marks it
|
||||
# unhealthy, which Docker itself never does (restart policies only see the
|
||||
# process exit). Only caddy carries the label today; give it to another
|
||||
# service with a healthcheck to cover that one too. It polls every 5s.
|
||||
#
|
||||
# It needs the Docker socket read-write to restart things, which is root on
|
||||
# the host, so it gets no network at all: nothing can reach it, and it
|
||||
# reaches nothing but the socket. For the same reason the image is pinned BY
|
||||
# DIGEST, never a tag, so a push to Docker Hub cannot gain root here at the
|
||||
# next pull. The digest is the multi-arch index of 1.2.0, the newest tagged
|
||||
# release; it calls the API unversioned, so it keeps working as the engine's
|
||||
# minimum API version moves. To bump: `docker buildx imagetools inspect
|
||||
# willfarrell/autoheal:<tag>` and paste the top-level Digest.
|
||||
#
|
||||
# This is the watchdog retired on 2026-10-01 (.deprecated/autoheal), back
|
||||
# with a label filter instead of `all`, so backend's and python's
|
||||
# healthchecks stay informational.
|
||||
# Restarts containers labelled autoheal=true when unhealthy.
|
||||
# Root via the socket, so: no network, and pinned by digest. To bump:
|
||||
# `docker buildx imagetools inspect willfarrell/autoheal:<tag>`.
|
||||
autoheal:
|
||||
image: willfarrell/autoheal@sha256:31f580ef0279eaced5b38d631b08c474d70d8403c1c2fdd6ddcf2e879d5f3f7c
|
||||
container_name: autoheal
|
||||
@@ -779,22 +429,8 @@ services:
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
# S3-compatible object store holding public uploads (the `uploads` bucket).
|
||||
# The backend writes to it on :3900 once S3_ENDPOINT is set in .env; Caddy
|
||||
# serves /uploads/ from it anonymously on :3902, falling back to the
|
||||
# `uploads` volume; garage-webui manages it via :3903. Nothing is published
|
||||
# to the host. Config is garage/garage.toml (no secrets in it); the two
|
||||
# secrets come from .env through the explicit list below.
|
||||
#
|
||||
# Nothing depends on this container being up. Caddy is deliberately NOT
|
||||
# given it in depends_on: it resolves garage when it dials it, so a missing
|
||||
# or crash-looping garage only makes bucket-only files 404 (everything on
|
||||
# the volume is still served), never Caddy's start; and the backend falls back
|
||||
# to the volume when a write fails.
|
||||
#
|
||||
# FIRST RUN: garage/bootstrap.sh (layout, bucket, key, website access).
|
||||
# The image is FROM scratch — no shell, so no in-container init script and
|
||||
# a healthcheck that calls the binary itself.
|
||||
# Public uploads bucket. Nothing depends on it: Caddy and the backend fall
|
||||
# back to the `uploads` volume. First run: garage/bootstrap.sh.
|
||||
garage:
|
||||
image: dxflrs/garage:v2.5.0
|
||||
container_name: garage
|
||||
@@ -815,17 +451,8 @@ services:
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
# Admin web UI for Garage, served at /garage/ behind Caddy's admin gate.
|
||||
# Manages buckets and keys, and browses/uploads/deletes objects. Its own
|
||||
# login (AUTH_USER_PASS) is left unset because Caddy's admin gate already
|
||||
# requires the site admin — and it holds the admin token, so never publish
|
||||
# its port. It reads the s3/web settings from garage.toml; the token comes
|
||||
# from .env instead, since the file has none.
|
||||
#
|
||||
# Files uploaded here land in the PUBLIC bucket and are served at
|
||||
# /uploads/<path> with none of the backend's checks. Put hand-managed media
|
||||
# under a prefix (e.g. media/) so it can't collide with the backend's
|
||||
# random hex names.
|
||||
# Admin-gated at /garage/; holds the admin token, so never publish it.
|
||||
# Files uploaded here are public at /uploads/ with no backend checks.
|
||||
garage-webui:
|
||||
image: khairul169/garage-webui:1.1.0
|
||||
container_name: garage-webui
|
||||
@@ -840,9 +467,7 @@ services:
|
||||
- API_ADMIN_KEY=${GARAGE_ADMIN_TOKEN}
|
||||
- S3_ENDPOINT_URL=http://garage:3900
|
||||
- S3_REGION=garage
|
||||
# The image has no /tmp, and Go spools any multipart upload over 32MB to
|
||||
# a temp file there, so without this every large upload fails with
|
||||
# "open /tmp/multipart-…: no such file or directory".
|
||||
# No /tmp in the image; large multipart uploads spool there.
|
||||
tmpfs:
|
||||
- /tmp
|
||||
volumes:
|
||||
|
||||
Reference in New Issue
Block a user