|
|
|
@@ -11,8 +11,11 @@ docker image inspect "$IMAGE" >/dev/null
|
|
|
|
|
ROOT=/opt/prompt-preview
|
|
|
|
|
exec 7>/var/lock/prompt-preview-init.lock
|
|
|
|
|
flock -w 30 7
|
|
|
|
|
if [ -s "$ROOT/fingerprint" ]; then echo 'Already initialized; use sync.sh, or perform an explicit manual refresh' >&2; exit 1; fi
|
|
|
|
|
if ss -H -ltn "sport = :$PORT" | grep -q .; then echo "Preview port $PORT is occupied; choose another PREVIEW_PORT" >&2; exit 1; fi
|
|
|
|
|
if [ -f "$ROOT/ready" ]; then echo 'Already initialized; use sync.sh, or perform an explicit manual refresh' >&2; exit 1; fi
|
|
|
|
|
if ss -H -ltn "sport = :$PORT" | grep -q .; then
|
|
|
|
|
project=$(docker inspect --format '{{index .Config.Labels "com.docker.compose.project"}}' prompt-preview-waterfall-wiki-1 2>/dev/null || true)
|
|
|
|
|
[[ "$project" == prompt-preview ]] || { echo "Preview port $PORT is occupied" >&2; exit 1; }
|
|
|
|
|
fi
|
|
|
|
|
# The prebuilt tooling image must match dependency, startup and schema inputs.
|
|
|
|
|
expected=$(node "$SOURCE/scripts/preview/fingerprint.mjs" "$SOURCE")
|
|
|
|
|
actual=$(docker run --rm --entrypoint node \
|
|
|
|
@@ -44,14 +47,16 @@ compose run --rm --no-deps prepare-tools
|
|
|
|
|
compose run --rm --no-deps auth-admin
|
|
|
|
|
compose run --rm --no-deps migrate
|
|
|
|
|
# The dependency volume is seeded from the already-verified image, no npm install.
|
|
|
|
|
compose up -d --no-build --no-recreate --no-deps waterfall-wiki
|
|
|
|
|
compose up -d --no-build --no-deps waterfall-wiki
|
|
|
|
|
printf '%s\n' "$expected" > "$ROOT/fingerprint"
|
|
|
|
|
for attempt in {1..90}; do
|
|
|
|
|
if curl -fsS --max-time 5 "http://127.0.0.1:$PORT/api/health" >/dev/null; then
|
|
|
|
|
if curl -fsS --max-time 5 "http://127.0.0.1:$PORT/api/health" >/dev/null 2>&1; then
|
|
|
|
|
touch "$ROOT/ready"
|
|
|
|
|
echo "Preview initialized on port $PORT; pnpm dev remains running"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
sleep 2
|
|
|
|
|
done
|
|
|
|
|
compose logs --tail 60 waterfall-wiki
|
|
|
|
|
compose stop waterfall-wiki
|
|
|
|
|
exit 1
|
|
|
|
|