Wire node-static deploy for chat_web_app (closes #13).
Unit Tests / test (pull_request) Successful in 11s
Unit Tests / test (pull_request) Successful in 11s
Add build:prod/beta webroot scripts, Gitea CI/deploy workflows, and bake API URLs from REACT_APP_* so hosts can deploy via server-infra like dta_webapp.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
# Chat Bot Frontend (`chat_web_app`)
|
||||
|
||||
CRA/React app under `llm-fe/`. Production serve is **node-static** (not Docker):
|
||||
hosts build with npm and write into `/var/www/...`; the shared **web-static** nginx
|
||||
container serves those roots. Deploy is driven by `server-infra`.
|
||||
|
||||
## Local development
|
||||
|
||||
```bash
|
||||
cd llm-fe
|
||||
npm ci
|
||||
npm start
|
||||
```
|
||||
|
||||
Uses `.env.development` (API → local `chat_backend`, usually `http://127.0.0.1:8001`).
|
||||
|
||||
## Environment files (CRA `REACT_APP_*`)
|
||||
|
||||
| File | When used | Backend |
|
||||
|------|-----------|---------|
|
||||
| `.env.development` | `npm start` | local backend |
|
||||
| `.env.production` | `npm run build` / `build:prod` | `https://chatbackend.aimloperations.com` |
|
||||
| `.env.beta` | `npm run build:beta` | `https://beta.chatbackend.aimloperations.com` |
|
||||
|
||||
Baked into the JS bundle at build time. No host secret file needed for this
|
||||
frontend (unlike Django apps under `~/Documents/secrets/`).
|
||||
|
||||
Required vars:
|
||||
|
||||
- `REACT_APP_BACKEND_REST_API_BASE_URL` — REST base (trailing `/api/`)
|
||||
- `REACT_APP_BACKEND_WS_API_BASE_URL` — WebSocket URL (full `ws://` / `wss://` path)
|
||||
|
||||
## Production / beta build (host deploy)
|
||||
|
||||
`server-infra` runs `npm ci` then `npm run build:<env>` in `llm-fe/`. Those
|
||||
scripts write static assets into:
|
||||
|
||||
| Script | Document root |
|
||||
|--------|----------------|
|
||||
| `npm run build:prod` | `/var/www/prod.chat.aimloperations/html` |
|
||||
| `npm run build:beta` | `/var/www/beta.chat.aimloperations/html` |
|
||||
|
||||
Paths must match `server-infra` `app_catalog.chat_web_app.webroot_pattern`.
|
||||
|
||||
Manual deploy from the control node:
|
||||
|
||||
```bash
|
||||
~/Documents/repos/server-infra/scripts/deploy.sh \
|
||||
--app chat_web_app --env prod --ref <sha>
|
||||
```
|
||||
|
||||
## CI / CD (Gitea)
|
||||
|
||||
- `.gitea/workflows/unit-tests.yml` — tests on push/PR to `master`
|
||||
- `.gitea/workflows/deploy-prod.yml` — after green Unit Tests on `master` push
|
||||
- `.gitea/workflows/deploy-beta.yml` — manual (`workflow_dispatch`)
|
||||
|
||||
## Tests
|
||||
|
||||
```bash
|
||||
cd llm-fe
|
||||
npm run test:ci
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user