English
Modes, Platforms & Environment Matrix
Pagehaven decouples static site hosting from large binary storage: one shared dist/ artifact deploys across static edge hosts while WebP pages and versioned SQLite files reside in private Cloudflare R2 behind CDN hosts.
Local Execution Modes
| Mode | Command | Purpose | Output / Port |
|---|---|---|---|
| Local sample demo | pnpm run demo (or pnpm run demo -- --range) | Serves the sample manga, reader, and SQLite (whole or HTTP 206 Range) locally without a CDN | http://localhost:4321 |
| Full pipeline build | pnpm run build | Runs build:config → build:manifest → build:db → build:site → build:index → build:sitemap | dist/ & out/ |
| Fixture dry build | DATA_DIR=packages/core/test/fixtures/data BUILD_WORK_DIR=/tmp/ph-smoke pnpm run build | Tests complete pipeline in an isolated work directory without touching repo generated files | $BUILD_WORK_DIR/{dist,out} |
| Static Astro preview | pnpm --filter @gallery/site run preview | Verifies static HTML chapters, text overlays, search, and 404.html | http://localhost:4321 |
| Local config UI | pnpm run customize | Edits site.config.yaml appearance and feature flags (including range_search) with YAML backups | http://127.0.0.1:4318/#token=... |
| Emergency cache purge | pnpm run purge -- [--prefix] [<url> …] | Zero-SDK EdgeOne CreatePurgeTask & Aliyun ESA PurgeCaches purge (PURGE_DRY_RUN=1 supported) | Task IDs on stdout |
| Standalone docs dev | pnpm --dir docs-site install --frozen-lockfile && pnpm --dir docs-site run docs:dev | Live-edits docs-site/ with cache-busted bilingual search reload | Managed dev port (scripts/docs-dev.mjs) |
Multi-Target Hosting Matrix
@gallery/platform (packages/platform/src/targets.js) registers five deploy targets; DEFAULT_RELEASE_TARGETS (--target all) expands to edgeone, esa, github, and workers, while legacy Cloudflare Pages stays standalone as cloudflare:
| Target ID | File Limit / App Guard | Size Limit | Preview Mode | Config & Template Handling |
|---|---|---|---|---|
edgeone | No extra target file cap | 20 MiB per-file guard | Supported (-e preview) | Public edgeone.json, _headers, 404.html |
esa | Hard cap 2,000 (1 proof file → 1,999 app files) | 1,024,000,000 B (4,096 B proof reserve) | Supported (staging DNS + TLS verification) | esa.jsonc excluded from dist/; project name injected in staging copy |
github | No extra target cap (18,000 global guard) | 1,000,000,000 B total | Unsupported (preview rejects github/all) | Requires .nojekyll, 404.html, index.html; pushes gh-pages |
workers | 18,000 (1 proof file → 17,999 app files) | 20 MiB per-file guard | Supported (CLOUDFLARE_PREVIEW_WORKER_NAME) | wrangler.jsonc excluded from dist/; Static Assets only |
cloudflare | 18,000 | 20 MiB per file | Supported (--branch preview) | Legacy Pages entry (excluded from all) |
When
features.platform_config: false,_headers,_redirects, andedgeone.jsonare omitted and the site operates purely via relative URLs and static HTML.
Immutable R2 & Three-Phase Release Flow
pnpm run publish:r2: Validates safe object paths, uploads missing WebP images, versioneddb/gallery-<version>.sqlite+.chunks.json, and immutablemanifest-<version>.jsonto R2; archives previous pointer toout/manifest-previous.json.pnpm run release:prepare: Saves current productionmanifest.jsonETag and fingerprint intoout/release-state.json.pnpm run deploy:<target>: Makers uses the lockfile-pinned SDK to upload the static directory and wait for the target deployment to succeed. Its preview environment requires an existing production deployment. Cloudflare and ESA usewrangler@4andesa-cli@1.0.13. Workers and ESA receive a temporary copy with a unique random deployment proof file, thenwaitForDeploymentfetches and verifies that exact proof over HTTPS (ESA staging overrides DNS connection target while preserving Host, SNI, and TLS validation) before writing a receipt.pnpm run release:activate: Requires identical(version, fingerprint)receipts from every planned target, then atomically updates R2manifest.jsonusingIf-Match: <etag>(orIf-None-Match: *on initial release).pnpm run push:search&pnpm run status: Computes newly added URLs betweenmanifest.jsonandmanifest-previous.json, submits batches (<= 10,000) to IndexNow ifseo.indexnow_keyis set, and updatesSTATUS.md.
Environment Variables & Secrets Matrix
Non-Secret Build & Path Overrides
| Variable | Default / Allowed | Purpose |
|---|---|---|
BUILD_WORK_DIR | Unset (defaults to repo root) | Isolates site-generated data, Astro cache, platform templates, and default dist/ / out/ per build |
CONFIG_FILE / DATA_DIR / DIST_DIR / OUT_DIR | Repo root site.config.yaml, data, dist, out | Redirect config, input catalog, static site output, and build artifacts |
DEPLOY_TARGET | Optional target ID or all | Enables target-specific budget checks in pnpm run check |
DEPLOY_ENV | production | preview | Selects production vs preview target configurations |
RELEASE_VERSION | Defaults to UTC YYYY-MM-DD | Pins immutable SQLite/manifest version ([A-Za-z0-9._-]+) |
CHAPTERS / LABELPLUS_PAGES | Comma-separated chapter keys; auto | number | sequence | Scopes ingest:labelplus / ingest:ocr chapters and page mapping |
INDEXNOW_ENDPOINT | https://api.indexnow.org/indexnow | Overrides IndexNow push endpoint |
CI Secrets & Environment Config (Never Committed or Logged)
| Scope | GitHub Actions Secrets | GitHub Actions Variables (falls back to Secrets if unset) | Step Isolation |
|---|---|---|---|
| Private R2 Storage | R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY | R2_ACCOUNT_ID, R2_BUCKET, R2_ENDPOINT (optional) | Injected only into release:check, verify:manifest, release:prepare, publish:r2, release:activate, and status steps |
| Cloudflare Workers / Pages | CLOUDFLARE_API_TOKEN | CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_WORKER_NAME, WORKERS_DEPLOY_URL (CLOUDFLARE_PREVIEW_WORKER_NAME, WORKERS_PREVIEW_DEPLOY_URL for preview) | Injected only into deploy:workers / deploy:cloudflare and preflight steps |
| EdgeOne Pages | EDGEONE_API_TOKEN | EDGEONE_PROJECT_ID, EDGEONE_PROJECT_NAME, EDGEONE_API_REGION (optional, default china) | The SDK uploads by project ID after the name and direct-upload type have been verified |
| Aliyun ESA Pages | ESA_ACCESS_KEY_ID, ESA_ACCESS_KEY_SECRET | ESA_PROJECT_NAME, ESA_DEPLOY_URL (ESA_PREVIEW_IP for preview) | esa-cli@1.0.13 --no-preview |
Emergency CDN Purge (purge) | EDGEONE_SECRET_ID, EDGEONE_SECRET_KEY, ESA_ACCESS_KEY_ID, ESA_ACCESS_KEY_SECRET | EDGEONE_ZONE_ID, ESA_SITE_ID (optional EDGEONE_API_ENDPOINT, ESA_API_ENDPOINT, PURGE_DRY_RUN=1) | Manual rescue invocation only (pnpm run purge); skips missing provider credentials and runs both CDNs independently |
| GitHub Pages & Signed Writeback | RELEASE_SIGNING_KEY, GITHUB_PAGES_TOKEN (optional for same-repo pushes; falls back to github.token) | GITHUB_PAGES_REPO (optional; defaults to github.repository) | Baseline checked before SSH-signed commit push to gh-pages and signed STATUS.md / data/text writeback |
The GitHub Actions release workflow (
.github/workflows/release.yml) bindsenvironment(viainputs.deploy_env:production/preview) and injects per-key Secrets and Variables at step scope only—leavingbuild,check, andingeststeps isolated without deploy credentials. Never commit, log, or print real credentials.
Pre-Release Checklist
- Replace
gallery.example.organdimages.example.orginsite.config.yamlwith real production hostnames (releasePlanblocks placeholder domains on production). - Configure CDN S3v4 private origin access to R2 and ensure
Access-Control-Allow-OriginandETagheaders permit browser fetches for.sqlitefiles. - Verify
dist/<indexnow_key>.txtexists ifseo.indexnow_keyis configured. - Confirm
pnpm run buildandDEPLOY_TARGET=all pnpm run checkexit0. - Run a
DEPLOY_ENV=previewtest deployment on new targets before cutting over production DNS.