From c03b9c582b980c6e000ca04aefbaef73a45645bc Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Thu, 3 Sep 2026 09:57:30 +0530 Subject: [PATCH] Fix seed script paths outside the image; document full local dev flow --- README.md | 33 ++++++++++++++++++++++++++++++--- scripts/seed.mjs | 13 +++++++++++-- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b3dc399..1367546 100644 --- a/README.md +++ b/README.md @@ -43,19 +43,46 @@ deploy.sh Build & push image to the private registry ## Local development +Frontend only (renders from bundled seed content; forms return errors): + ```bash cd app npm install -npm run dev # http://localhost:3000 (uses bundled seed data if PocketBase is down) +npm run dev # http://localhost:3000 ``` -To run PocketBase locally (optional): +Full stack with PocketBase (recommended — from the repo root): ```bash +# Terminal 1 — PocketBase on :8090 (data in ./pb_data, schema auto-applied +# from pb/migrations on first boot) ./.tmp-pb/pocketbase serve --http=127.0.0.1:8090 --dir=./pb_data --migrationsDir=./pb/migrations + +# Terminal 2 — one-time setup: create a local admin and seed the content +./.tmp-pb/pocketbase superuser upsert dev@greatbear.in devpass12345 --dir=./pb_data --migrationsDir=./pb/migrations +PB_URL=http://127.0.0.1:8090 PB_SUPERUSER_EMAIL=dev@greatbear.in PB_SUPERUSER_PASSWORD=devpass12345 \ + node scripts/seed.mjs + +# Terminal 2 — the site (talks to PocketBase on 127.0.0.1:8090 automatically) +cd app && npm run dev ``` -`npm run build` produces `.output/server/index.mjs`, started with `npm start`. +- PocketBase admin UI: `http://127.0.0.1:8090/_/` (dev@greatbear.in) — edits show up on the + site on the next page load +- Dev data lives in `./pb_data` (git-ignored); delete it for a factory reset +- The PB binary in `.tmp-pb/` was fetched during setup — if it's missing, grab a release from + https://github.com/pocketbase/pocketbase/releases (or run PocketBase however you like; only + the port matters) + +`npm run build` produces `.output/server/index.mjs`, started with `npm start`. To run the +**production image** locally instead: + +```bash +docker build -t greatbear:dev . +docker run --rm -p 3000:3000 -p 8090:8090 \ + -e PB_SUPERUSER_EMAIL=dev@greatbear.in -e PB_SUPERUSER_PASSWORD=devpass12345 \ + -v greatbear_dev_data:/data greatbear:dev +``` ## Deploying diff --git a/scripts/seed.mjs b/scripts/seed.mjs index 5dc6e28..f82d4a3 100755 --- a/scripts/seed.mjs +++ b/scripts/seed.mjs @@ -10,7 +10,7 @@ * * Required env: PB_SUPERUSER_EMAIL, PB_SUPERUSER_PASSWORD. Optional: PB_URL. */ -import { readFileSync } from 'node:fs' +import { existsSync, readFileSync } from 'node:fs' import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' @@ -24,7 +24,16 @@ if (!EMAIL || !PASSWORD) { process.exit(0) } -const content = JSON.parse(readFileSync(join(here, 'content.json'), 'utf8')) +// Inside the image content.json sits next to this script; in the repo it lives +// with the frontend sources. +const contentPath = [join(here, 'content.json'), join(here, '../app/src/data/content.json')].find( + (path) => existsSync(path), +) +if (!contentPath) { + console.error('[seed] content.json not found — nothing to seed') + process.exit(1) +} +const content = JSON.parse(readFileSync(contentPath, 'utf8')) async function auth() { const res = await fetch(`${PB_URL}/api/collections/_superusers/auth-with-password`, {