chore(web): remove Go templates, integrate React build into Docker, clean up #10

Closed
opened 2026-02-06 20:44:38 +00:00 by forbes · 0 comments
Owner

Phase 4 of #6 — Frontend Migration

Goal

Complete the migration by removing the old Go template frontend, integrating the React build into the production Docker image, and updating all serving infrastructure.

Tasks

Remove Go Templates

  • Delete internal/api/templates/ directory (items.html, projects.html, schemas.html, settings.html, login.html, base.html, audit.html)
  • Remove template loading code from Go server (template parsing, html/template imports)
  • Remove HandleIndex, HandleProjects, HandleSchemas, HandleSettings web handlers
  • Remove web handler route group from routes.go
  • Remove CSRF middleware for web routes (React uses token auth, not cookie forms)

Go Server Static File Serving

  • Serve web/dist/ at / with SPA fallback (all non-API routes return index.html)
  • Option 1: go:embed the built assets into the binary for single-binary deployment
  • Option 2: Serve from filesystem path (configurable, default ./web/dist/)
  • Ensure /api/* routes take precedence over SPA fallback
  • Serve correct Content-Type headers for JS, CSS, SVG, etc.
  • Add cache headers for hashed assets (Vite produces hashed filenames)

Docker Integration

  • Update Dockerfile to multi-stage build:
    • Stage 1: Node — npm ci && npm run build in web/
    • Stage 2: Go — go build with embedded or copied web/dist/
    • Final: minimal runtime image with single binary
  • Update docker-compose.yaml — no changes needed if single binary
  • Update docker-compose.prod.yaml if it exists

Makefile Updates

  • Add make web-installcd web && npm ci
  • Add make web-buildcd web && npm run build
  • Add make web-devcd web && npm run dev
  • Update make build to include web build step
  • Update make clean to include web/dist/

Documentation Updates

  • Update README.md Quick Start to mention npm install / web build
  • Update DEPLOYMENT.md with new build steps
  • Update docs/STATUS.md to note React frontend
  • Update component tree in README.md to include web/ directory

Cleanup

  • Remove any remaining references to Go templates in docs
  • Ensure go build still works without web assets (graceful fallback or build tag)
  • Run full test suite
  • Verify Docker build produces working image

Acceptance Criteria

  • Single Docker image serves both API and React frontend
  • make build produces working binary with embedded frontend
  • No Go template code remains
  • All pages accessible at their React Router paths
  • API endpoints unaffected
  • Production deployment guide updated

Dependencies

Requires #7, #8, #9 (all pages migrated before templates can be removed).

## Phase 4 of #6 — Frontend Migration ### Goal Complete the migration by removing the old Go template frontend, integrating the React build into the production Docker image, and updating all serving infrastructure. ### Tasks #### Remove Go Templates - [ ] Delete `internal/api/templates/` directory (items.html, projects.html, schemas.html, settings.html, login.html, base.html, audit.html) - [ ] Remove template loading code from Go server (template parsing, `html/template` imports) - [ ] Remove `HandleIndex`, `HandleProjects`, `HandleSchemas`, `HandleSettings` web handlers - [ ] Remove web handler route group from `routes.go` - [ ] Remove CSRF middleware for web routes (React uses token auth, not cookie forms) #### Go Server Static File Serving - [ ] Serve `web/dist/` at `/` with SPA fallback (all non-API routes return index.html) - [ ] Option 1: `go:embed` the built assets into the binary for single-binary deployment - [ ] Option 2: Serve from filesystem path (configurable, default `./web/dist/`) - [ ] Ensure `/api/*` routes take precedence over SPA fallback - [ ] Serve correct Content-Type headers for JS, CSS, SVG, etc. - [ ] Add cache headers for hashed assets (Vite produces hashed filenames) #### Docker Integration - [ ] Update Dockerfile to multi-stage build: - Stage 1: Node — `npm ci && npm run build` in `web/` - Stage 2: Go — `go build` with embedded or copied `web/dist/` - Final: minimal runtime image with single binary - [ ] Update `docker-compose.yaml` — no changes needed if single binary - [ ] Update `docker-compose.prod.yaml` if it exists #### Makefile Updates - [ ] Add `make web-install` — `cd web && npm ci` - [ ] Add `make web-build` — `cd web && npm run build` - [ ] Add `make web-dev` — `cd web && npm run dev` - [ ] Update `make build` to include web build step - [ ] Update `make clean` to include `web/dist/` #### Documentation Updates - [ ] Update README.md Quick Start to mention `npm install` / web build - [ ] Update DEPLOYMENT.md with new build steps - [ ] Update docs/STATUS.md to note React frontend - [ ] Update component tree in README.md to include `web/` directory #### Cleanup - [ ] Remove any remaining references to Go templates in docs - [ ] Ensure `go build` still works without web assets (graceful fallback or build tag) - [ ] Run full test suite - [ ] Verify Docker build produces working image ### Acceptance Criteria - Single Docker image serves both API and React frontend - `make build` produces working binary with embedded frontend - No Go template code remains - All pages accessible at their React Router paths - API endpoints unaffected - Production deployment guide updated ### Dependencies Requires #7, #8, #9 (all pages migrated before templates can be removed).
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo#10