Deployment and static SPAs
Monorepo scripts (root package.json)
Section titled “Monorepo scripts (root package.json)”| Script | What it runs |
|---|---|
npm run admin:build | turbo run build --filter=@indochina/admin-web |
npm run vendor:build | turbo run build --filter=@indochina/vendor-web |
npm run admin:build:staging | Vite --mode staging + VITE_API_URL (see apps/admin-web/staging.env.example) |
npm run vendor:build:staging | Vite --mode staging + VITE_API_URL (see apps/vendor-web/staging.env.example) |
npm run deploy:staging | deploy-to-vps-staging.sh — staging SSH env, backend .env.host.staging, staging SPA builds |
npm run backend:build | turbo run build --filter=@indochina/backend |
npm run build:deploy | admin:build → vendor:build → backend:build (single command for release) |
npm run deploy | bash deploy/deploy-to-vps.sh (optional VPS rsync; see below) |
Vite outDir in each app’s vite.config.ts points to apps/backend/static/admin and apps/backend/static/vendor, so SPA builds write straight into the Nest static tree before backend:build.
Docker (reference implementation)
Section titled “Docker (reference implementation)”The root Dockerfile:
- Builder:
npm ci, copy workspaces, setNODE_ENV=productionandVITE_API_URL=, runnpm run build:deploy. - Runner: production
npm install --omit=devforapps/backendonly, copydistandstatic, runnode dist/main.js.
So CI “copy dist into static” is already encoded in the image build — no manual rsync inside the container.
Upload persistence (gallery / imports)
Section titled “Upload persistence (gallery / imports)”- Runtime: Nest writes gallery files under
PUBLIC_STORAGE_ROOT(default{cwd}/public/storage) and serves them at/public/storage/*(mountPublicStorageinbootstrap-static-spas.ts). Clover import jobs useVENDOR_IMPORT_STORAGE_ROOT(default{cwd}/storage/vendor-imports). - Docker:
deploy/docker-compose.ymlmounts named volumes on those default paths so uploads survive image rebuilds. - PM2/VPS: set
PUBLIC_STORAGE_ROOTandVENDOR_IMPORT_STORAGE_ROOTinapps/backend/.env.hostto directories outside the rsync deploy tree; seedeploy/README.md→ Persistent uploads.
GitHub Actions
Section titled “GitHub Actions”.github/workflows/docker-build.yml— validates the image onmain/masterand PRs (build only, no registry push).
VPS without Docker
Section titled “VPS without Docker”deploy/deploy-to-vps.sh— builds locally (unlessSKIP_BUILD=1), rsyncsstatic/*and/ordistto the server, optionalRUN_MIGRATIONS=1, PM2 or systemd restart. Configure viadeploy/.env.deploy.
Static hosting (runtime)
Section titled “Static hosting (runtime)”- When
index.htmlexists underapps/backend/static/adminandstatic/vendor, the backend serves them (seebootstrap-static-spas.ts). - Reserved paths for the vendor SPA exclude
/api,/admin, and Swagger UI/JSON paths so APIs keep working.
Organization-specific
Section titled “Organization-specific”Document Nginx or CDN rules (TLS, caching, WebSocket if added) in your internal runbook.