Document codebase: comments, per-area READMEs, deployment guide
Readability pass across all four areas of the stack. Comments explain why rather than what, concentrated at the points where behaviour is non-obvious: concurrency, caching, auth, scraping and nginx templating. Backend: doc comments on every exported declaration across handlers, services, models and resolvers. Resolver commentary lives inside function bodies so gqlgen does not strip it on regeneration; schema files use # comments rather than description blocks so introspection output is unchanged. Extracted the duplicated auth-cookie blocks into helpers. Frontend: header comments on every component, store and view, including STATUS: notes marking which of the parallel/legacy views are still live. Documented the non-reactive animation-state pattern, the homeData hub and the WebSocket stale-socket guard. Removed a few dead imports and named the reconnect-backoff and poll-interval constants. Python: module and function docstrings covering the Travelodge scraping contract, the deadline threading, the two-executor concurrency and the NDJSON streaming protocol. Infra: header blocks on every compose file, nginx template, Dockerfile and entrypoint, covering the config selection, envsubst allow-lists, rate-limit semantics and volume persistence. Hoisted the duplicated envsubst variable list in nginx/entrypoint.sh. New: backend/README.md, python/README.md, DEPLOYMENT.md, .env.example, backend/graph/doc.go. Refreshed vue/README.md. Corrected CLAUDE.md, which stated a 24h access token where main.go sets 7 days. No behaviour change. go build/vet, vite build, py_compile and docker compose config all pass. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
@@ -1,10 +1,73 @@
|
||||
#!/bin/sh
|
||||
# =============================================================================
|
||||
# certbot entrypoint — obtains the TLS certificate once, then renews forever.
|
||||
#
|
||||
# WHAT IT DOES
|
||||
# 1. One blocking `certonly` run to get (or confirm) a certificate for the
|
||||
# apex domain and its www alias.
|
||||
# 2. Then loops forever: `certbot renew` every 12 hours.
|
||||
#
|
||||
# WHEN IT RUNS
|
||||
# Production only. docker-compose.dev.yml puts this service in the `disabled`
|
||||
# profile, so `docker compose -f docker-compose.yml -f docker-compose.dev.yml
|
||||
# up` never starts it and dev uses nginx's self-signed localhost cert instead.
|
||||
#
|
||||
# HOW VALIDATION WORKS (--webroot)
|
||||
# Let's Encrypt HTTP-01: certbot writes a challenge token into
|
||||
# /var/www/certbot/.well-known/acme-challenge/ and Let's Encrypt fetches it
|
||||
# over plain HTTP on port 80. certbot itself listens on nothing — nginx is
|
||||
# the server that answers. /var/www/certbot is the ./certbot/www bind mount,
|
||||
# mounted into BOTH containers, which is what makes this work. Every nginx
|
||||
# template (including the bootstrap nginx_setup.conf) serves that path.
|
||||
# See nginx/entrypoint.sh for the first-issuance chicken-and-egg ordering.
|
||||
#
|
||||
# CERT STORAGE / SHARING
|
||||
# /etc/letsencrypt is the ./certbot/conf bind mount, also mounted read-write
|
||||
# into nginx. That directory is the private key material — it is gitignored
|
||||
# and must never be committed.
|
||||
#
|
||||
# RENEWAL TIMING AND THE RELOAD SIGNAL
|
||||
# `certbot renew` is a no-op unless the cert is within 30 days of expiry, so
|
||||
# running it every 12h is safe and well inside Let's Encrypt's rate limits —
|
||||
# it just means the renewal window is checked twice a day rather than once a
|
||||
# month. Certificates are valid 90 days, so a renewal lands ~day 60.
|
||||
#
|
||||
# IMPORTANT CAVEAT: there is NO --deploy-hook here, and this container cannot
|
||||
# signal nginx (no docker socket, no shared PID namespace). nginx loads the
|
||||
# certificate files at startup and keeps them in memory, so a freshly renewed
|
||||
# certificate is NOT picked up until nginx is reloaded or restarted. In
|
||||
# practice the site is redeployed often enough (the Gitea Actions deploy
|
||||
# workflow runs `docker compose up -d --build` on every push to main, which
|
||||
# recreates nginx) that this has not bitten — but on a quiet month it could.
|
||||
# See DEPLOYMENT.md "Renew certificates" for the manual reload, and the
|
||||
# proposal to add a reload hook.
|
||||
#
|
||||
# ENV VARS REQUIRED (from ./.env via `env_file`)
|
||||
# DOMAIN apex domain; both $DOMAIN and www.$DOMAIN go on one certificate,
|
||||
# filed under --cert-name $DOMAIN so the path nginx expects
|
||||
# (/etc/letsencrypt/live/$DOMAIN/) is stable regardless of which
|
||||
# name certbot would otherwise have chosen.
|
||||
# EMAIL registration/expiry-notice address for the ACME account.
|
||||
#
|
||||
# FLAGS WORTH KNOWING
|
||||
# --agree-tos --non-interactive never prompt; required in a container.
|
||||
# --expand if a cert already exists under this name but
|
||||
# covers a different set of names, replace it
|
||||
# rather than erroring out.
|
||||
#
|
||||
# ASSUMES EXISTS
|
||||
# /var/www/certbot (shared ACME webroot, served by nginx on port 80)
|
||||
# /etc/letsencrypt (persistent cert store, shared with nginx)
|
||||
# Port 80 reachable from the public internet for $DOMAIN and www.$DOMAIN.
|
||||
# =============================================================================
|
||||
|
||||
certbot certonly --webroot -w /var/www/certbot \
|
||||
--email ${EMAIL} \
|
||||
-d ${DOMAIN} -d www.${DOMAIN} \
|
||||
--cert-name ${DOMAIN} \
|
||||
--agree-tos --non-interactive --expand;
|
||||
|
||||
# Exit promptly on `docker compose stop` instead of sitting out the 12h sleep.
|
||||
trap exit TERM;
|
||||
|
||||
while :; do
|
||||
|
||||
Reference in New Issue
Block a user