Give the preview process ownership of its Next cache
Unified application CI and deployment / static-checks (push) Successful in 7s
Remote development preview source sync / sync-source (push) Successful in 1m28s
Unified application CI and deployment / static-checks (pull_request) Successful in 5s
python CI and deployment / static-checks (pull_request) Successful in 3s
Unified application CI and deployment / verify-and-release (push) Has been skipped
Unified application CI and deployment / verify-and-release (pull_request) Has been skipped
python CI and deployment / verify-and-deploy (pull_request) Has been skipped

This commit is contained in:
2026-11-04 14:32:04 +08:00
parent fe26f03cf4
commit 1df5790d23
3 changed files with 12 additions and 7 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ jobs:
SOURCE_SHA: ${{ gitea.sha }}
SOURCE_BRANCH: ${{ gitea.ref_name }}
run: |
if [ ! -s /opt/prompt-preview/fingerprint ]; then
if [ ! -f /opt/prompt-preview/ready ]; then
bash scripts/preview/init.sh "$PWD" waterfall-wiki-tests:6654a1456bdcef77d83ca84373dc36188e15bd12
fi
bash scripts/preview/sync.sh "$PWD" "$SOURCE_SHA" "$SOURCE_BRANCH"
+2 -2
View File
@@ -71,8 +71,8 @@ services:
image: ${PREVIEW_TOOL_IMAGE:?required}
profiles: [setup]
user: root
volumes: ["tools:/tools"]
command: ["/bin/sh", "-ec", "mkdir -p /tools/corepack && cp -a /root/.cache/node/corepack/. /tools/corepack/ && chown -R 1000:1000 /tools"]
volumes: ["tools:/tools", "next-cache:/preview-next"]
command: ["/bin/sh", "-ec", "mkdir -p /tools/corepack && cp -a /root/.cache/node/corepack/. /tools/corepack/ && chown -R 1000:1000 /tools /preview-next"]
migrate:
image: ${PREVIEW_TOOL_IMAGE:?required}
profiles: [setup]
+9 -4
View File
@@ -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