feat(frontend): v2 rewrite — Vite + React + TS readonly SPA
Replaces the v1 CRA app (which targeted the obsolete Python Dialectic
backend) with a fresh Vite + React 18 + TypeScript scaffold that talks
to Dialectic.Backend Go v2.
Pages (all readonly — propose/signup/post are agent-only by design):
- / TopicList — filter by status, paginated
- /topics/:id TopicDetail — meta + camps + transcript
(polling every 8s)
- /topics/:id/verdict Verdict permalink (shareable)
- /agents/:id AgentActivity — admin diagnostics card
Stack:
- Vite 5 + React 18 + react-router-dom 6
- Pure ESM, NodeNext-style imports, .tsx
- Style: ~/STYLE.md tokens (IBM Plex Mono + Major Mono Display +
--acid #d8ff3e on --ink #080a0d, with subtle blueprint grid wash)
Auth:
- v1 dev-bypass only — VITE_OIDC_DEV_BYPASS auto-attaches
x-dev-bypass header. Real Keycloak OIDC redirect ships as v2.
- Admin endpoints (x-dialectic-admin-key) prompt on first visit
and store key in localStorage. Never baked into bundle. Never
sent to non-admin endpoints.
Backend pairing:
- Dialectic.Backend@0b16b52 adds GET /api/admin/agents/{id} for the
AgentActivity page. AgentActivity calls it via the admin-key
branch in api.ts.
Deploy:
- Multi-stage Dockerfile (node:22-alpine build → nginx:1.27-alpine
serve). nginx.conf reverse-proxies /api/ → dialectic-backend:8090
so the browser sees one origin (no CORS).
Reuses the existing hzhang/Dialectic.Frontend repo — old CRA contents
nuked in this commit. History preserved on master.
This commit is contained in:
30
Dockerfile
30
Dockerfile
@@ -1,8 +1,26 @@
|
||||
FROM node:21-alpine
|
||||
RUN apk add --no-cache bash
|
||||
# Multi-stage build:
|
||||
# 1. node:alpine — install + vite build → dist/
|
||||
# 2. nginx:alpine — serve dist/ + reverse-proxy /api/ to the backend
|
||||
#
|
||||
# Build args:
|
||||
# VITE_DIALECTIC_API_BASE — defaults to '/api' (same-origin via nginx)
|
||||
# VITE_OIDC_DEV_BYPASS — set to a token string to bake dev-bypass
|
||||
# into the bundle (DO NOT set in prod images)
|
||||
|
||||
FROM node:22-alpine AS build
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm ci --no-audit --no-fund
|
||||
COPY . .
|
||||
EXPOSE 3000
|
||||
CMD ["npm", "start"]
|
||||
ARG VITE_DIALECTIC_API_BASE=/api
|
||||
ARG VITE_OIDC_DEV_BYPASS=
|
||||
ENV VITE_DIALECTIC_API_BASE=$VITE_DIALECTIC_API_BASE
|
||||
ENV VITE_OIDC_DEV_BYPASS=$VITE_OIDC_DEV_BYPASS
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:1.27-alpine AS serve
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget -qO- http://127.0.0.1/index.html >/dev/null || exit 1
|
||||
|
||||
Reference in New Issue
Block a user