Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Serve the hosted dashboard from the dev server via pnpm server:*

Damian Legawiecf3b0987de6f9
diff --git a/CLAUDE.md b/CLAUDE.md
index 23ae4e6295..64099ccb3f 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -90,6 +90,7 @@ Day-to-day from the repo root: `pnpm server:dev` (foreground — streams web + w
| What changed | What to run |
|---|---|
| Ruby code in `spree/*` gems | Nothing — bind-mounted, reloads on next request |
+| Hosted React Dashboard at `/dashboard` (single-node test) | `pnpm server:dashboard` — rebuilds `packages/dashboard-starter/dist` with `VITE_BASE_PATH=/dashboard/`; served immediately through the monorepo mount (no restart). For dashboard *development* keep using Vite on :5173 (`cd packages/dashboard && pnpm dev`). |
| Tailwind classes in `spree/admin` templates/helpers/JS | Nothing — a watcher in the web container rebuilds the admin CSS within ~15s. If changes still don't reach the browser, delete `server/public/assets/.manifest.json` (stale precompile output that freezes asset serving) and restart web — `pnpm server:dev` boots handle this automatically. |
| New migration in a gem | Nothing — the next `pnpm server:dev` boot runs `spree:install:migrations db:prepare` (or `cd server && pnpm exec spree migrate` while running) |
| Gem dependencies (gemspec / Gemfile / starter `Gemfile.lock` drift after a pull) | Nothing — the next `pnpm server:dev` boot self-heals (`bundle check || bundle install` into the `bundle_cache` volume); while running: `cd server && pnpm exec spree bundle install` |
@@ -98,7 +99,7 @@ Day-to-day from the repo root: `pnpm server:dev` (foreground — streams web + w
| Meilisearch image bump ("database version … is incompatible") | `docker compose -p server rm -sf meilisearch && docker volume rm server_meilisearch_data`, boot, then `cd server && pnpm exec spree rake spree:search:reindex` |
| Broken beyond repair | `pnpm server:setup` (full reset — wipes DB + volumes) |
-Backend: http://localhost:3000, admin at `/admin` (`[email protected]` / `spree123`). Native no-Docker path: `pnpm server:create`, then `cd server && bin/setup && bin/dev`.
+Backend: http://localhost:3000, admin at `/admin`, hosted React Dashboard at `/dashboard` (`[email protected]` / `spree123`). Native no-Docker path: `pnpm server:create`, then `cd server && bin/setup && bin/dev`.
---
diff --git a/package.json b/package.json
index 0b9bad60e4..dc416d5b00 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
"clean": "turbo clean",
"server:create": "git clone --depth 1 https://github.com/spree/spree-starter.git server && rm -rf server/.git server/.gitignore && printf 'SPREE_PATH=..\\nSECRET_KEY_BASE=%s\\n' \"$(openssl rand -hex 64)\" > server/.env",
"server:setup": "bash scripts/server-setup.sh",
+ "server:dashboard": "VITE_BASE_PATH=/dashboard/ pnpm --dir packages/dashboard-starter build",
"server:dev": "SPREE_PATH=$PWD docker compose -f server/docker-compose.dev.yml -f scripts/docker-compose.edge.yml up --force-recreate web worker",
"server:build": "bash scripts/server-build.sh",
"server:restart": "SPREE_PATH=$PWD docker compose -f server/docker-compose.dev.yml -f scripts/docker-compose.edge.yml restart web worker",
diff --git a/scripts/docker-compose.edge.yml b/scripts/docker-compose.edge.yml
index be31aa152b..49527a9e10 100644
--- a/scripts/docker-compose.edge.yml
+++ b/scripts/docker-compose.edge.yml
@@ -23,8 +23,16 @@ services:
# path we mirror-mount. The starter's .env may carry a different
# SPREE_PATH (e.g. `..` for the native bin/dev flow); the overlay-set
# value here wins because `environment:` beats `env_file:` in Compose.
+ #
+ # SPREE_DASHBOARD_DIST_PATH: the monorepo mount already contains the
+ # dashboard-starter's build output, so the spree_dashboard gem serves it
+ # at /dashboard (single-node topology) with zero copying — run
+ # `pnpm server:dashboard` to (re)build the dist; changes are served
+ # immediately (the gem reads files per request, no restart). Until a
+ # build exists the directory is absent and /dashboard responds 404.
environment:
SPREE_PATH: ${SPREE_PATH}
+ SPREE_DASHBOARD_DIST_PATH: ${SPREE_PATH}/packages/dashboard-starter/dist
volumes:
- ${SPREE_PATH}:${SPREE_PATH}
# Hard-bypass the starter's bin/docker-entrypoint, which auto-runs
diff --git a/scripts/server-setup.sh b/scripts/server-setup.sh
index ca1b4fbe99..d1e461b58d 100755
--- a/scripts/server-setup.sh
+++ b/scripts/server-setup.sh
@@ -58,6 +58,15 @@ printf 'SPREE_PATH=..\nSECRET_KEY_BASE=%s\n' "$(openssl rand -hex 64)" > "$SERVE
step "Building @spree/cli (so node ../packages/cli/dist/index.js works)"
pnpm --filter @spree/cli build
+step "Building the React Dashboard (served at /dashboard via spree_dashboard)"
+# The edge overlay points SPREE_DASHBOARD_DIST_PATH at this build output
+# through the monorepo mount — no copying, and rebuilds (`pnpm
+# server:dashboard`) are served immediately. Non-fatal: the backend works
+# without it (/dashboard just 404s until a build exists).
+if ! VITE_BASE_PATH=/dashboard/ pnpm --dir "$ROOT/packages/dashboard-starter" build; then
+ echo " ⚠ dashboard build failed — continuing; run 'pnpm server:dashboard' later."
+fi
+
step "Starting the edge stack"
# Detached on purpose — `pnpm server:dev` runs the stack in the foreground
# (streaming logs, Ctrl+C to stop); setup needs to continue past the boot.
@@ -86,4 +95,4 @@ until code="$(curl -s -o /dev/null -w '%{http_code}' --max-time 2 http://localho
elapsed=$((elapsed + 3))
done
-printf '\nServer ready: http://localhost:3000\nAdmin: http://localhost:3000/admin\n\n'
+printf '\nServer ready: http://localhost:3000\nAdmin: http://localhost:3000/admin\nDashboard: http://localhost:3000/dashboard\n\n'