From 6b0e44a50c5e64dbdb8d139c38f491b6cebc3038 Mon Sep 17 00:00:00 2001 From: Michele Bigi Date: Sun, 20 Sep 2026 00:15:34 +0200 Subject: [PATCH] Pin VPS deploy to /root/periscope only. Refuse update-periscope.sh unless dirname resolves to the canonical checkout, set compose project name periscope, and document that the GitHub clone URL may still be manvalan/pinscope. --- README.md | 11 +++++++++-- docker-compose.yml | 4 ++++ scripts/update-periscope.sh | 25 +++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 06536db..407af9e 100644 --- a/README.md +++ b/README.md @@ -68,13 +68,20 @@ Backend on port 8080, frontend on port 3000. ### Update a live instance (e.g. periscope.michelebigi.it) -On the server, from the Periscope checkout: +One checkout on the VPS: **`/root/periscope`**. The GitHub clone URL may still be `manvalan/pinscope`; clone into that path so the folder is not `pinscope`: ```bash +git clone git@github.com:manvalan/pinscope.git /root/periscope +``` + +Do not keep a second live tree under `/root/pinscope` (or `/opt/pinscope`). Stop compose there, then deploy only from the canonical root: + +```bash +cd /root/periscope ./scripts/update-periscope.sh ``` -The script pulls the current branch, writes `NEXT_PUBLIC_API_URL` / `CORS_ORIGINS` for `https://periscope.michelebigi.it`, rebuilds both Docker images, and leaves `data/` alone. First run: put `DEEPSEEK_API_KEY` in `.env` at the repo root (compose reads that file). `--no-pull` skips git. `SITE=https://other.host ./scripts/update-periscope.sh` overrides the public URL. +The script cds via `dirname "$0"/..` (no `find`). It refuses to run if the resolved root is not `/root/periscope`. Compose project name is `periscope`. It pulls the current branch, writes `NEXT_PUBLIC_API_URL` / `CORS_ORIGINS` for `https://periscope.michelebigi.it`, rebuilds both Docker images, and leaves `data/` alone. First run: put `DEEPSEEK_API_KEY` in `.env` at the repo root (compose reads that file). `--no-pull` skips git. `SITE=https://other.host ./scripts/update-periscope.sh` overrides the public URL. Do not set `ENVIRONMENT=production` unless Clerk auth is configured — that flag refuses to boot with auth disabled. diff --git a/docker-compose.yml b/docker-compose.yml index 2c6de20..4aa406b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,7 @@ +# Canonical compose project on the VPS is "periscope" (not the GitHub +# clone folder name "pinscope"). Bind mounts stay relative to the checkout. +name: periscope + services: backend: diff --git a/scripts/update-periscope.sh b/scripts/update-periscope.sh index 9b2e3c4..52da74a 100755 --- a/scripts/update-periscope.sh +++ b/scripts/update-periscope.sh @@ -1,24 +1,35 @@ #!/usr/bin/env bash # Rebuild and restart the Periscope stack on the production host -# (periscope.michelebigi.it). Run from anywhere: +# (periscope.michelebigi.it). # +# Canonical live checkout (one tree only): +# /root/periscope +# Clone URL may still be github.com/manvalan/pinscope — clone into that path: +# git clone git@github.com:manvalan/pinscope.git /root/periscope +# +# Resolve the repo root from this script's location only (no find): +# cd /root/periscope # ./scripts/update-periscope.sh +# or: +# /root/periscope/scripts/update-periscope.sh # # Optional: # SITE=https://periscope.michelebigi.it ./scripts/update-periscope.sh # ./scripts/update-periscope.sh --no-pull +# CANONICAL_ROOT=/other/periscope ./scripts/update-periscope.sh # # Does not touch ./data (projects + component library). set -euo pipefail SITE="${SITE:-https://periscope.michelebigi.it}" +CANONICAL_ROOT="${CANONICAL_ROOT:-/root/periscope}" DO_PULL=1 for arg in "$@"; do case "$arg" in --no-pull) DO_PULL=0 ;; -h|--help) - sed -n '2,12p' "$0" + sed -n '2,22p' "$0" exit 0 ;; *) @@ -35,6 +46,14 @@ cd "$ROOT" log() { printf '\n==> %s\n' "$*"; } die() { printf 'error: %s\n' "$*" >&2; exit 1; } +if [[ "$ROOT" != "$CANONICAL_ROOT" ]]; then + die "Checkout is $ROOT; live deploy must be $CANONICAL_ROOT. +Stop compose in the old tree (often /root/pinscope), move or clone this +repo to $CANONICAL_ROOT (keep .env and data/), then run +$CANONICAL_ROOT/scripts/update-periscope.sh +Override only if the host layout differs: CANONICAL_ROOT=$ROOT $0" +fi + if [[ "${ENVIRONMENT:-}" == "production" ]]; then die "ENVIRONMENT=production is set. The backend will refuse to start without Clerk. Unset it for this self-hosted instance." fi @@ -43,6 +62,8 @@ if [[ ! -f docker-compose.yml ]]; then die "docker-compose.yml not found in $ROOT — run this from the Periscope checkout." fi +log "checkout $ROOT (compose project: periscope)" + compose() { if docker compose version >/dev/null 2>&1; then docker compose "$@"