Frontend: src/uploads.js is the one way to store or show a file (uploadFile, ACCEPT, kindOf, isUploadUrl, tagFor, mediaSize). Chat, the box editor, canvas drops and the background editor all use it; views/home3/upload.js and the chat store's own axios call are gone. Backend: POST /api/uploads (was /messages/upload) is a thin wrapper over services.Uploads.Save, which owns validation, naming and storage. The three per-extension maps are now one UploadTypes table, and a refused file is an *UploadError whose message is safe to show. nginx now fetches /uploads/ from Garage first and falls back to the volume on a 404 or any 5xx, so the bucket is the source of truth and deleting a file in garage-webui unpublishes it, while a Garage outage still only affects bucket-only files. Co-Authored-By: Claude Opus 5.5 <[email protected]>
767 lines
35 KiB
YAML
767 lines
35 KiB
YAML
# =============================================================================
|
|
# 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 the Raspberry Pi, 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},
|
|
# 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
|
|
# inline defaults.
|
|
#
|
|
# NAMING CONVENTION / WHY container_name IS SET FROM env
|
|
# Service discovery is by container name on app-network. nginx builds its
|
|
# upstreams from the same ${*_HOST} variables (nginx/entrypoint.sh), 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 nginx at it — do not change one without the other.
|
|
#
|
|
# WHAT IS PUBLISHED TO THE HOST
|
|
# Only nginx (80, 443), gitea (3000 HTTP, 2222 SSH) 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 nginx. Web traffic can
|
|
# also arrive through the `cloudflared` tunnel, which publishes nothing.
|
|
# =============================================================================
|
|
|
|
networks:
|
|
# One flat bridge network; every service resolves every other by container
|
|
# name via docker's embedded DNS at 172.28.0.11 (nginx configs point their
|
|
# `resolver` there). The subnet is pinned explicitly so it cannot collide
|
|
# with the Pi's LAN range or wander between compose versions.
|
|
app-network:
|
|
driver: bridge
|
|
ipam:
|
|
config:
|
|
- subnet: 172.28.0.0/16
|
|
|
|
# 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,
|
|
# ./certbot/conf) live in the repo checkout on the Pi 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.
|
|
dbdata:
|
|
# File upload — PERSISTENT. Written by the backend at /backend/uploads,
|
|
# served read-only by nginx at /uploads/. Shared so nginx 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. nginx serves
|
|
# /uploads/ from the bucket first and only 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.
|
|
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; nginx mounts
|
|
# it at /etc/nginx/html and serves it. Repopulated on every rebuild.
|
|
vue_dist:
|
|
|
|
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.
|
|
vue:
|
|
build:
|
|
context: ./vue
|
|
dockerfile: Dockerfile
|
|
container_name: vue
|
|
volumes:
|
|
- vue_dist:/output
|
|
networks:
|
|
- app-network
|
|
|
|
# The only public entrypoint. Terminates TLS, serves the SPA, reverse-proxies
|
|
# everything else. Its config is chosen at container start — see
|
|
# nginx/entrypoint.sh for the DEV_MODE / cert-present / bootstrap decision.
|
|
#
|
|
# START ORDERING: these `depends_on` entries are the plain list form, which
|
|
# only waits for each container to be *created and started*, NOT for it to be
|
|
# ready or healthy. That is deliberate — nginx's `resolver 127.0.0.11` means
|
|
# upstreams are resolved per-request, so a late-starting backend produces a
|
|
# temporary 502 rather than a failed nginx boot. The one ordering nginx
|
|
# genuinely cares about (the Vue build finishing) is handled by the polling
|
|
# loop in its entrypoint, because depends_on cannot express "wait for a
|
|
# one-shot container to exit successfully" here.
|
|
nginx:
|
|
build:
|
|
context: ./nginx
|
|
dockerfile: Dockerfile
|
|
container_name: nginx
|
|
env_file: ./.env
|
|
restart: always
|
|
depends_on:
|
|
- vue
|
|
- backend
|
|
- icecast2
|
|
- gitea
|
|
- silverbullet
|
|
- silverbullet-public
|
|
- python
|
|
- jobs
|
|
- activity-tracker
|
|
- dozzle
|
|
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://nginx` would fail the
|
|
# name check). Any other container that calls the public site now
|
|
# reaches nginx directly instead of hairpinning through the internet.
|
|
aliases:
|
|
- ${DOMAIN}
|
|
- www.${DOMAIN}
|
|
ports:
|
|
- 80:80
|
|
- 443:443
|
|
volumes:
|
|
# Shared with certbot: the cert store nginx reads and certbot writes.
|
|
# PERSISTENT, and private key material — gitignored, never commit.
|
|
- ./certbot/conf:/etc/letsencrypt
|
|
# Shared with certbot: the ACME HTTP-01 challenge webroot. certbot drops
|
|
# tokens in, nginx serves them on port 80.
|
|
- ./certbot/www:/var/www/certbot
|
|
- uploads:/uploads
|
|
# The SPA written by the one-shot `vue` container.
|
|
- vue_dist:/etc/nginx/html
|
|
# The JSON request-body log (nginx/payload_log.conf), kept on the host so
|
|
# it survives rebuilds and the `traffic` container can tail it. Grows
|
|
# without bound unless rotated — see DEPLOYMENT.md.
|
|
- ./logs/nginx:/var/log/nginx/payloads
|
|
|
|
# Obtains the cert once, then renews every 12h forever. Disabled in dev via
|
|
# the `disabled` profile in docker-compose.dev.yml. Note this is the stock
|
|
# certbot image with our script bind-mounted over the entrypoint, so editing
|
|
# certbot/entrypoint.sh takes effect on restart with no rebuild. Version is
|
|
# pinned so a certbot release cannot change behaviour under us on redeploy.
|
|
# The dns-cloudflare variant is plain certbot plus the Cloudflare DNS plugin:
|
|
# with CLOUDFLARE_DNS_API_TOKEN set it validates over DNS, so renewal needs
|
|
# no inbound port, and without it falls back to the webroot method.
|
|
certbot:
|
|
image: certbot/dns-cloudflare:v3.1.0
|
|
container_name: certbot
|
|
volumes:
|
|
- ./certbot/entrypoint.sh:/entrypoint.sh
|
|
- ./certbot/conf:/etc/letsencrypt
|
|
- ./certbot/www:/var/www/certbot
|
|
entrypoint: ["/entrypoint.sh"]
|
|
env_file:
|
|
- .env
|
|
networks:
|
|
- app-network
|
|
|
|
# Cloudflare Tunnel: an OUTBOUND connection from here to Cloudflare's edge,
|
|
# which then forwards visitors' requests back down it to nginx. 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 nginx's network aliases
|
|
# resolve to nginx itself, so the certificate verifies; nginx'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 nginx can trust the CF-Connecting-IP header from this
|
|
# container and no other (set_real_ip_from in nginx.conf.template). 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.
|
|
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:
|
|
- nginx
|
|
networks:
|
|
app-network:
|
|
ipv4_address: 172.28.255.250
|
|
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
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
|
|
networks:
|
|
- app-network
|
|
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).
|
|
- ./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 nginx serves at /uploads/ — backend writes, nginx 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.
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-qO-", "http://localhost:8080/"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
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.
|
|
# Schema for the app DB comes from GORM auto-migration at backend start —
|
|
# there are no migration files.
|
|
db:
|
|
image: postgres:16
|
|
container_name: "${POSTGRES_HOST}"
|
|
restart: always
|
|
env_file:
|
|
- ./.env
|
|
networks:
|
|
- 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.
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\" -q"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
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-nginx 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 nginx 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:
|
|
build:
|
|
context: ./icecast2
|
|
dockerfile: Dockerfile
|
|
container_name: "${ICECAST_HOST}"
|
|
restart: always
|
|
networks:
|
|
- app-network
|
|
env_file:
|
|
- ./.env
|
|
volumes:
|
|
- ./icecast2/fallback_music:/music:ro
|
|
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 the nginx 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.
|
|
silverbullet:
|
|
image: ghcr.io/silverbulletmd/silverbullet:2.11.0
|
|
container_name: "${SILVERBULLET_HOST:-silverbullet}"
|
|
restart: always
|
|
networks:
|
|
- app-network
|
|
environment:
|
|
SB_PORT: "${SILVERBULLET_PORT:-3000}"
|
|
# The app builds its service-worker scope and asset URLs from this, which
|
|
# is why nginx must NOT strip the /sb/ prefix. See nginx.conf.template.
|
|
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.
|
|
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. nginx deny blocks 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 nginx 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.
|
|
silverbullet-public:
|
|
image: ghcr.io/silverbulletmd/silverbullet:2.11.0
|
|
container_name: "${SILVERBULLET_PUBLIC_HOST:-silverbullet-public}"
|
|
restart: always
|
|
networks:
|
|
- app-network
|
|
environment:
|
|
SB_PORT: "${SILVERBULLET_PUBLIC_PORT:-3000}"
|
|
# Same reason as the editor's SB_URL_PREFIX: nginx 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 nginx/nginx_routes.conf.template, or a new entry here is
|
|
# hidden from the list but still publicly fetchable.
|
|
SB_SPACE_IGNORE: |
|
|
private/
|
|
templates/
|
|
.obsidian
|
|
PUID: "1000"
|
|
PGID: "1000"
|
|
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 the nginx 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.
|
|
silverbullet-git:
|
|
image: alpine/git:v2.49.1
|
|
container_name: "${SILVERBULLET_GIT_HOST:-silverbullet-git}"
|
|
restart: always
|
|
networks:
|
|
- app-network
|
|
# Same uid SilverBullet writes as, so commits don't leave root-owned objects
|
|
# in .git that the host user can no longer clean up.
|
|
user: "1000:1000"
|
|
environment:
|
|
SYNC_INTERVAL: "${SILVERBULLET_GIT_INTERVAL:-300}"
|
|
GIT_AUTHOR_NAME: silverbullet
|
|
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"]
|
|
volumes:
|
|
- ${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 nginx.
|
|
# 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 nginx)
|
|
# makes its Claude call here.
|
|
python:
|
|
build:
|
|
context: ./python
|
|
dockerfile: Dockerfile
|
|
container_name: "${PYTHON_HOST:-python}"
|
|
restart: always
|
|
networks:
|
|
- app-network
|
|
environment:
|
|
- PYTHON_PORT=${PYTHON_PORT:-8000}
|
|
- ROOT_PATH=/py
|
|
- TFL_APP_KEY=${TFL_APP_KEY:-}
|
|
- CLAUDE_API_KEY=${CLAUDE_API_KEY:-}
|
|
- CLAUDE_MODEL=${CLAUDE_MODEL:-}
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request,os; urllib.request.urlopen(f\"http://localhost:{os.environ.get('PYTHON_PORT','8000')}/health\")"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
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. nginx's auth_request 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 nginx's auth_request 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.
|
|
jobs:
|
|
image: adam-french.co.uk/adamf/job-tracker:${JOBS_IMAGE_TAG:-latest}
|
|
container_name: jobs
|
|
restart: always
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
networks:
|
|
- app-network
|
|
environment:
|
|
- DATABASE_URL=postgres://${POSTGRES_JOBS_USER:-jobs}:${POSTGRES_JOBS_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_JOBS_DB:-jobs}?sslmode=disable
|
|
- AUTH_VALIDATE_URL=http://${BACKEND_HOST}:${BACKEND_PORT}/auth/validate-admin
|
|
- CLAUDE_API_KEY=${CLAUDE_API_KEY:-}
|
|
- CLAUDE_MODEL=${CLAUDE_MODEL:-}
|
|
- EMAIL_BACKEND=${EMAIL_BACKEND:-}
|
|
- EMAIL_SYNC_ENABLED=${EMAIL_SYNC_ENABLED:-}
|
|
- EMAIL_SYNC_INTERVAL=${EMAIL_SYNC_INTERVAL:-}
|
|
- MSGRAPH_CLIENT_ID=${MSGRAPH_CLIENT_ID:-}
|
|
- MSGRAPH_CLIENT_SECRET=${MSGRAPH_CLIENT_SECRET:-}
|
|
- MSGRAPH_TENANT_ID=${MSGRAPH_TENANT_ID:-}
|
|
- MSGRAPH_REDIRECT_URI=${MSGRAPH_REDIRECT_URI:-}
|
|
- IMAP_HOST=${IMAP_HOST:-}
|
|
- IMAP_PORT=${IMAP_PORT:-}
|
|
- IMAP_EMAIL=${IMAP_EMAIL:-}
|
|
- IMAP_PASSWORD=${IMAP_PASSWORD:-}
|
|
- JOB_LEADS_ENABLED=${JOB_LEADS_ENABLED:-}
|
|
- JOB_LEADS_INTERVAL=${JOB_LEADS_INTERVAL:-}
|
|
- ADZUNA_APP_ID=${ADZUNA_APP_ID:-}
|
|
- ADZUNA_APP_KEY=${ADZUNA_APP_KEY:-}
|
|
- REED_API_KEY=${REED_API_KEY:-}
|
|
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 over the Docker network when Gitea's push webhook
|
|
# fires (USACO_WEBHOOK_SECRET signs it), and commits the admin's edits
|
|
# (status, link, notes) back with USACO_GIT_TOKEN. ./usaco-data holds only
|
|
# that clone, so deleting it is safe; the image runs as uid 1000, so the
|
|
# directory must be owned by it.
|
|
#
|
|
# 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:
|
|
image: adam-french.co.uk/adamf/usaco:${USACO_IMAGE_TAG:-latest}
|
|
container_name: usaco
|
|
restart: always
|
|
depends_on:
|
|
- gitea
|
|
networks:
|
|
- app-network
|
|
environment:
|
|
- GIT_REMOTE_URL=http://${GITEA_HOST}:${GITEA_PORT}/adamf/usaco.git
|
|
- GIT_TOKEN=${USACO_GIT_TOKEN:-}
|
|
- WEBHOOK_SECRET=${USACO_WEBHOOK_SECRET:-}
|
|
- AUTH_VALIDATE_URL=http://${BACKEND_HOST}:${BACKEND_PORT}/auth/validate-admin
|
|
volumes:
|
|
- ./usaco-data:/data
|
|
|
|
# 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: nginx's auth_request 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:
|
|
image: adam-french.co.uk/adamf/activity-tracker:${ACTIVITY_TRACKER_IMAGE_TAG:-latest}
|
|
container_name: activity-tracker
|
|
restart: always
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
networks:
|
|
- app-network
|
|
environment:
|
|
- DATABASE_URL=postgres://${POSTGRES_TRACKER_USER:-tracker}:${POSTGRES_TRACKER_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_TRACKER_DB:-tracker}?sslmode=disable
|
|
- TRACKER_TZ=${TRACKER_TZ:-}
|
|
- AUTH_VALIDATE_URL=http://${BACKEND_HOST}:${BACKEND_PORT}/auth/validate-admin
|
|
|
|
# Echoes nginx'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 nginx'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.
|
|
traffic:
|
|
image: busybox:1.37.0
|
|
container_name: traffic
|
|
restart: always
|
|
command: ["tail", "-n0", "-F", "/logs/payloads.log"]
|
|
network_mode: none
|
|
volumes:
|
|
- ./logs/nginx:/logs:ro
|
|
|
|
# Dozzle: a live, searchable web view of every container's logs, served at
|
|
# /dozzle/ behind the admin login (nginx/nginx_routes.conf.template). 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.
|
|
dozzle:
|
|
image: amir20/dozzle:v11.2.0
|
|
container_name: dozzle
|
|
restart: always
|
|
networks:
|
|
- app-network
|
|
environment:
|
|
- DOZZLE_BASE=/dozzle
|
|
- DOZZLE_NO_ANALYTICS=true
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
|
|
# S3-compatible object store holding public uploads (the `uploads` bucket).
|
|
# The backend writes to it on :3900 once S3_ENDPOINT is set in .env; nginx
|
|
# 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. nginx is deliberately NOT
|
|
# given it in depends_on: its upstream is a variable, so a missing or
|
|
# crash-looping garage only makes bucket-only files 404 (everything on the
|
|
# volume is still served), never nginx's boot; 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.
|
|
garage:
|
|
image: dxflrs/garage:v2.4.1
|
|
container_name: garage
|
|
restart: always
|
|
networks:
|
|
- app-network
|
|
environment:
|
|
- GARAGE_RPC_SECRET=${GARAGE_RPC_SECRET}
|
|
- GARAGE_ADMIN_TOKEN=${GARAGE_ADMIN_TOKEN}
|
|
volumes:
|
|
- ./garage/garage.toml:/etc/garage.toml:ro
|
|
- garage_meta:/var/lib/garage/meta
|
|
- garage_data:/var/lib/garage/data
|
|
healthcheck:
|
|
test: ["CMD", "/garage", "status"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|
|
|
|
# Admin web UI for Garage, served at /garage/ behind the nginx admin gate.
|
|
# Manages buckets and keys, and browses/uploads/deletes objects. Its own
|
|
# login (AUTH_USER_PASS) is left unset because nginx's auth_request 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.
|
|
garage-webui:
|
|
image: khairul169/garage-webui:1.1.0
|
|
container_name: garage-webui
|
|
restart: always
|
|
depends_on:
|
|
- garage
|
|
networks:
|
|
- app-network
|
|
environment:
|
|
- BASE_PATH=/garage
|
|
- API_BASE_URL=http://garage:3903
|
|
- 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".
|
|
tmpfs:
|
|
- /tmp
|
|
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/).
|
|
#
|
|
# 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.)
|
|
- ./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
|
|
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
|