Repository navigation
perf(ui): pre-compile Angular UI on host and package via single-stage static container #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
66c62c4
perf(ui): pre-compile Angular UI on host and package via single-stage…
VLukiantsev 68273c3
fix(e2e): detect stale UI dist bundle and cleanup on failure
VLukiantsev d1bd0f7
perf(ui): ignore non-frontend files and skip redundant npm ci in UI b…
VLukiantsev 69f2297
fix(ui): harden file filtering, error handling, and dependency tracking
VLukiantsev ec34dbb
fix(ui): follow symlinks when traversing UI directory in _is_ui_dist_…
VLukiantsev 33c2ce5
fix(ui): use workspace temporary directory and verify npx availability
VLukiantsev 851390f
refactor(ui): clean up package mtime check and deduplicate test config
VLukiantsev f11691a
fix(ui): revert to system tempdir and wrap os.makedirs in try-except
VLukiantsev a504009
fix(ui): add dist staleness check in build_ui_oci and use .package-lo…
VLukiantsev 23206ab
fix(ui): simplify prebuilt dist presence check in build_ui_oci
VLukiantsev 8386ffa
fix(ui): optimize fallback Dockerfile caching and invalidate node_mod…
VLukiantsev b4a0750
fix(ui): add cycle detection in directory walks and preserve package …
VLukiantsev 49e0062
fix(ui): add path traversal guard in copy_flat and use .install-succe…
VLukiantsev ec6f9af
fix(ui): handle FileNotFoundError explicitly during dist cleanup
VLukiantsev cd16dd4
docs(ui): add explanatory docstrings and comments for two-tier packag…
VLukiantsev 1717991
fix(e2e): check UI dist staleness before Node check and harden test d…
VLukiantsev 256f539
fix(ui): filter symlinked ignored directories and handle rmtree OSError
VLukiantsev a968aea
test(ui): add build_ui_oci unit tests and document container packagin…
VLukiantsev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # UI Container Packaging (`cmd/ui`) | ||
|
|
||
| This directory contains the packaging logic for the XMC Web UI container image (`//cmd/ui:ui_image_tarball`). | ||
|
|
||
| --- | ||
|
|
||
| ## Packaging Architecture (`build_ui_oci.py`) | ||
|
|
||
| The container build uses a two-tier strategy to optimize local and CI build times while maintaining hermetic reproducibility: | ||
|
|
||
| ```mermaid | ||
| graph TD | ||
| A["build_ui_oci.py"] --> B{"Is 'dist/browser' present<br/>and fresher than source files?"} | ||
| B -->|Yes| C["Fast Single-Stage Build<br/>(FROM nginx:alpine, ~3s)"] | ||
| B -->|No / Missing / Stale| D["Hermetic Multi-Stage Build<br/>(node:22-alpine -> nginx:alpine, ~90s)"] | ||
| ``` | ||
|
|
||
| 1. **Fast Single-Stage Nginx Packaging (Tier 1)**: | ||
| - When pre-compiled Angular assets exist in `dist/browser` and are fresher than UI source files, `build_ui_oci.py` generates a single-stage `Dockerfile` (`FROM nginx:alpine`) that directly copies the pre-built bundle. | ||
| - Packaging takes **~3 seconds**. | ||
| 2. **Hermetic Multi-Stage Fallback (Tier 2)**: | ||
| - If `dist/browser` is absent, stale, or source files have been modified, it automatically falls back to a hermetic multi-stage build (`node:22-alpine` compiling with `npm ci` and `ng build`, copied into `nginx:alpine`). | ||
| - Requires zero host dependencies beyond Docker. | ||
|
|
||
| --- | ||
|
|
||
| ## Build Commands | ||
|
|
||
| - **Bazel Target**: | ||
| ```bash | ||
| bazel build //cmd/ui:ui_image_tarball | ||
| ``` | ||
| - **Direct CLI Execution**: | ||
| ```bash | ||
| python3 cmd/ui/build_ui_oci.py <output_tar> | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## E2E Runner Host Pre-Compilation (`test/e2e/lib/image_builder.py`) | ||
|
|
||
| The E2E test runner accelerates test execution by running `npm ci` and `ng build` directly on the host runner (where Node.js 22 is available) before invoking Bazel, allowing `build_ui_oci.py` to consistently hit the fast single-stage Nginx path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.