Add LAN-dev registry-pull artifacts: docker-compose.dev.yml + deploy-dev.sh
This commit is contained in:
parent
bbc9b28bfd
commit
75201ef533
2 changed files with 121 additions and 0 deletions
74
deploy/deploy-dev.sh
Executable file
74
deploy/deploy-dev.sh
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env bash
|
||||
# LAN-dev deploy: roll the per-service registry-pull stack (see deploy.sh) onto
|
||||
# the ~/thermograph-dev overlay instead of prod/beta's loopback-only stack.
|
||||
#
|
||||
# *** PREREQUISITE -- READ BEFORE RUNNING ***
|
||||
# This script assumes $APP_DIR is a checkout of THIS repo (thermograph-infra),
|
||||
# the same way /opt/thermograph is on prod/beta. As of this writing, the LAN
|
||||
# dev box's ~/thermograph-dev is still provisioned by deploy/provision-dev-lan.sh
|
||||
# cloning the OLD MONOREPO (thermograph.git, see its REPO_URL default) and running
|
||||
# the monorepo's build-in-place deploy/deploy-dev.sh -- an app-code checkout with
|
||||
# Dockerfiles, not an infra checkout with compose files. Until provision-dev-lan.sh
|
||||
# (and its REPO_URL) is repointed at thermograph-infra and ~/thermograph-dev is
|
||||
# reprovisioned from that, THIS SCRIPT IS INERT: pointing it at the live dev box
|
||||
# today would `git fetch`/`reset` the wrong repository entirely. Do not treat this
|
||||
# as a live deploy path until that reprovision happens -- it exists now so the infra
|
||||
# repo carries its own dev-deploy story from day one, same as it already carries
|
||||
# deploy.sh for prod/beta.
|
||||
#
|
||||
# Design: a thin wrapper around deploy.sh, not a duplicate. deploy.sh already owns
|
||||
# the entire per-service registry-pull mechanism -- secrets sourcing, docker login,
|
||||
# the retry-pull loop, --no-deps single-service rolls vs. --remove-orphans `all`,
|
||||
# .image-tags.env persistence, and the 8137/8080 health checks. None of that is
|
||||
# dev-specific; the only things LAN dev actually changes are WHERE it deploys
|
||||
# (a separate checkout + branch) and WHICH compose files are in play (the base
|
||||
# file plus docker-compose.dev.yml's uncapped/LAN-published overrides). Both are
|
||||
# expressible as environment (APP_DIR/BRANCH that deploy.sh already reads, and
|
||||
# docker compose's own COMPOSE_FILE variable), so re-exec'ing deploy.sh with that
|
||||
# environment set covers it with no forked copy of the pull/roll/health logic to
|
||||
# drift out of sync. If LAN dev ever needs deploy logic that genuinely diverges
|
||||
# from prod/beta (not just "different files/directory"), promote this to a
|
||||
# standalone script at that point rather than growing special cases into deploy.sh.
|
||||
#
|
||||
# Usage (once the prerequisite above is satisfied), mirrors deploy.sh directly:
|
||||
# # roll just the backend onto a dev-tagged image:
|
||||
# ssh dev-box 'SERVICE=backend BACKEND_IMAGE_TAG=sha-<12hex> deploy/deploy-dev.sh'
|
||||
# # bring the whole dev stack up (both tags required, same as deploy.sh):
|
||||
# ssh dev-box 'SERVICE=all BACKEND_IMAGE_TAG=sha-<a> FRONTEND_IMAGE_TAG=sha-<b> deploy/deploy-dev.sh'
|
||||
set -euo pipefail
|
||||
|
||||
# Dev context: a separate checkout + branch from prod/beta's /opt/thermograph
|
||||
# (main), so a dev deploy never touches or is touched by the prod/beta one.
|
||||
APP_DIR="${APP_DIR:-$HOME/thermograph-dev}"
|
||||
BRANCH="${BRANCH:-dev}"
|
||||
export APP_DIR BRANCH
|
||||
|
||||
# Point every `docker compose` invocation inside deploy.sh at the LAN-dev overlay
|
||||
# (uncapped CPU, backend published on 0.0.0.0:8137, frontend unpublished -- see
|
||||
# docker-compose.dev.yml) without deploy.sh needing to know dev exists at all.
|
||||
# COMPOSE_FILE is docker compose's own env var for this; ':' is the Linux/macOS
|
||||
# path-list separator it expects (';' only on Windows).
|
||||
export COMPOSE_FILE="docker-compose.yml:docker-compose.dev.yml"
|
||||
|
||||
# deploy.sh needs POSTGRES_PASSWORD to interpolate the compose file (both to init
|
||||
# the db container and to build backend's THERMOGRAPH_DATABASE_URL) -- normally
|
||||
# supplied by /etc/thermograph.env via render-secrets.sh's SOPS render, but dev has
|
||||
# no entry in deploy/secrets/ (only common/beta/prod.yaml exist), so
|
||||
# render_thermograph_secrets degrades to a no-op here (see render-secrets.sh) and
|
||||
# /etc/thermograph.env likely doesn't exist on a fresh dev box either. Postgres is
|
||||
# loopback-only inside the compose network on dev (never published, no real
|
||||
# credentials on this box), so a fixed default is fine -- same value the monorepo's
|
||||
# deploy-dev.sh used historically. Override via the environment if you ever want a
|
||||
# different one; this only sets it when nothing else already has.
|
||||
export POSTGRES_PASSWORD="${POSTGRES_PASSWORD:-thermograph-dev}"
|
||||
|
||||
# REGISTRY_TOKEN (for `docker login` in deploy.sh) is a REAL credential -- read
|
||||
# access to git.thermograph.org's registry -- and deliberately has NO default here.
|
||||
# Until dev gets its own deploy/secrets/dev.yaml entry (see deploy/secrets/README.md)
|
||||
# it must come from the calling environment: exported by hand for a manual run, or
|
||||
# injected by whatever eventually SSHes in to trigger a dev deploy (analogous to
|
||||
# how deploy.yml supplies it for prod/beta today). deploy.sh's own `docker login`
|
||||
# step fails loudly if it's unset or wrong -- nothing silently no-ops.
|
||||
|
||||
echo "==> LAN-dev deploy: APP_DIR=$APP_DIR BRANCH=$BRANCH COMPOSE_FILE=$COMPOSE_FILE"
|
||||
exec "$(dirname "$0")/deploy.sh" "$@"
|
||||
47
docker-compose.dev.yml
Normal file
47
docker-compose.dev.yml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# Dev overlay for the LAN dev server (deploy/deploy-dev.sh):
|
||||
#
|
||||
# docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d
|
||||
#
|
||||
# Split-repo adaptation: the monorepo's docker-compose.dev.yml (see
|
||||
# thermograph/docker-compose.dev.yml) overlaid a base file where backend and
|
||||
# frontend had `build: .` -- dev's whole point there was `--build` in place from
|
||||
# the working checkout. This infra repo holds no Dockerfile at all (each service's
|
||||
# lives in its own app repo, thermograph-backend / thermograph-frontend), so the
|
||||
# base docker-compose.yml already has NO `build:` for either service, only
|
||||
# `image: .../${BACKEND_IMAGE_PATH}:${BACKEND_IMAGE_TAG}` (and the frontend
|
||||
# equivalent) -- same registry-pull model as prod/beta, just pointed at a dev tag
|
||||
# by deploy-dev.sh. This overlay must NOT reintroduce `build:`; it only relaxes
|
||||
# resource caps and LAN-exposes a port, same as the monorepo overlay did.
|
||||
#
|
||||
# Differences from the prod stack (unchanged intent from the monorepo overlay):
|
||||
# 1. backend is published on ALL interfaces (0.0.0.0:8137), not loopback, so
|
||||
# phones and other devices on the Wi-Fi can reach the dev server directly --
|
||||
# dev has no Caddy in front (prod does, which is why the base file binds
|
||||
# 127.0.0.1 only).
|
||||
# 2. frontend's port publish is dropped entirely -- dev has no Caddy to reach it
|
||||
# directly, so it stays compose-internal-only, reached solely through
|
||||
# backend's own reverse-proxy fallback (THERMOGRAPH_FRONTEND_BASE_INTERNAL,
|
||||
# see backend/web/app.py's _proxy_to_frontend in the backend repo). This
|
||||
# keeps the dev stack serving the one URL it always has, at :8137.
|
||||
# 3. The CPU caps are removed -- dev runs UNCAPPED (no thread/CPU limits), unlike
|
||||
# prod's backend=4 / frontend=2 / db=2 allocation. `!reset` drops the base
|
||||
# value (both the top-level `cpus:` and the Swarm-style `deploy.resources`
|
||||
# block the base file carries for parity).
|
||||
services:
|
||||
backend:
|
||||
ports: !override
|
||||
- "8137:8137"
|
||||
cpus: !reset null
|
||||
deploy: !reset null
|
||||
frontend:
|
||||
ports: !reset null
|
||||
cpus: !reset null
|
||||
deploy: !reset null
|
||||
db:
|
||||
cpus: !reset null
|
||||
deploy: !reset null
|
||||
# Uncapped memory on dev too (prod ceilings it at 8g). The Postgres/DuckDB
|
||||
# memory *budget* is still the ~8 GB derived by deploy/db/init/20-tuning.sh from
|
||||
# the default DB_MEMORY (raise DB_MEMORY to give dev more); shm_size stays (it's
|
||||
# required shared memory for parallel query, not a limit).
|
||||
mem_limit: !reset null
|
||||
Loading…
Reference in a new issue