From e94c88761c528c777697cffd07702025ce7aaa9d Mon Sep 17 00:00:00 2001 From: Yannan <73408381+YannanGao-gs@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:32:57 -0500 Subject: [PATCH] Enable data cude deployment --- .changeset/modern-dolls-sell.md | 2 + .changeset/tidy-pandas-serve.md | 6 ++ .github/workflows/check-docker.yml | 2 + .../scripts/setup.js | 2 +- .../Dockerfile | 2 +- ...datacube.config.js => data-cube.config.js} | 4 +- .../docker/config.json | 10 ++++ .../docker/entryPoint.sh | 16 +++++ .../docker/server-config.json | 60 +++++++++++++++++++ .../package.json | 2 +- .../src/index.tsx | 2 +- .../tsconfig.json | 2 +- .../webpack.config.js | 2 +- 13 files changed, 104 insertions(+), 8 deletions(-) create mode 100644 .changeset/modern-dolls-sell.md create mode 100644 .changeset/tidy-pandas-serve.md rename packages/legend-application-data-cube-deployment/{datacube.config.js => data-cube.config.js} (97%) create mode 100644 packages/legend-application-data-cube-deployment/docker/config.json create mode 100644 packages/legend-application-data-cube-deployment/docker/entryPoint.sh create mode 100644 packages/legend-application-data-cube-deployment/docker/server-config.json diff --git a/.changeset/modern-dolls-sell.md b/.changeset/modern-dolls-sell.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/modern-dolls-sell.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.changeset/tidy-pandas-serve.md b/.changeset/tidy-pandas-serve.md new file mode 100644 index 0000000000..a43d5a52b2 --- /dev/null +++ b/.changeset/tidy-pandas-serve.md @@ -0,0 +1,6 @@ +--- +'@finos/legend-application-data-cube-deployment': patch +'@finos/legend-application-data-cube-bootstrap': patch +--- + +Enable data cube deployment diff --git a/.github/workflows/check-docker.yml b/.github/workflows/check-docker.yml index 4edf4273dc..b0d6b07b58 100644 --- a/.github/workflows/check-docker.yml +++ b/.github/workflows/check-docker.yml @@ -43,6 +43,8 @@ jobs: package: '@finos/legend-application-studio-deployment' - image: local/legend-query package: '@finos/legend-application-query-deployment' + - image: local/legend-data-cube + package: '@finos/legend-application-data-cube-deployment' - image: local/legend-showcase-server package: '@finos/legend-server-showcase-deployment' steps: diff --git a/packages/legend-application-data-cube-bootstrap/scripts/setup.js b/packages/legend-application-data-cube-bootstrap/scripts/setup.js index 4c1c7cae1d..f5a106495d 100644 --- a/packages/legend-application-data-cube-bootstrap/scripts/setup.js +++ b/packages/legend-application-data-cube-bootstrap/scripts/setup.js @@ -39,7 +39,7 @@ export const setup = (outputDir) => { resolve(outputDir, 'config.json'), JSON.stringify( { - appName: 'query', + appName: 'data-cube', env: 'local', engine: { url: 'http://localhost:6300/api', diff --git a/packages/legend-application-data-cube-deployment/Dockerfile b/packages/legend-application-data-cube-deployment/Dockerfile index b247d18a0f..4fd084c545 100644 --- a/packages/legend-application-data-cube-deployment/Dockerfile +++ b/packages/legend-application-data-cube-deployment/Dockerfile @@ -1,5 +1,5 @@ FROM finos/legend-shared-server:0.23.5 -COPY dist/query /app/bin/webapp-content/web/query/ +COPY dist/data-cube /app/bin/webapp-content/web/data-cube/ RUN mkdir -p /config COPY docker/server-config.json /config/server-config.json diff --git a/packages/legend-application-data-cube-deployment/datacube.config.js b/packages/legend-application-data-cube-deployment/data-cube.config.js similarity index 97% rename from packages/legend-application-data-cube-deployment/datacube.config.js rename to packages/legend-application-data-cube-deployment/data-cube.config.js index 3109be0a92..bd38dca542 100644 --- a/packages/legend-application-data-cube-deployment/datacube.config.js +++ b/packages/legend-application-data-cube-deployment/data-cube.config.js @@ -27,7 +27,7 @@ export default { * e.g. `/something/` is the `baseUrl` of https://www.example.org/something/ * For URLs that have no path, use '/'. */ - baseUrl: '/datacube/', + baseUrl: '/data-cube/', /** * `devServerOptions` [object, optional] * Options to override `webpack-dev-server` configs. @@ -36,7 +36,7 @@ export default { devServerOptions: { // NOTE: for development from within a Docker container, it's best to update this to 0.0.0.0 host: '0.0.0.0', - port: 9001, + port: 9007, allowedHosts: 'all', }, }; diff --git a/packages/legend-application-data-cube-deployment/docker/config.json b/packages/legend-application-data-cube-deployment/docker/config.json new file mode 100644 index 0000000000..1acbe0a685 --- /dev/null +++ b/packages/legend-application-data-cube-deployment/docker/config.json @@ -0,0 +1,10 @@ +{ + "appName": "data-cube", + "env": "local", + "engine": { + "url": "${PROTOCOL}://${ENGINE_HOST}:${ENGINE_PORT}/api" + }, + "depot": { + "url": "${PROTOCOL}://${DEPOT_HOST}:${DEPOT_PORT}/depot/api" + } +} \ No newline at end of file diff --git a/packages/legend-application-data-cube-deployment/docker/entryPoint.sh b/packages/legend-application-data-cube-deployment/docker/entryPoint.sh new file mode 100644 index 0000000000..24fb199a1f --- /dev/null +++ b/packages/legend-application-data-cube-deployment/docker/entryPoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +PROTOCOL=${PROTOCOL:-http} +ENGINE_HOST=${ENGINE_HOST:-localhost} +ENGINE_PORT=${ENGINE_PORT:-6300} +DEPOT_HOST=${DEPOT_HOST:-localhost} +DEPOT_PORT=${DEPOT_PORT:-7000} + +sed -i 's~${PROTOCOL}~'$PROTOCOL'~g' /config/config.json +sed -i 's~${ENGINE_HOST}~'$ENGINE_HOST'~g' /config/config.json +sed -i 's~${ENGINE_PORT}~'$ENGINE_PORT'~g' /config/config.json +sed -i 's~${DEPOT_HOST}~'$DEPOT_HOST'~g' /config/config.json +sed -i 's~${DEPOT_PORT}~'$DEPOT_PORT'~g' /config/config.json + +java -cp /app/bin/webapp-content:/app/bin/* org.finos.legend.server.shared.staticserver.Server server /config/server-config.json + diff --git a/packages/legend-application-data-cube-deployment/docker/server-config.json b/packages/legend-application-data-cube-deployment/docker/server-config.json new file mode 100644 index 0000000000..e4488c3dee --- /dev/null +++ b/packages/legend-application-data-cube-deployment/docker/server-config.json @@ -0,0 +1,60 @@ +{ + "pac4j": { + "callbackPrefix": "/data-cube/log.in", + "bypassPaths": ["/data-cube/admin/healthcheck"], + "clients": [ + { + "org.finos.legend.server.pac4j.gitlab.GitlabClient": { + "name": "gitlab", + "clientId": "${GITLAB_APP_ID}", + "secret": "${GITLAB_APP_SECRET}", + "discoveryUri": "https://${GITLAB_HOST}/.well-known/openid-configuration", + "scope": "openid profile api" + } + } + ], + "mongoUri": "${MONGODB_URI}", + "mongoDb": "${MONGODB_NAME}", + "mongoSession": { + "enabled": ${MONGO_SESSION_ENABLED}, + "collection": "userSessions" + } + }, + "html5Router": true, + "routerExemptPaths": [ + "/editor.worker.js", + "/json.worker.js", + "/editor.worker.js.map", + "/json.worker.js.map", + "/version.json", + "/config.json", + "/favicon.ico", + "/static" + ], + "localAssetPaths": { + "/data-cube/config.json": "/config/config.json" + }, + "uiPath": "/data-cube", + "sessionCookie": "LEGEND_DATA_CUBE_JSESSIONID", + "server": { + "type": "simple", + "applicationContextPath": "/", + "adminContextPath": "/data-cube/admin", + "connector": { + "type": "http", + "port": ${DATA_CUBE_PORT} + } + }, + "logging": { + "level": "INFO", + "loggers": { + "root": { "level": "INFO" }, + "org.pac4j": { "level": "INFO" } + }, + "appenders": [ + { + "type": "console" + } + ] + } +} diff --git a/packages/legend-application-data-cube-deployment/package.json b/packages/legend-application-data-cube-deployment/package.json index 3ce138a0a6..42ea9d1260 100644 --- a/packages/legend-application-data-cube-deployment/package.json +++ b/packages/legend-application-data-cube-deployment/package.json @@ -32,7 +32,7 @@ "dev:webpack:debug": "cross-env NODE_ENV=development DEVELOPMENT_MODE=debug webpack serve --mode development", "lint:js": "cross-env NODE_ENV=production eslint --cache --cache-location ./build/.eslintcache --report-unused-disable-directives --parser-options=project:\"./tsconfig.json\",requireConfigFile:false \"./scripts/**/*.{mjs,cjs,js}\" \"./src/**/*.{js,ts,tsx}\"", "publish:docker": "echo 'Building webapp content...' && yarn bundle && ../../scripts/docker/publish-docker.sh finos/legend-data-cube", - "serve": "npx http-server ./dist -p 3000 -a localhost -g --cors -o /datacube", + "serve": "npx http-server ./dist -p 3000 -a localhost -g --cors -o /data-cube", "setup": "rimraf \"dev\" && yarn node ./scripts/setup.js ./dev" }, "dependencies": { diff --git a/packages/legend-application-data-cube-deployment/src/index.tsx b/packages/legend-application-data-cube-deployment/src/index.tsx index 7ce6596ab2..e12fca8e3a 100644 --- a/packages/legend-application-data-cube-deployment/src/index.tsx +++ b/packages/legend-application-data-cube-deployment/src/index.tsx @@ -15,7 +15,7 @@ */ import { LegendDataCubeWebApplication } from '@finos/legend-application-data-cube-bootstrap'; -import config from '../datacube.config.js'; +import config from '../data-cube.config.js'; import '../lib/tailwind.css'; // eslint-disable-line @finos/legend/no-cross-workspace-non-export-usage import './index.css'; diff --git a/packages/legend-application-data-cube-deployment/tsconfig.json b/packages/legend-application-data-cube-deployment/tsconfig.json index 0e7e0765ee..1a138a162d 100644 --- a/packages/legend-application-data-cube-deployment/tsconfig.json +++ b/packages/legend-application-data-cube-deployment/tsconfig.json @@ -10,7 +10,7 @@ "src/**/*.ts", "src/**/*.tsx", "src/**/*.json", - "datacube.config.js" + "data-cube.config.js" ], "references": [{ "path": "../legend-application-data-cube-bootstrap" }] } diff --git a/packages/legend-application-data-cube-deployment/webpack.config.js b/packages/legend-application-data-cube-deployment/webpack.config.js index 1a1440e001..b93a10bbd9 100644 --- a/packages/legend-application-data-cube-deployment/webpack.config.js +++ b/packages/legend-application-data-cube-deployment/webpack.config.js @@ -17,7 +17,7 @@ import { resolve, dirname } from 'path'; import webpack from 'webpack'; import CopyWebpackPlugin from 'copy-webpack-plugin'; -import appConfig from './datacube.config.js'; +import appConfig from './data-cube.config.js'; import { getEnvInfo, getWebAppBaseWebpackConfig,