Cloud container: PULL_INTERVAL=0 never pulls, so a mounted checkout is never reset

The pull loop follows BRANCH with `git reset --hard FETCH_HEAD` whenever the branch moves.
In the cloud that is the point. On a checkout mounted from someone's machine it would wipe
their commits and uncommitted work. PULL_INTERVAL=0 now skips the loop entirely: no fetch,
no reset, one line in /tmp/pull.log saying so. Every other value behaves as before.

Checked both ways on a throwaway repo whose remote had moved on and whose working copy held an
uncommitted edit: with 0 the commit and the edit stay; with 1 (the control) the loop resets
both, as it always has.
This commit is contained in:
Doxa Maps 2026-09-29 02:30:16 +00:00
parent 7d2decab5b
commit e9e16c7aaf
2 changed files with 8 additions and 2 deletions

View file

@ -22,7 +22,7 @@ and the hot-reload websocket. Only people in the allowed groups get in.
|---|---|---|
| `REPO_URL` | yes | the dx-maps git URL to clone |
| `BRANCH` | no (`main`) | the branch to follow |
| `PULL_INTERVAL` | no (`15`) | seconds between pulls |
| `PULL_INTERVAL` | no (`15`) | seconds between pulls; `0` never pulls (for a checkout mounted from your machine: a pull resets it hard) |
| `GIT_TOKEN` | private repos | a read token for the clone and pulls |
| `PORT` | no (`5173`) | the port the container serves on |
| `HMR_CLIENT_PORT`, `HMR_PROTOCOL` | behind HTTPS | `443` and `wss`, so browsers reach the hot-reload websocket |

View file

@ -1,6 +1,6 @@
#!/bin/bash
# dx-maps cloud dev server, run by the image's /boot.sh from the cloned repo (see Dockerfile).
# 1. install, 2. pull BRANCH every PULL_INTERVAL s (Vite hot-reloads what changed),
# 1. install, 2. pull BRANCH every PULL_INTERVAL s (Vite hot-reloads what changed; 0 = never pull),
# 3. serve: Vite alone, or behind an OIDC sign-in when OIDC_ISSUER is set.
set -u
cd /app/repo
@ -8,6 +8,11 @@ BRANCH="${BRANCH:-main}"; PORT="${PORT:-5173}"
echo "$(date -u +%FT%TZ) START at $(git rev-parse --short HEAD)" | tee -a /tmp/pull.log
bun install --frozen-lockfile || bun install
# PULL_INTERVAL=0: never pull, never reset. For a checkout mounted from someone's machine, where the
# loop's `git reset --hard` would wipe their work.
if [ "${PULL_INTERVAL:-15}" = 0 ]; then
echo "$(date -u +%FT%TZ) PULL_INTERVAL=0: not following $BRANCH; the checkout is left as it is" | tee -a /tmp/pull.log
else
(
while true; do
sleep "${PULL_INTERVAL:-15}"
@ -38,6 +43,7 @@ bun install --frozen-lockfile || bun install
fi
done
) &
fi
CONFIG=/app/repo/deployment/cloud/vite.cloud.config.mjs