Skip to content

[T-116] Web production image: nginx (non-root), runtime /config.json, CSP & security headers, compose web service #185

Closed

Description

@CodewithJha

Task T-116 · Milestone M8 — Dashboard · Size S · Priority P0 · Epic #8

Implements NFR-DEP-001 · NFR-SEC-001

Branch ci/t-116-web-production-image-nginx-non — one task = one branch = one PR (doc 32 §6)

Summary

Create docker/web/Dockerfile (pnpm build → nginx-unprivileged), nginx.conf (SPA fallback, /api reverse proxy with SSE buffering off, gzip/brotli static, cache headers for hashed assets), strict CSP / X-Content-Type-Options / Referrer-Policy / frame-ancestors headers, /config.json generated from env at container start, and the compose web service (app profile).

Context / motivation

Doc 17 §5 / doc 29: one-command deployment; CSP mitigates XSS (TM-05).

Scope

In scope

  • Healthcheck; read-only root FS compatible.

Implementation guidance

  • docker/web/Dockerfile: stage 1 node:22-alpine + corepack pnpm, pnpm install --frozen-lockfile, pnpm build; stage 2 nginxinc/nginx-unprivileged pinned by digest serving /usr/share/nginx/html on 8080 as non-root.
  • Entrypoint hook docker/web/40-config-json.sh (nginx docker-entrypoint.d) writes /config.json from ROBOPROBE_WEB_API_BASE_URL, ROBOPROBE_WEB_SSE_URL, ROBOPROBE_WEB_DEFAULT_THEME, ROBOPROBE_WEB_FEATURES (doc 27 §4.11) into a tmpfs-backed path (read-only root FS compatible).
  • nginx.conf: SPA fallback try_files $uri /index.html; location /api/ → proxy_pass http://api:8000 with proxy_http_version 1.1; proxy_buffering off and proxy_read_timeout 1h for /api/v1/events; gzip for text assets; Cache-Control: public, max-age=31536000, immutable for hashed /assets/*, no-cache for index.html/config.json.
  • Security headers: Content-Security-Policy: default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; connect-src 'self'; frame-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none' (Plotly requires inline styles — document why), X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer, minimal Permissions-Policy.
  • Compose web service (profile app): port ${ROBOPROBE_WEB_PORT:-8080}, depends_on api healthy, healthcheck wget -qO- http://localhost:8080/.
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Configuration keys

From the configuration reference (doc 27). Keys marked (new) must be added to the typed settings models and appear in the generated reference (T-003c).

  • ROBOPROBE_WEB_API_BASE_URL
  • ROBOPROBE_WEB_SSE_URL
  • ROBOPROBE_WEB_DEFAULT_THEME
  • ROBOPROBE_WEB_FEATURES
  • ROBOPROBE_WEB_PORT

Acceptance criteria

  • docker compose --profile app up serves the dashboard at the configured port; SSE works through nginx.
  • Security headers verified by a curl test in CI.
  • CSP produces no violations on any route in E2E (console listener asserts).
  • Image runs with read_only: true.
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • CI smoke job: build image, curl headers, SSE through proxy.

Dependencies

Blocked by: #165 (T-085d), #27 (T-005b)

Blocks: #186 (T-117), #189 (T-119), #219 (T-127)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • docker/web/**
  • docker/compose.yaml (web service block)

Infra-only; compose edit append-only.

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-116 (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 17 §5 · doc 17 §4 · doc 29 §3 · doc 21 §1 · doc 30 §RB-06 · doc 27 §4.11 · doc 27 §4.12

Requirements: NFR-DEP-001 · NFR-SEC-001 (traceability: doc 28)

External:

Activity

  1. added this to the M8 — Dashboard milestone on Nov 19, 2026
  2. added
    type:infraCI, build, deployment infrastructure
    area:deployDocker images, compose, release packaging
    area:securitySecurity hardening, supply chain
    priority:P0Critical path / blocks others
    taskChild task of a milestone epic
    on Nov 19, 2026
  3. added a commit that references this issue on Nov 22, 2026
    a1eecdc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:dashboardReact web dashboardarea:deployDocker images, compose, release packagingarea:securitySecurity hardening, supply chainmilestone:M8M8 — Dashboardpriority:P0Critical path / blocks otherssize:S<= 1 daytaskChild task of a milestone epictype:infraCI, build, deployment infrastructure

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions