diff --git a/Makefile b/Makefile index 74d42157..7d742e56 100644 --- a/Makefile +++ b/Makefile @@ -101,6 +101,16 @@ MINIKUBE_VERSION ?= latest # used in integration and performance tests. YK_VERSION=18a3c7f +# Add these near the top with other tool versions +NODE_VERSION ?= 22.13.0 +PNPM_VERSION ?= latest + +# Add these with other LOCALBIN definitions +NODE_DIR ?= $(LOCALBIN_TOOLING)/node +PNPM ?= $(NODE_DIR)/lib/node_modules/corepack/shims/pnpm + +NODE_PATH := PATH=$(NODE_DIR)/bin:$(dir $(PNPM)):$$PATH + ##@ General # The help target prints out all targets with their descriptions organized @@ -308,17 +318,43 @@ test-k6-performance: ## run k6 performance tests. ##@ Build .PHONY: web-build -web-build: ng ## build the web components. - pnpm --prefix ./web install - pnpm --prefix ./web update yunikorn-web ## ensure that the yunikorn-web package is up to date - uhsApiURL=$(strip $(call uhs_api_url)) yunikornApiURL=$(strip $(call yunikorn_api_url)) pnpm --prefix ./web setenv - pnpm --prefix ./web build +web-build: node ## build the web components. +## YHS Web + $(NODE_PATH) $(PNPM) --prefix ./web install + $(NODE_PATH) $(PNPM) --prefix ./web update yunikorn-web ## ensure that the yunikorn-web package is up to date + $(NODE_PATH) uhsApiURL=$(strip $(call uhs_api_url)) yunikornApiURL=$(strip $(call yunikorn_api_url)) \ + moduleFederationRemoteEntry=$(strip $(call uhs_api_url))/remoteEntry.js \ + localUhsComponentsWebAddress=$(strip $(call uhs_api_url)) \ + $(NODE_PATH) $(PNPM) --prefix ./web setenv + $(NODE_PATH) $(PNPM) --prefix ./web build + echo "UHS Web Build Complete" +## Yunikorn Web + echo "Removing node modules from yunikorn-web" + rm -rf ./web/node_modules/yunikorn-web/node_modules + echo "Copying yunikorn-web" + rsync -av --copy-links ./web/node_modules/yunikorn-web/ ./tmp/ + echo "Installing yunikorn-web" + $(NODE_PATH) $(PNPM) --prefix ./tmp install + echo "Setting environment variables in yunikorn-web" + localSchedulerWebAddress=$(strip $(call yunikorn_api_url)) \ + uhsApiURL=$(strip $(call uhs_api_url)) yunikornApiURL=$(strip $(call yunikorn_api_url)) \ + moduleFederationRemoteEntry=$(strip $(call uhs_api_url))/remoteEntry.js \ + localUhsComponentsWebAddress=$(strip $(call uhs_api_url)) \ + $(NODE_PATH) $(PNPM) --prefix ./tmp setenv:prod + echo "Building yunikorn-web" + $(NODE_PATH) $(PNPM) --prefix ./tmp build:prod +## Merging Assets + echo "Moving envconfig.json" mv assets/assets/config/envconfig.json assets/assets/config/envconfig-uhs.json - ## copy and merge yunikorn-web assets into the UHS assets directory - rsync -av web/node_modules/yunikorn-web/dist/yunikorn-web/ assets + echo "Copy and Merge yunikorn-web assets into the UHS assets directory" + rsync -av ./tmp/dist/yunikorn-web/ assets + echo "Cleaning up yunikorn-web build" + rm -rf ./tmp + echo "Moving envconfig.json" mv assets/assets/config/envconfig.json assets/assets/config/envconfig-yk.json ## merge the two envconfig files cd assets/assets/config && jq -s '.[0] * .[1]' envconfig-yk.json envconfig-uhs.json > envconfig.json + echo "Web build completed" .PHONY: build build: bin/app ## build the unicorn-history-server binary for current OS and architecture. @@ -366,7 +402,7 @@ endif .PHONY: docker-build docker-build: OS=linux -docker-build: bin/docker clean build ## build docker image using buildx. +docker-build: bin/docker clean build web-build ## build docker image using buildx. echo "Building docker image for linux/$(ARCH)" docker buildx build \ --file build/unicorn-history-server/Dockerfile \ @@ -491,7 +527,7 @@ patch-yunikorn-service: ## patch yunikorn service to expose it as NodePort (yuni ##@ Build Dependencies .PHONY: install-tools -install-tools: golangci-lint gotestsum $(CLUSTER_MGR) helm yq ## install development tools. +install-tools: golangci-lint gotestsum $(CLUSTER_MGR) helm yq node ## install development tools. GOTESTSUM ?= $(LOCALBIN_TOOLING)/gotestsum GOTESTSUM_VERSION ?= v1.11.0 @@ -575,6 +611,15 @@ k6: xk6 $(K6) ## download k6 locally if necessary. $(K6): bin/tooling test -s $(K6) || $(XK6) build $(K6_VERSION) --with github.com/grafana/xk6-kubernetes --output $(K6) -.PHONY: ng -ng: ## install Angular CLI. - npm install -g @angular/cli@18 +.PHONY: node +node: $(NODE_DIR) ## download and setup node locally if necessary. +$(NODE_DIR): bin/tooling + if [ ! -d $(NODE_DIR) ]; then \ + mkdir -p $(NODE_DIR) ; \ + fi ; \ + NODE_ARCH="$$(if [ "$$(uname -m)" = "x86_64" ]; then echo "x64"; elif [ "$$(uname -m)" = "aarch64" ]; then echo "arm64"; else echo "$$(uname -m)"; fi)" ; \ + echo "Downloading node $(NODE_VERSION) for $(OS)-$${NODE_ARCH}: https://nodejs.org/dist/v$(subst x,,$(NODE_VERSION))/node-v$(subst x,,$(NODE_VERSION))-$(OS)-$${NODE_ARCH}.tar.gz" ; \ + curl -fsSL https://nodejs.org/dist/v$(subst x,,$(NODE_VERSION))/node-v$(subst x,,$(NODE_VERSION))-$(OS)-$${NODE_ARCH}.tar.gz | tar -xz --strip-components=1 -C $(NODE_DIR) ; \ + PATH=$(NODE_DIR)/bin:$$PATH $(NODE_DIR)/bin/corepack enable && \ + PATH=$(NODE_DIR)/bin:$$PATH $(NODE_DIR)/bin/corepack prepare pnpm@$(PNPM_VERSION) --activate + diff --git a/build/unicorn-history-server/Dockerfile b/build/unicorn-history-server/Dockerfile index a8c578b7..628c12d2 100644 --- a/build/unicorn-history-server/Dockerfile +++ b/build/unicorn-history-server/Dockerfile @@ -1,23 +1,8 @@ -ARG NODE_VERSION=22 ARG ALPINE_VERSION=3.20 -FROM node:${NODE_VERSION} AS builder -ENV PNPM_HOME="/pnpm" -ENV PATH="$PNPM_HOME:$PATH" -RUN corepack enable - -WORKDIR /build/src -COPY web ./ - -RUN npm install -g @angular/cli@18 -RUN npm install -g pnpm --force - -RUN pnpm install -RUN pnpm run build - FROM alpine:${ALPINE_VERSION} -COPY --from=builder /build/assets /app/assets +COPY assets /app/assets COPY bin/app/unicorn-history-server /app/unicorn-history-server COPY migrations /app/migrations COPY config/unicorn-history-server/config.yml /app/config.yml diff --git a/web/package.json b/web/package.json index 4c38aa70..5eb3d91b 100644 --- a/web/package.json +++ b/web/package.json @@ -5,7 +5,7 @@ "ng": "ng", "start": "ng serve", "build": "ng build", - "postbuild": "cd node_modules/yunikorn-web && pnpm install && pnpm build:prod", + "build:prod": "ng build --configuration production", "watch": "ng build --watch --configuration development", "test": "ng test", "preinstall": "npx only-allow pnpm", @@ -41,6 +41,7 @@ "@angular/cli": "^18.2.5", "@angular/compiler-cli": "^18.2.5", "@types/jasmine": "~5.1.4", + "@types/node": "^22.10.6", "jasmine-core": "~5.3.0", "json-server": "^0.17.4", "karma": "~6.4.4", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 3ffb423d..11e181e4 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -62,7 +62,7 @@ importers: devDependencies: '@angular-devkit/build-angular': specifier: ^18.2.5 - version: 18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.5)(chokidar@3.6.0)(karma@6.4.4)(typescript@5.5.4) + version: 18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.6)(chokidar@3.6.0)(karma@6.4.4)(typescript@5.5.4) '@angular/cli': specifier: ^18.2.5 version: 18.2.12(chokidar@3.6.0) @@ -72,6 +72,9 @@ importers: '@types/jasmine': specifier: ~5.1.4 version: 5.1.5 + '@types/node': + specifier: ^22.10.6 + version: 22.10.6 jasmine-core: specifier: ~5.3.0 version: 5.3.0 @@ -95,7 +98,7 @@ importers: version: 2.1.0(jasmine-core@5.3.0)(karma-jasmine@5.1.0(karma@6.4.4))(karma@6.4.4) ngx-build-plus: specifier: ^18.0.0 - version: 18.0.0(@angular-devkit/build-angular@18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.5)(chokidar@3.6.0)(karma@6.4.4)(typescript@5.5.4))(chokidar@3.6.0)(rxjs@7.8.1) + version: 18.0.0(@angular-devkit/build-angular@18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.6)(chokidar@3.6.0)(karma@6.4.4)(typescript@5.5.4))(chokidar@3.6.0)(rxjs@7.8.1) prettier: specifier: ^3.3.3 version: 3.4.2 @@ -104,7 +107,7 @@ importers: version: 5.5.4 yunikorn-web: specifier: github:G-Research/yunikorn-web - version: https://codeload.github.com/G-Research/yunikorn-web/tar.gz/e04bd5bc61c0226eabcfbb050e96e0930d900ea9(encoding@0.1.13) + version: https://codeload.github.com/G-Research/yunikorn-web/tar.gz/8628b4f8ee86e55e5c5089da0a7bf04bd86443fd(encoding@0.1.13) packages: @@ -1739,11 +1742,8 @@ packages: '@types/node-forge@1.3.11': resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==} - '@types/node@20.17.12': - resolution: {integrity: sha512-vo/wmBgMIiEA23A/knMfn/cf37VnuF52nZh5ZoW0GWt4e4sxNquibrMRJ7UQsA06+MBx9r/H1jsI9grYjQCQlw==} - - '@types/node@22.10.5': - resolution: {integrity: sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ==} + '@types/node@22.10.6': + resolution: {integrity: sha512-qNiuwC4ZDAUNcY47xgaSuS92cjf8JbSUoaKS77bmLG1rU7MlATVSiw/IlrjtIyyskXBZ8KkNfjK/P5na7rgXbQ==} '@types/qs@6.9.17': resolution: {integrity: sha512-rX4/bPcfmvxHDv0XjfJELTTr+iB+tn032nPILqHm5wbthUUUuVtNGGqzhya9XUxjTP8Fpr0qYgSZZKxGY++svQ==} @@ -4311,9 +4311,6 @@ packages: resolution: {integrity: sha512-us1E3K+3jJppDBa3Tl0L3MOJiGhe1C6P0+nIvQAFYbxlMAx0h81eOwLmU57xgqToduDDPx3y5QsdjPfDu+FgOQ==} hasBin: true - undici-types@6.19.8: - resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} - undici-types@6.20.0: resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} @@ -4598,8 +4595,8 @@ packages: resolution: {integrity: sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==} engines: {node: '>=18'} - yunikorn-web@https://codeload.github.com/G-Research/yunikorn-web/tar.gz/e04bd5bc61c0226eabcfbb050e96e0930d900ea9: - resolution: {tarball: https://codeload.github.com/G-Research/yunikorn-web/tar.gz/e04bd5bc61c0226eabcfbb050e96e0930d900ea9} + yunikorn-web@https://codeload.github.com/G-Research/yunikorn-web/tar.gz/8628b4f8ee86e55e5c5089da0a7bf04bd86443fd: + resolution: {tarball: https://codeload.github.com/G-Research/yunikorn-web/tar.gz/8628b4f8ee86e55e5c5089da0a7bf04bd86443fd} version: 0.0.0 engines: {node: '22', pnpm: '9'} @@ -4638,13 +4635,13 @@ snapshots: transitivePeerDependencies: - chokidar - '@angular-devkit/build-angular@18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.5)(chokidar@3.6.0)(karma@6.4.4)(typescript@5.5.4)': + '@angular-devkit/build-angular@18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.6)(chokidar@3.6.0)(karma@6.4.4)(typescript@5.5.4)': dependencies: '@ampproject/remapping': 2.3.0 '@angular-devkit/architect': 0.1802.12(chokidar@3.6.0) '@angular-devkit/build-webpack': 0.1802.12(chokidar@3.6.0)(webpack-dev-server@5.0.4(webpack@5.94.0(esbuild@0.23.0)))(webpack@5.94.0(esbuild@0.23.0)) '@angular-devkit/core': 18.2.12(chokidar@3.6.0) - '@angular/build': 18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.5)(chokidar@3.6.0)(less@4.2.0)(postcss@8.4.41)(terser@5.31.6)(typescript@5.5.4) + '@angular/build': 18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.6)(chokidar@3.6.0)(less@4.2.0)(postcss@8.4.41)(terser@5.31.6)(typescript@5.5.4) '@angular/compiler-cli': 18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4) '@babel/core': 7.25.2 '@babel/generator': 7.25.0 @@ -4657,7 +4654,7 @@ snapshots: '@babel/runtime': 7.25.0 '@discoveryjs/json-ext': 0.6.1 '@ngtools/webpack': 18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(typescript@5.5.4)(webpack@5.94.0(esbuild@0.23.0)) - '@vitejs/plugin-basic-ssl': 1.1.0(vite@5.4.6(@types/node@22.10.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6)) + '@vitejs/plugin-basic-ssl': 1.1.0(vite@5.4.6(@types/node@22.10.6)(less@4.2.0)(sass@1.77.6)(terser@5.31.6)) ansi-colors: 4.1.3 autoprefixer: 10.4.20(postcss@8.4.41) babel-loader: 9.1.3(@babel/core@7.25.2)(webpack@5.94.0(esbuild@0.23.0)) @@ -4697,7 +4694,7 @@ snapshots: tree-kill: 1.2.2 tslib: 2.6.3 typescript: 5.5.4 - vite: 5.4.6(@types/node@22.10.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6) + vite: 5.4.6(@types/node@22.10.6)(less@4.2.0)(sass@1.77.6)(terser@5.31.6) watchpack: 2.4.1 webpack: 5.94.0(esbuild@0.23.0) webpack-dev-middleware: 7.4.2(webpack@5.94.0(esbuild@0.23.0)) @@ -4760,7 +4757,7 @@ snapshots: '@angular/core': 18.2.13(rxjs@7.8.1)(zone.js@0.14.10) tslib: 2.8.1 - '@angular/build@18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.5)(chokidar@3.6.0)(less@4.2.0)(postcss@8.4.41)(terser@5.31.6)(typescript@5.5.4)': + '@angular/build@18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.6)(chokidar@3.6.0)(less@4.2.0)(postcss@8.4.41)(terser@5.31.6)(typescript@5.5.4)': dependencies: '@ampproject/remapping': 2.3.0 '@angular-devkit/architect': 0.1802.12(chokidar@3.6.0) @@ -4770,7 +4767,7 @@ snapshots: '@babel/helper-split-export-declaration': 7.24.7 '@babel/plugin-syntax-import-attributes': 7.24.7(@babel/core@7.25.2) '@inquirer/confirm': 3.1.22 - '@vitejs/plugin-basic-ssl': 1.1.0(vite@5.4.6(@types/node@22.10.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6)) + '@vitejs/plugin-basic-ssl': 1.1.0(vite@5.4.6(@types/node@22.10.6)(less@4.2.0)(sass@1.77.6)(terser@5.31.6)) browserslist: 4.24.4 critters: 0.0.24 esbuild: 0.23.0 @@ -4787,7 +4784,7 @@ snapshots: sass: 1.77.6 semver: 7.6.3 typescript: 5.5.4 - vite: 5.4.6(@types/node@22.10.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6) + vite: 5.4.6(@types/node@22.10.6)(less@4.2.0)(sass@1.77.6)(terser@5.31.6) watchpack: 2.4.1 optionalDependencies: less: 4.2.0 @@ -5871,7 +5868,7 @@ snapshots: '@inquirer/figures': 1.0.9 '@inquirer/type': 2.0.0 '@types/mute-stream': 0.0.4 - '@types/node': 22.10.5 + '@types/node': 22.10.6 '@types/wrap-ansi': 3.0.0 ansi-escapes: 4.3.2 cli-width: 4.1.0 @@ -6292,26 +6289,26 @@ snapshots: '@types/body-parser@1.19.5': dependencies: '@types/connect': 3.4.38 - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/bonjour@3.5.13': dependencies: - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/connect-history-api-fallback@1.5.4': dependencies: '@types/express-serve-static-core': 5.0.4 - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/connect@3.4.38': dependencies: - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/cookie@0.4.1': {} '@types/cors@2.8.17': dependencies: - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/d3-color@3.1.3': {} @@ -6348,14 +6345,14 @@ snapshots: '@types/express-serve-static-core@4.19.6': dependencies: - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/qs': 6.9.17 '@types/range-parser': 1.2.7 '@types/send': 0.17.4 '@types/express-serve-static-core@5.0.4': dependencies: - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/qs': 6.9.17 '@types/range-parser': 1.2.7 '@types/send': 0.17.4 @@ -6371,7 +6368,7 @@ snapshots: '@types/http-proxy@1.17.15': dependencies: - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/jasmine@5.1.5': {} @@ -6381,17 +6378,13 @@ snapshots: '@types/mute-stream@0.0.4': dependencies: - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/node-forge@1.3.11': dependencies: - '@types/node': 20.17.12 + '@types/node': 22.10.6 - '@types/node@20.17.12': - dependencies: - undici-types: 6.19.8 - - '@types/node@22.10.5': + '@types/node@22.10.6': dependencies: undici-types: 6.20.0 @@ -6404,7 +6397,7 @@ snapshots: '@types/send@0.17.4': dependencies: '@types/mime': 1.3.5 - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/serve-index@1.9.4': dependencies: @@ -6413,22 +6406,22 @@ snapshots: '@types/serve-static@1.15.7': dependencies: '@types/http-errors': 2.0.4 - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/send': 0.17.4 '@types/sockjs@0.3.36': dependencies: - '@types/node': 20.17.12 + '@types/node': 22.10.6 '@types/wrap-ansi@3.0.0': {} '@types/ws@8.5.13': dependencies: - '@types/node': 20.17.12 + '@types/node': 22.10.6 - '@vitejs/plugin-basic-ssl@1.1.0(vite@5.4.6(@types/node@22.10.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6))': + '@vitejs/plugin-basic-ssl@1.1.0(vite@5.4.6(@types/node@22.10.6)(less@4.2.0)(sass@1.77.6)(terser@5.31.6))': dependencies: - vite: 5.4.6(@types/node@22.10.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6) + vite: 5.4.6(@types/node@22.10.6)(less@4.2.0)(sass@1.77.6)(terser@5.31.6) '@webassemblyjs/ast@1.14.1': dependencies: @@ -7122,7 +7115,7 @@ snapshots: dependencies: '@types/cookie': 0.4.1 '@types/cors': 2.8.17 - '@types/node': 20.17.12 + '@types/node': 22.10.6 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.7.2 @@ -7792,7 +7785,7 @@ snapshots: jest-worker@27.5.1: dependencies: - '@types/node': 20.17.12 + '@types/node': 22.10.6 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -8236,9 +8229,9 @@ snapshots: neo-async@2.6.2: {} - ngx-build-plus@18.0.0(@angular-devkit/build-angular@18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.5)(chokidar@3.6.0)(karma@6.4.4)(typescript@5.5.4))(chokidar@3.6.0)(rxjs@7.8.1): + ngx-build-plus@18.0.0(@angular-devkit/build-angular@18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.6)(chokidar@3.6.0)(karma@6.4.4)(typescript@5.5.4))(chokidar@3.6.0)(rxjs@7.8.1): dependencies: - '@angular-devkit/build-angular': 18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.5)(chokidar@3.6.0)(karma@6.4.4)(typescript@5.5.4) + '@angular-devkit/build-angular': 18.2.12(@angular/compiler-cli@18.2.13(@angular/compiler@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.5.4))(@types/node@22.10.6)(chokidar@3.6.0)(karma@6.4.4)(typescript@5.5.4) '@schematics/angular': 18.2.12(chokidar@3.6.0) rxjs: 7.8.1 webpack-merge: 5.10.0 @@ -9216,8 +9209,6 @@ snapshots: ua-parser-js@0.7.40: {} - undici-types@6.19.8: {} - undici-types@6.20.0: {} unicode-canonical-property-names-ecmascript@2.0.1: {} @@ -9270,13 +9261,13 @@ snapshots: vary@1.1.2: {} - vite@5.4.6(@types/node@22.10.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6): + vite@5.4.6(@types/node@22.10.6)(less@4.2.0)(sass@1.77.6)(terser@5.31.6): dependencies: esbuild: 0.21.5 postcss: 8.4.49 rollup: 4.30.1 optionalDependencies: - '@types/node': 22.10.5 + '@types/node': 22.10.6 fsevents: 2.3.3 less: 4.2.0 sass: 1.77.6 @@ -9494,7 +9485,7 @@ snapshots: yoctocolors-cjs@2.1.2: {} - yunikorn-web@https://codeload.github.com/G-Research/yunikorn-web/tar.gz/e04bd5bc61c0226eabcfbb050e96e0930d900ea9(encoding@0.1.13): + yunikorn-web@https://codeload.github.com/G-Research/yunikorn-web/tar.gz/8628b4f8ee86e55e5c5089da0a7bf04bd86443fd(encoding@0.1.13): dependencies: '@angular-architects/module-federation': 18.0.6(@angular/common@18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1))(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10))(encoding@0.1.13) '@angular/animations': 18.2.13(@angular/core@18.2.13(rxjs@7.8.1)(zone.js@0.14.10)) diff --git a/web/src/assets/config/envconfig.example.json b/web/src/assets/config/envconfig.example.json new file mode 100644 index 00000000..5c028057 --- /dev/null +++ b/web/src/assets/config/envconfig.example.json @@ -0,0 +1,6 @@ +{ + "localUhsComponentsWebAddress": "http://localhost:3100", + "externalLogsURL": "https://logs.example.com?token=abc123&applicationId=", + "yunikornApiURL": "http://localhost:30001", + "uhsApiURL": "http://localhost:8989" +} diff --git a/web/src/environments/environment.template.ts b/web/src/environments/environment.template.ts index e5c71853..81681004 100644 --- a/web/src/environments/environment.template.ts +++ b/web/src/environments/environment.template.ts @@ -21,4 +21,5 @@ export const environment = { externalLogsURL: '', yunikornApiURL: '', uhsApiURL: '', + localUhsComponentsWebAddress: '', }; diff --git a/web/src/environments/setEnvironmentVariables.ts b/web/src/environments/setEnvironmentVariables.ts index 148e2123..2ea23ca6 100644 --- a/web/src/environments/setEnvironmentVariables.ts +++ b/web/src/environments/setEnvironmentVariables.ts @@ -20,15 +20,24 @@ const fs = require('fs'); let config = process.argv[2]; let template_environment = fs.readFileSync('./src/environments/environment.template.ts').toString(); +let envconfig = JSON.parse(fs.readFileSync('./src/assets/config/envconfig.json').toString()); Object.keys(process.env).forEach((env_var) => { + // Handle TypeScript environment file let regex = new RegExp(`(${env_var}:)(\\s*?)('.*?'|".*?")`); template_environment = template_environment.replace( regex, `${env_var}: '${process.env[env_var]}'` ); + + // Handle JSON config file + if (envconfig.hasOwnProperty(env_var)) { + envconfig[env_var] = process.env[env_var]; + } }); if (config && config === 'prod') fs.writeFileSync(`./src/environments/environment.${config}.ts`, template_environment); else fs.writeFileSync('./src/environments/environment.ts', template_environment); + +fs.writeFileSync('./src/assets/config/envconfig.json', JSON.stringify(envconfig, null, 2));