Fix seed script paths outside the image; document full local dev flow

This commit is contained in:
2026-09-03 09:57:30 +05:30
parent 7b070fde81
commit c03b9c582b
2 changed files with 41 additions and 5 deletions
+30 -3
View File
@@ -43,19 +43,46 @@ deploy.sh Build & push image to the private registry
## Local development ## Local development
Frontend only (renders from bundled seed content; forms return errors):
```bash ```bash
cd app cd app
npm install 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 ```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 ./.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 ## Deploying
+11 -2
View File
@@ -10,7 +10,7 @@
* *
* Required env: PB_SUPERUSER_EMAIL, PB_SUPERUSER_PASSWORD. Optional: PB_URL. * 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 { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url' import { fileURLToPath } from 'node:url'
@@ -24,7 +24,16 @@ if (!EMAIL || !PASSWORD) {
process.exit(0) 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() { async function auth() {
const res = await fetch(`${PB_URL}/api/collections/_superusers/auth-with-password`, { const res = await fetch(`${PB_URL}/api/collections/_superusers/auth-with-password`, {