Deploy path: pin the project name the instance already runs under
The file this deployment is pasted from had no `name:`, so the project name came from the directory Dokploy writes it in. It already runs as `kuentagym`, and the volumes are pinned by `name:` either way — this just stops a pasted copy from renaming the stack and the containers in every `docker` command and log line.
This commit is contained in:
1 parent
cc257d2671
commit
f36a32e8af
1 file changed
-70
@@ -1,73 +1,3 @@
|
||||
# Build-from-source stack for a host that builds at deploy time (Dokploy and friends).
|
||||
#
|
||||
# This is the same five-service shape the instance at gym.dploy.lol runs: `source` clones the
|
||||
# repository into a volume, `api` installs and runs the backend from that clone, `web-build`
|
||||
# compiles the frontend, and `web` serves the result with nginx. Nothing is pulled from a
|
||||
# registry, so `scripts/build-images.sh` and `.gitea/workflows/docker-publish.yml` are not part
|
||||
# of this path at all.
|
||||
#
|
||||
# Five things here are easy to get wrong, and all five are load-bearing:
|
||||
#
|
||||
# 1. `web-build` copies the WHOLE repository into /app and builds from /app/frontend, not
|
||||
# frontend/ on its own. The frontend imports the Coach's core from outside its own directory
|
||||
# (`frontend/src/lib/coach-local.js` and `views/CoachSetup.jsx` reach into
|
||||
# `../../../api/coach/core/`), so a build stage that only has frontend/ fails with nine
|
||||
# UNRESOLVED_IMPORT errors. The repo's own web/Dockerfile copies api/coach/core/ into its
|
||||
# build stage for the same reason.
|
||||
#
|
||||
# 2. The volumes are pinned with `name:`. They hold the users, passkeys, workouts and weigh-ins
|
||||
# — `kuentagym-data` above all. Those names are this deployment's existing volumes; they are
|
||||
# spelled out so a restyled stack keeps pointing at the same data instead of silently
|
||||
# creating empty ones. Never change them without moving the data first, and never run
|
||||
# `docker compose down -v` — `-v` deletes the volumes, which is every logged set and every
|
||||
# weigh-in. A plain `docker compose down` is safe. Check yours with `docker volume ls`.
|
||||
#
|
||||
# 3. nginx needs `client_max_body_size`, and needs it in two sizes. Its default request limit is
|
||||
# 1 MB, and the app PUTs the whole profile to /api/data on every change — a couple of years of
|
||||
# training passes 1 MB and the sync then fails with a 413 the UI cannot explain. So the bulk
|
||||
# of /api is 5m, matching the API's own MAX_BODY. But the Apple Health ingest takes whole
|
||||
# exports: a first sync of a year of raw samples is tens of megabytes, and the API allows
|
||||
# that one route 32 MB (VITALS_MAX_BODY in api/server.js). One global number cannot do both,
|
||||
# which is why the generated config below has a second location for that one path — nginx
|
||||
# picks the longest matching prefix, so /api/vitals/ingest gets 32m and everything else keeps
|
||||
# 5m.
|
||||
#
|
||||
# This inline config is the one this deployment actually runs; web/nginx.conf.template is for
|
||||
# the registry-image path (docker-compose.yml) and is NOT read here. A change to the limits
|
||||
# has to be made in both, or the two deployment shapes diverge.
|
||||
#
|
||||
# 4. X-Forwarded-For uses the APPEND form here, unlike web/nginx.conf.template. In this shape
|
||||
# nginx is NOT the edge: Traefik terminates TLS in front of it, so `$remote_addr` is Traefik's
|
||||
# own address and the real client only survives in the header Traefik sends.
|
||||
# `$proxy_add_x_forwarded_for` carries that one through as the first entry, which is exactly
|
||||
# what the API reads (see clientIp in api/server.js). The registry template does the opposite
|
||||
# for the opposite reason — there the web container answers the internet directly, so the
|
||||
# incoming header can be forged and only $remote_addr can be trusted.
|
||||
#
|
||||
# 5. nginx resolves `api` through a VARIABLE, not by name. A plain `proxy_pass http://api:3000`
|
||||
# is resolved once, when nginx starts, and the address is then pinned for the life of the
|
||||
# container: recreate the api — a deploy that changes its configuration, a `--force-recreate`,
|
||||
# a manual restart that gives it a new IP — and every /api call answers 502 until the web
|
||||
# container is restarted too, including /api/config, so the app cannot even load. The
|
||||
# `resolver` + `set $api_upstream` pair below makes nginx ask again on every request, which is
|
||||
# the same fix web/nginx.conf.template carries (and explains at length) for the other shape.
|
||||
#
|
||||
# To deploy a change to the code, force the one-shot services to run again — `source` and
|
||||
# `web-build` have `restart: "no"`, so compose leaves them alone when their configuration has not
|
||||
# changed:
|
||||
#
|
||||
# docker compose up -d --force-recreate
|
||||
#
|
||||
# That is also how the `api` service picks up new code: it copies the clone into /app at container
|
||||
# start, so an `api` that was not recreated keeps running the previous revision while `web-build`
|
||||
# happily serves the new frontend. Recreate `web` in the same command, and not on its own: its
|
||||
# `proxy_pass http://api:3000` is resolved once at start-up, so a recreated api means a new IP and
|
||||
# an nginx still pointing at the old one answers 502 on every /api call.
|
||||
#
|
||||
# Set RP_ID, RP_NAME and ORIGIN in the host's environment (or its .env). RP_ID must be the exact
|
||||
# hostname the app is served from — passkeys are bound to it — and RP_NAME is what the passkey
|
||||
# prompt shows, so set it to KuentaGYM.
|
||||
|
||||
name: kuentagym
|
||||
|
||||
services:
|
||||
|
||||
Reference in new issue
Block a user