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.
This commit is contained in:
2026-09-20 00:15:34 +02:00
parent 16c606ae3d
commit 6b0e44a50c
3 changed files with 36 additions and 4 deletions
+9 -2
View File
@@ -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.
+4
View File
@@ -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:
+23 -2
View File
@@ -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 "$@"