Skip to content

Commit

Permalink
Make build for prod env
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoric committed Jan 20, 2025
1 parent 4007aaa commit e9e04ae
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 46 deletions.
28 changes: 12 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ YK_VERSION=18a3c7f

# Add these near the top with other tool versions
NODE_VERSION ?= 22.13.0
PNPM_VERSION ?= latest
PNPM_VERSION ?= 9.15.4

# Add these with other LOCALBIN definitions
NODE_DIR ?= $(LOCALBIN_TOOLING)/node
Expand Down Expand Up @@ -319,14 +319,15 @@ test-k6-performance: ## run k6 performance tests.

.PHONY: web-build
web-build: node ## build the web components.
## Cleanup
rm -rf ./assets/**
rm -rf ./web/node_modules
## 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) production=true \
$(NODE_PATH) $(PNPM) --prefix ./web setenv
$(NODE_PATH) $(PNPM) --prefix ./web build
$(NODE_PATH) $(PNPM) --prefix ./web build:prod
echo "UHS Web Build Complete"
## Yunikorn Web
echo "Removing node modules from yunikorn-web"
Expand All @@ -336,10 +337,7 @@ web-build: node ## build the web components.
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) production=true \
$(NODE_PATH) $(PNPM) --prefix ./tmp setenv:prod
echo "Building yunikorn-web"
$(NODE_PATH) $(PNPM) --prefix ./tmp build:prod
Expand Down Expand Up @@ -615,11 +613,9 @@ $(K6): bin/tooling
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
mkdir -p $(NODE_DIR) && \
curl -fsSL https://nodejs.org/dist/v$(subst x,,$(NODE_VERSION))/node-v$(subst x,,$(NODE_VERSION))-$(OS)-$(ARCH).tar.gz | tar -xz --strip-components=1 -C $(NODE_DIR) && \
$(NODE_DIR)/bin/corepack enable && \
$(NODE_DIR)/bin/npm install -g pnpm@9 ; \
fi

5 changes: 2 additions & 3 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"run:all": "node node_modules/@angular-architects/module-federation/src/server/mf-dev-server.js",
"setenv": "npx --yes ts-node ./src/environments/setEnvironmentVariables.ts",
"setenv:prod": "npx --yes ts-node ./src/environments/setEnvironmentVariables.ts prod",
"prebuild:prod": "pnpm set-env-vars",
"start:json-server": "json-server --watch mock-server/db.json --config mock-server/server.json",
"prettify": "prettier --config ./.prettierrc --write 'src/**/*.{js,ts,json,css,scss,md,html}'"
},
Expand Down Expand Up @@ -52,11 +51,11 @@
"ngx-build-plus": "^18.0.0",
"prettier": "^3.3.3",
"typescript": "5.5.4",
"yunikorn-web": "github:G-Research/yunikorn-web"
"yunikorn-web": "github:G-Research/yunikorn-web#denis-coric/dynamic-env"
},
"engines": {
"pnpm": "9",
"node": "22"
},
"packageManager": "pnpm@9"
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0"
}
10 changes: 5 additions & 5 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions web/src/app/services/envconfig/envconfig.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

import { EnvConfig } from '@app/models/envconfig.model';
import { environment } from 'src/environments/environment';

const ENV_CONFIG_JSON_URL = './assets/config/envconfig.json';

Expand Down Expand Up @@ -56,15 +57,18 @@ export class EnvConfigService {
}

getYuniKornWebAddress() {
if (this.envConfig.yunikornApiURL) {
return `${this.envConfig.yunikornApiURL}/ws`;
console.log('environment.production', environment.production);
if (!environment.production) {
return `${this.envConfig.yunikornApiURL}/api`;
}

return `${this.uiProtocol}//${this.uiHostname}:${this.uiPort}/ws`;
return `${this.uiProtocol}//${this.uiHostname}:${this.uiPort}/api`;
}

getUHSWebAddress() {
if (this.envConfig.uhsApiURL) {
console.log('environment.production', environment.production);

if (!environment.production) {
return `${this.envConfig.uhsApiURL}/api`;
}

Expand Down
8 changes: 4 additions & 4 deletions web/src/assets/config/envconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"localUhsComponentsWebAddress": "http://localhost:3100",
"localUhsComponentsWebAddress": "http://127.0.0.1:8989",
"externalLogsURL": "https://logs.example.com?token=abc123&applicationId=",
"yunikornApiURL": "http://localhost:30001",
"uhsApiURL": "http://localhost:8989"
}
"yunikornApiURL": "http://127.0.0.1:30001",
"uhsApiURL": "http://127.0.0.1:8989"
}
16 changes: 2 additions & 14 deletions web/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,10 @@
* limitations under the License.
*/

// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.

export const environment = {
production: false,
production: true,
externalLogsURL: '',
yunikornApiURL: '',
uhsApiURL: '',
localUhsComponentsWebAddress: '',
};

/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.

0 comments on commit e9e04ae

Please sign in to comment.