Skip to content

feat: Implemented runtime basepath config - #2561

Merged
lucaseduoli merged 1 commit into
mainfrom
fix/basepath_frontend
Oct 29, 2026
Merged

lucaseduoli merged 1 commit into
mainfrom
fix/basepath_frontend

Conversation

@lucaseduoli

@lucaseduoli lucaseduoli commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Cherry-pick from #2505

This pull request refactors how the OpenRAG frontend's base path (OPENRAG_FRONTEND_BASE_PATH) is configured and applied. The main improvement is that the base path can now be set at container runtime, rather than build time, allowing for more flexible deployments (especially on Kubernetes) without needing to rebuild the frontend image. This is accomplished by introducing a runtime entrypoint script that patches the base path in a writable copy of the frontend assets. The Makefile, Dockerfile, Helm chart, and documentation are updated to support and explain this new workflow.

Key changes:

Frontend Runtime Base Path Refactor:

  • Added a new frontend/entrypoint.sh script that copies frontend assets to a writable directory and replaces a placeholder with the runtime OPENRAG_FRONTEND_BASE_PATH. This enables changing the base path at container startup, not build time.
  • Updated Dockerfile.frontend to use the new entrypoint script and no longer require the base path as a build argument. The placeholder is now replaced at runtime. [1] [2]
  • Modified frontend/next.config.ts to use a placeholder for the base path during image build and to support runtime replacement. Added logic to distinguish between development, build, and runtime phases. [1] [2] [3] [4]
  • Added tests for the new base path logic in frontend/next.config.test.ts.

Build and Deployment Process Updates:

  • Removed the need to pass OPENRAG_FRONTEND_BASE_PATH as a build argument in the Makefile and Docker Compose, simplifying image builds and supporting runtime configuration instead. [1] [2] [3] [4]
  • Updated the Makefile to use a normalized frontend URL for local development and to reflect the new runtime base path configuration in output messages. [1] [2] [3] [4] [5] [6]

Kubernetes and Helm Improvements:

  • Modified the Helm chart (deployment.yaml) to set the base path as an environment variable and mount a writable volume for runtime asset patching. Liveness and readiness probes now respect the configured base path. [1] [2] [3]

Documentation and Environment Configuration:

  • Updated .env.example and documentation to clarify that the frontend base path is now a runtime setting and does not require rebuilding the image. Provided guidance for Kubernetes deployments. [1] [2]

These changes make frontend deployments more flexible and robust, especially in containerized and orchestrated environments.

Summary by CodeRabbit

  • New Features
    • Frontend URL prefixes can now be configured when the container starts, without rebuilding the image.
    • Prefixes are normalized automatically; invalid paths are rejected with an error.
    • Local startup displays the frontend URL using the configured port and path.
  • Documentation
    • Updated configuration guidance explains runtime path prefixes and writable runtime storage requirements.

* Implemented runtime basepath config

* fixed makefile not showing base path

* fixed picks

* fix not working in kb pod

* changed entrypoint to write at tmp

* fixed picks

* fix: validate runtime frontend base paths at startup (#2508)

Co-authored-by: Edwin Jose <edwin.jose@ibm.com>

---------

Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Co-authored-by: Edwin Jose <edwin.jose@ibm.com>
@lucaseduoli lucaseduoli self-assigned this Oct 29, 2026
@github-actions github-actions Bot added documentation 📘 Improvements or additions to documentation frontend 🟨 Issues related to the UI/UX docker enhancement 🔵 New feature or request and removed documentation 📘 Improvements or additions to documentation labels Oct 29, 2026
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 8ca4726 and 4f6398c.

Files selected for processing: 13
  • .env.example
  • Dockerfile.frontend
  • Makefile
  • docker-compose.yml
  • docs/docs/reference/configuration.mdx
  • frontend/entrypoint.sh
  • frontend/entrypoint.test.ts
  • frontend/lib/frontend-base-path.test.ts
  • frontend/lib/frontend-base-path.ts
  • frontend/next.config.test.ts
  • frontend/next.config.ts
  • kubernetes/helm/openrag/templates/frontend/deployment.yaml
  • kubernetes/helm/openrag/values.yaml

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

The frontend now applies its base path at container startup. The image uses standalone output, and local and Kubernetes configuration pass the path at runtime.

Changes

Frontend base-path configuration

Layer / File(s) Summary
Build configuration and path validation
frontend/next.config.ts, frontend/next.config.test.ts, frontend/lib/frontend-base-path.ts, frontend/lib/frontend-base-path.test.ts
The Next.js config factory selects a placeholder for production image builds when runtime base paths are enabled, and emits standalone output. Path validation uses an allowed-character set and rejects repeated slashes and dot segments. Tests cover configuration phases and path cases.
Container startup and asset replacement
Dockerfile.frontend, frontend/entrypoint.sh, frontend/entrypoint.test.ts
The image packages standalone output and starts through entrypoint.sh. The entrypoint validates the base path, copies assets to a writable runtime directory, replaces the placeholder in the copied assets, and starts server.js. Tests cover normalization, rejection, and missing standalone output.
Local and Kubernetes configuration
Makefile, docker-compose.yml, kubernetes/helm/openrag/templates/frontend/deployment.yaml, kubernetes/helm/openrag/values.yaml, docs/docs/reference/configuration.mdx, .env.example
Compose and Helm pass the base path at runtime. Helm mounts an emptyDir at /tmp and uses the normalized path for health probes. Makefile recipes omit the path build argument and display the configured local URL. Documentation describes path validation and writable runtime-directory requirements.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant NextConfig
  participant DockerImage
  participant entrypoint_sh
  participant server_js
  NextConfig->>DockerImage: build standalone output with a base-path placeholder
  DockerImage->>entrypoint_sh: start with the runtime base-path environment
  entrypoint_sh->>entrypoint_sh: validate path and copy assets to runtime directory
  entrypoint_sh->>entrypoint_sh: replace placeholder in copied assets
  entrypoint_sh->>server_js: execute from runtime directory
Loading
Merge Risk: Minimal · up to 4f639

The frontend path is configured at startup. No merge-blocking issue was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: runtime configuration for the frontend base path. It is concise and related to the pull request objectives.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 6 files. (7 skipped: 7 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Build successful! ✅
Deploying docs draft.
Deploy successful! View draft

@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Oct 29, 2026
@github-actions github-actions Bot added the lgtm label Oct 29, 2026
@lucaseduoli
lucaseduoli merged commit 83216b0 into main Oct 29, 2026
60 of 62 checks passed
@github-actions
github-actions Bot deleted the fix/basepath_frontend branch October 29, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker enhancement 🔵 New feature or request frontend 🟨 Issues related to the UI/UX lgtm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants