Skip to content

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 ​

ModeCommandPurposeOutput / Port
Local sample demopnpm run demo (or pnpm run demo -- --range)Serves the sample manga, reader, and SQLite (whole or HTTP 206 Range) locally without a CDNhttp://localhost:4321
Full pipeline buildpnpm run buildRuns build:config → build:manifest → build:db → build:site → build:index → build:sitemapdist/ & out/
Fixture dry buildDATA_DIR=packages/core/test/fixtures/data BUILD_WORK_DIR=/tmp/ph-smoke pnpm run buildTests complete pipeline in an isolated work directory without touching repo generated files$BUILD_WORK_DIR/{dist,out}
Static Astro previewpnpm --filter @gallery/site run previewVerifies static HTML chapters, text overlays, search, and 404.htmlhttp://localhost:4321
Local config UIpnpm run customizeEdits site.config.yaml appearance and feature flags (including range_search) with YAML backupshttp://127.0.0.1:4318/#token=...
Emergency cache purgepnpm run purge -- [--prefix] [<url> …]Zero-SDK EdgeOne CreatePurgeTask & Aliyun ESA PurgeCaches purge (PURGE_DRY_RUN=1 supported)Task IDs on stdout
Standalone docs devpnpm --dir docs-site install --frozen-lockfile && pnpm --dir docs-site run docs:devLive-edits docs-site/ with cache-busted bilingual search reloadManaged 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 IDFile Limit / App GuardSize LimitPreview ModeConfig & Template Handling
edgeoneNo extra target file cap20 MiB per-file guardSupported (-e preview)Public edgeone.json, _headers, 404.html
esaHard 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
githubNo extra target cap (18,000 global guard)1,000,000,000 B totalUnsupported (preview rejects github/all)Requires .nojekyll, 404.html, index.html; pushes gh-pages
workers18,000 (1 proof file → 17,999 app files)20 MiB per-file guardSupported (CLOUDFLARE_PREVIEW_WORKER_NAME)wrangler.jsonc excluded from dist/; Static Assets only
cloudflare18,00020 MiB per fileSupported (--branch preview)Legacy Pages entry (excluded from all)

When features.platform_config: false, _headers, _redirects, and edgeone.json are omitted and the site operates purely via relative URLs and static HTML.

Immutable R2 & Three-Phase Release Flow ​

  1. pnpm run publish:r2: Validates safe object paths, uploads missing WebP images, versioned db/gallery-<version>.sqlite + .chunks.json, and immutable manifest-<version>.json to R2; archives previous pointer to out/manifest-previous.json.
  2. pnpm run release:prepare: Saves current production manifest.json ETag and fingerprint into out/release-state.json.
  3. 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 use wrangler@4 and esa-cli@1.0.13. Workers and ESA receive a temporary copy with a unique random deployment proof file, then waitForDeployment fetches and verifies that exact proof over HTTPS (ESA staging overrides DNS connection target while preserving Host, SNI, and TLS validation) before writing a receipt.
  4. pnpm run release:activate: Requires identical (version, fingerprint) receipts from every planned target, then atomically updates R2 manifest.json using If-Match: <etag> (or If-None-Match: * on initial release).
  5. pnpm run push:search & pnpm run status: Computes newly added URLs between manifest.json and manifest-previous.json, submits batches (<= 10,000) to IndexNow if seo.indexnow_key is set, and updates STATUS.md.

Environment Variables & Secrets Matrix ​

Non-Secret Build & Path Overrides ​

VariableDefault / AllowedPurpose
BUILD_WORK_DIRUnset (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_DIRRepo root site.config.yaml, data, dist, outRedirect config, input catalog, static site output, and build artifacts
DEPLOY_TARGETOptional target ID or allEnables target-specific budget checks in pnpm run check
DEPLOY_ENVproduction | previewSelects production vs preview target configurations
RELEASE_VERSIONDefaults to UTC YYYY-MM-DDPins immutable SQLite/manifest version ([A-Za-z0-9._-]+)
CHAPTERS / LABELPLUS_PAGESComma-separated chapter keys; auto | number | sequenceScopes ingest:labelplus / ingest:ocr chapters and page mapping
INDEXNOW_ENDPOINThttps://api.indexnow.org/indexnowOverrides IndexNow push endpoint

CI Secrets & Environment Config (Never Committed or Logged) ​

ScopeGitHub Actions SecretsGitHub Actions Variables (falls back to Secrets if unset)Step Isolation
Private R2 StorageR2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEYR2_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 / PagesCLOUDFLARE_API_TOKENCLOUDFLARE_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 PagesEDGEONE_API_TOKENEDGEONE_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 PagesESA_ACCESS_KEY_ID, ESA_ACCESS_KEY_SECRETESA_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_SECRETEDGEONE_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 WritebackRELEASE_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) binds environment (via inputs.deploy_env: production / preview) and injects per-key Secrets and Variables at step scope only—leaving build, check, and ingest steps isolated without deploy credentials. Never commit, log, or print real credentials.

Pre-Release Checklist ​

  1. Replace gallery.example.org and images.example.org in site.config.yaml with real production hostnames (releasePlan blocks placeholder domains on production).
  2. Configure CDN S3v4 private origin access to R2 and ensure Access-Control-Allow-Origin and ETag headers permit browser fetches for .sqlite files.
  3. Verify dist/<indexnow_key>.txt exists if seo.indexnow_key is configured.
  4. Confirm pnpm run build and DEPLOY_TARGET=all pnpm run check exit 0.
  5. Run a DEPLOY_ENV=preview test deployment on new targets before cutting over production DNS.