Changes for .changelog/20261013_0020_subpath-hosting-and-harbor-ci.md: 43 added lines, 0 removed lines.
Original line number
Diff line number
Diff line
# Runtime base path (subpath hosting) + Harbor CI pipeline
**Date:** 2026-10-13
## Why
The Chronos Helm chart (`org.etsi.osl.chronos.deploy`) serves the UI at `{rootUrl}/chronos/` on the OpenSlice host. Until now the UI assumed it lived at `/`:
-`/config.js`, `/vite.svg` and `/assets/*` were absolute paths.
-`BrowserRouter` had no basename.
- The Keycloak redirect URI was `origin + '/'`.
## What changed
-**`vite.config.ts`:**`base: './'`, so asset URLs are relative.
-**`index.html`:**
- Added a `<base href="/" />` placeholder.
-`config.js` and `vite.svg` are now referenced relatively.
-**`docker-entrypoint.sh`:**
- Reads the new `CHRONOS_BASE_PATH` (default `/`) and normalizes it to `/x/`.
- Rewrites `<base href>` in `index.html`.
- Writes `VITE_BASE_PATH` into `window.__CHRONOS_CONFIG__`.
-`CHRONOS_HTML_ROOT` overrides the html directory, which is useful for testing.
-**`src/config.ts`:** new `appConfig.basePath`, taken from optional `VITE_BASE_PATH` and normalized by the exported `normalizeBasePath`.
-`src/vite-env.d.ts` declares the env var.
-**`src/main.tsx`:**
-`BrowserRouter basename` is the base path without its trailing slash, so both `/chronos` and `/chronos/` match.
- Keycloak `redirectUri` is `origin + basePath`.
-**`createKeycloakAuthAdapter(kc, redirectUri?)`:** new optional redirect URI. It is used for the login redirect, and the default is unchanged.
-**`.gitlab-ci.yml` (new):** on a Git tag, Kaniko builds the Dockerfile and pushes `${HARBOR_REGISTRY}/${HARBOR_PROJECT}/org.etsi.osl.chronos.ui:{tag,latest}`. It is the same as the backend pipeline minus the Maven stage.
-**Docs:**
-`.env.example` gains `VITE_BASE_PATH`.
- The operations guide gains the env-table row, a new section 3b on serving under a subpath, and updated redirect-URI notes.
The default behaviour (served at `/`) is unchanged, and nginx needs no change because the ingress strips the prefix.
## Verification
-`npm run typecheck` is clean, and eslint is clean on the touched files.
-`src/config.test.ts` passes 16 tests (new basePath default/override tests and a `normalizeBasePath` table).
-`src/adapters` passes 331 tests.
-`vite build` output has relative `./assets/*` URLs.
- Running the entrypoint against `dist/index.html` with `/chronos/`, `chronos`, an empty value and `/a/b` gives the correct `<base href>` and `VITE_BASE_PATH`, and re-running the script rewrites it again.
-**Pre-existing failures, unchanged by this work** (confirmed on a stashed baseline):
-`npm run lint` reports 107 errors.
-`test:coverage` has 5 timeouts, in BlackoutFormDialog, BlackoutsPage and CalendarsPage.
-**Not verified:**`docker build` and a browser round-trip behind ingress, since there was no Docker or cluster locally.
| `VITE_TENANT_TIMEZONE` | No | `Europe/Athens` | IANA zone for display. Defaults to `UTC`. |
| `VITE_BASE_PATH` | No | `/chronos/` | URL path the app is served under. Defaults to `/`. In the Docker image set `CHRONOS_BASE_PATH` instead (see 3b). |
## 3. Build and serve (plain static hosting)
@@ -102,7 +103,7 @@ docker run -d -p 8080:80 \
### How runtime injection works
1.`index.html` loads `/config.js`**before** the app bundle.
1.`index.html` loads `config.js`(relative to `<base href>`) **before** the app bundle.
2. In the image, `config.js` starts as an empty placeholder; the nginx
entrypoint (`/docker-entrypoint.d/40-chronos-config.sh`) rewrites it from the
container's `VITE_*` env vars at start-up, defining `window.__CHRONOS_CONFIG__`.
@@ -119,6 +120,27 @@ long-term.
> build intentionally does not gate on types so a type error can't block
> producing a deployable artifact.
## 3b. Serving under a subpath (e.g. `/chronos/` on the OpenSlice host)
The bundle uses relative asset URLs (Vite `base: './'`), and `index.html`
carries a `<base href="/">` placeholder. To serve the app under a path prefix,
set `CHRONOS_BASE_PATH` on the container:
```bash
docker run -d-p 8080:80 -eCHRONOS_BASE_PATH=/chronos/ ... chronos-ui:latest
```
The entrypoint normalizes the value (leading and trailing slash), rewrites
`<base href>` in `index.html`, and writes it as `VITE_BASE_PATH` into
`config.js`. The app then uses it as the router basename and the Keycloak
redirect URI.
nginx still serves from `/`, so the reverse proxy in front must **strip the
prefix**. With ingress-nginx this is `rewrite-target`. The Helm chart in
`org.etsi.osl.chronos.deploy` sets this up: the UI is served at `{rootUrl}/chronos/`
and the API at `{rootUrl}/chronos-api`. Behind a prefix, `VITE_API_BASE_URL` must
be an **absolute** URL.
## 4. Keycloak client setup
Register a **public** client (no client secret — this is a browser SPA using
@@ -128,8 +150,8 @@ PKCE):
-**Access type:** public
-**Standard flow (authorization code):** enabled
-**PKCE:** S256 (the UI requests `pkceMethod: 'S256'`)
-**Valid redirect URIs:** the app origin, e.g. `https://chronos-ui.example.org/`
(the UI uses `window.location.origin + '/'` as the redirect URI)
-**Valid redirect URIs:** the app URL, e.g. `https://chronos-ui.example.org/` or `https://openslice.example.org/chronos/*` under a subpath
(the UI uses `window.location.origin + basePath` as the redirect URI)
-**Web origins:** the app origin (for CORS on token/userinfo)
Changes for .changelog/index.md: 1 added line, 0 removed lines.
Original line number
Diff line number
Diff line
@@ -94,3 +94,4 @@
| 2026-07-20 21:50 | [Activity view: display `type` and `holdExpiry`](20260720_2150_activity_reservation_type_hold_expiry.md) | Refreshed contract from live backend; new ReservationType domain union + codec decode; Type column, hold-expiry chips, detail rows and calendar markers for tentative holds; also fixes pre-existing schema.d.ts drift; 697 tests passing |
| 2026-07-21 00:08 | [Activity view: cancel reservations and holds](20260721_0008_activity_cancel_reservations.md) | New CancelReservationButton (icon + button variants) wired into the Activity table and detail page; routes to DELETE /reservations/{id} or /reservations/holds/{holdId} by reservation type; capability-gated, state-aware, ConfirmDialog + ProblemDetailAlert; 706 tests passing |
| 2026-07-21 17:00 | [Activity view: `correlationId`](20260721_1700_activity_correlation_id.md) | Refreshed contract from live backend (correlationId on ReservationView + activity query param, new /reservations/cancel schemas); domain + codec + gateway wiring; Correlation ID column and filter on ActivityPage, detail row on ReservationDetailPage; 710 tests |
| 2026-10-13 00:20 | [Runtime base path + Harbor CI](20261013_0020_subpath-hosting-and-harbor-ci.md) | The UI can be served under a path prefix (`CHRONOS_BASE_PATH`, e.g. `/chronos/`) for the Helm chart in `org.etsi.osl.chronos.deploy`: relative assets, a `<base href>` rewritten at container start, router basename and Keycloak redirect from `appConfig.basePath`. New `.gitlab-ci.yml` pushes the image to Harbor on tags. Default `/` unchanged; config and adapter tests pass |