Files
react-website/docs/DEPLOYMENT.md
T
MehboobKandClaude Sonnet 5 63a36e0dca Initial commit: BlackDice site rebuild with integrated CMS
Rebuilds content management around a single admin route (/admin —
"BlackDice Studio"), replacing blackdice-studio.html. Publishing writes
one JSON content document instead of regenerating HTML files, so it can
no longer overwrite hand-made site changes the way the old tool did.

- /admin: click-to-edit copy/images, article CRUD with a Word-safe rich
  text editor, demo clip management, per-page SEO, enquiry log, publish
  history with rollback
- Real per-page URLs for all pages and articles, each with its own
  meta/canonical/OG/JSON-LD
- Newsroom + article pages driven by the CMS post library, seeded from
  the old studio's export (17 articles) plus a drafted GSMA Open Gateway
  press release awaiting approval
- Demo sections on Mobile SDK and Halo CPE, interactive by default and
  upgradable to an uploaded clip per slot
- Dependency-free Node API server (auth, publish, uploads, snapshots,
  leads, live sitemap)
- Deployment configs for Node/nginx/IIS, Vercel and Netlify

See docs/ARCHITECTURE.md, docs/PROJECT-STRUCTURE.md, docs/CMS-GUIDE.md
and docs/DEPLOYMENT.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-12 23:52:44 +05:00

127 lines
4.6 KiB
Markdown

# Deployment and operations
The app ships as a static build plus one small Node process. The Node process is
what makes `/admin` able to publish, so **host it wherever the CMS is needed**.
```bash
npm ci
npm run build # → dist/
ADMIN_PASSWORD='…' npm start # serves dist/ + the API on port 8787
```
## Environment
| Variable | Default | Purpose |
| --- | --- | --- |
| `ADMIN_PASSWORD` | `blackdice` | Password for `/admin`. **Set this** — the server logs a warning while it is unset. |
| `ADMIN_SECRET` | derived from the password | Signs session tokens. Set it to invalidate all sessions independently of the password. |
| `PORT` | `8787` | Listen port. |
| `CONTENT_DIR` | `./content` | Published content, uploads, snapshots, enquiries. Put this on persistent storage. |
| `DIST_DIR` | `./dist` | The built site. |
| `SITE_URL` | `https://www.blackdice.ai` | Canonical origin used in `sitemap.xml`. |
Sessions last 12 hours. Failed logins are throttled at 10 per IP per 15 minutes.
Uploads are capped at 32MB and limited to images, MP4/WebM and PDF.
## What lives where
```
content/
site-content.json the published site: copy, articles, demos, settings
versions/ one snapshot per publish (latest 60 kept)
uploads/ images and clips uploaded through Studio
leads.jsonl enquiry form submissions
dist/ the built site (safe to delete and rebuild)
public/content/posts/ article heroes imported from the old studio (in git)
```
**Back up `content/`.** It is the only thing that cannot be rebuilt from the repo.
A nightly copy of the directory is enough; `site-content.json` is a single small
JSON file. Editors can also take their own backup from Studio → History → *Download
this draft*.
## Behind IIS or nginx
Serve the app from Node and reverse-proxy to it — that keeps `/api`, uploads, the
SPA fallback and the live sitemap working with no extra configuration.
nginx:
```nginx
location / {
proxy_pass http://127.0.0.1:8787;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 40M; # Studio uploads
}
```
IIS: install URL Rewrite + ARR and proxy the site to `http://127.0.0.1:8787`, or run
it under iisnode. Raise `maxAllowedContentLength` to ~40MB for uploads.
Keep the process alive with a Windows service (`nssm`), `pm2`, or systemd:
```ini
# /etc/systemd/system/blackdice-site.service
[Service]
WorkingDirectory=/srv/blackdice
Environment=ADMIN_PASSWORD=…
Environment=CONTENT_DIR=/srv/blackdice-content
ExecStart=/usr/bin/node server/index.mjs
Restart=always
```
Docker:
```dockerfile
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
ENV PORT=8787 CONTENT_DIR=/data
VOLUME /data
EXPOSE 8787
CMD ["node", "server/index.mjs"]
```
## Static hosting without the CMS
`dist/` can be served by any static host. Deep links need an SPA fallback, which is
already configured for Vercel (`vercel.json`), Netlify (`public/_redirects`) and IIS
(`public/web.config`). Apache:
```apache
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]
```
In that setup the site shows the content compiled into the build and `/admin` cannot
publish. To make a change, run Studio locally (`npm run dev`), publish, then commit
the resulting `content/site-content.json` and any `content/uploads/` files and
redeploy — the build copies neither automatically, so they must be placed alongside
`dist/` (`dist/content/site-content.json`, `dist/content/uploads/…`).
## Release checklist
1. `npm ci && npm run build` — the build fails on type errors, so it gates itself.
2. `node scripts/generate-sitemap.mjs https://www.blackdice.ai` if the static
sitemap needs refreshing (the server's live one needs nothing).
3. Deploy `dist/`, `server/`, `package.json`, and keep `content/` in place.
4. Check: `/`, `/mobile-sdk`, `/news`, one `/blog/<slug>` deep link, `/sitemap.xml`,
`/admin` login.
5. In Search Console, submit `https://www.blackdice.ai/sitemap.xml` and request
indexing for the product pages — they now have their own URLs to index.
## After the first deploy
- Set `ADMIN_PASSWORD` and share it only with the people who edit the site.
- Publish once from Studio so `content/site-content.json` exists and snapshots begin.
- Approve and publish the GSMA Open Gateway release (Studio → Articles).
- Upload the Retina and Angel walkthrough clips (Studio → Demos) to finish the Halo
CPE demos.