feat: initial Vite/React frontend service template
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
9fd6fd1d26
32 changed files with 5218 additions and 0 deletions
44
README.md
Normal file
44
README.md
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# ${REPO_NAME}
|
||||
|
||||
Frontend service generated from `nholtware/service-template-react`: a Vite +
|
||||
React 19 + React Router (data mode) SPA, served as static files by
|
||||
unprivileged nginx.
|
||||
|
||||
## Develop
|
||||
|
||||
```sh
|
||||
npm install
|
||||
npm run dev # http://localhost:5173, /api proxied to API_PROXY_TARGET (default http://localhost:3000)
|
||||
npm test
|
||||
npm run lint
|
||||
npm run format
|
||||
```
|
||||
|
||||
## Runtime config
|
||||
|
||||
`/config.js` sets `window.__APP_CONFIG__`. In the container,
|
||||
`docker-entrypoint.d/10-config.sh` writes it at start from env vars, so one
|
||||
image runs in every environment. Read values through `getConfig()` in
|
||||
`src/lib/config.ts`.
|
||||
|
||||
| Env var | Default | Meaning |
|
||||
| -------------- | ------- | ----------------------------------------------- |
|
||||
| `API_BASE_URL` | `/api` | Backend base URL; `/api` is the same-host route |
|
||||
| `APP_NAME` | `app` | Display name |
|
||||
|
||||
Everything in `config.js` is public. Never put secrets there.
|
||||
|
||||
## Container
|
||||
|
||||
- `GIT_SHA` build arg is baked in as `import.meta.env.VITE_GIT_SHA`.
|
||||
- nginx listens on 8080: `/healthz` returns 200, unknown paths fall back to
|
||||
`index.html`, `/assets/*` are cached as immutable, and `index.html` and
|
||||
`config.js` are not cached.
|
||||
|
||||
## Deploy
|
||||
|
||||
Push to `main`: Forgejo CI runs lint/test/format, builds and pushes
|
||||
`192.168.1.230:3000/nholtware/${REPO_NAME}:<sha>`, and bumps the tag in the
|
||||
gitops repo. ArgoCD then syncs it. Manifests come from gitops
|
||||
`templates/frontend/`. The repo needs Actions secrets `REGISTRY_USER`,
|
||||
`REGISTRY_TOKEN`, and `GITOPS_TOKEN`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue