diff --git a/packages/kogito-management-console/README.md b/packages/kogito-management-console/README.md index fad43901389..359550d08ed 100644 --- a/packages/kogito-management-console/README.md +++ b/packages/kogito-management-console/README.md @@ -70,18 +70,18 @@ This package contains the `Containerfile/Dockerfile` and scripts to build a cont [comment]: <> (//TODO: Use EnvJson.schema.json to generate this documentation somehow.. See https://github.com/kiegroup/kie-issues/issues/16) - | Name | Description | Default | - | :----------------------------------------------------: | :-----------------------------------------------------------: | :------------------------------------------------------------------------------------------: | - | `RUNTIME_TOOLS_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE` | Env Mode: "PROD" or "DEV". PROD enables Keycloak integration. | "PROD" | - | `RUNTIME_TOOLS_MANAGEMENT_CONSOLE_KOGITO_APP_NAME` | Management Console app name. | See [ defaultEnvJson.ts ](../runtime-tools-managment-console-webapp/build/defaultEnvJson.js) | - | `RUNTIME_TOOLS_MANAGEMENT_CONSOLE_KOGITO_APP_VERSION` | Management Console app version. | See [ defaultEnvJson.ts ](../runtime-tools-managment-console-webapp/build/defaultEnvJson.js) | - | `RUNTIME_TOOLS_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT` | The URL that points to the Data Index service. | See [ defaultEnvJson.ts ](../runtime-tools-managment-console-webapp/build/defaultEnvJson.js) | - | `KOGITO_CONSOLES_KEYCLOAK_DISABLE_HEALTH_CHECK` | Disables Keycloak health-check. | See [ defaultEnvJson.ts ](../runtime-tools-managment-console-webapp/build/defaultEnvJson.js) | - | `KOGITO_CONSOLES_KEYCLOAK_UPDATE_TOKEN_VALIDITY` | Update token validity in minutes. | See [ defaultEnvJson.ts ](../runtime-tools-managment-console-webapp/build/defaultEnvJson.js) | - | `KOGITO_CONSOLES_KEYCLOAK_HEALTH_CHECK_URL` | Keycloak health-check URL. | See [ defaultEnvJson.ts ](../runtime-tools-managment-console-webapp/build/defaultEnvJson.js) | - | `KOGITO_CONSOLES_KEYCLOAK_REALM` | Keycloak realm name. | See [ defaultEnvJson.ts ](../runtime-tools-managment-console-webapp/build/defaultEnvJson.js) | - | `KOGITO_CONSOLES_KEYCLOAK_URL` | Keycloak auth URL. | See [ defaultEnvJson.ts ](../runtime-tools-managment-console-webapp/build/defaultEnvJson.js) | - | `KOGITO_CONSOLES_KEYCLOAK_CLIENT_ID` | Keycloak Client ID. | See [ defaultEnvJson.ts ](../runtime-tools-managment-console-webapp/build/defaultEnvJson.js) | + | Name | Description | Default | + | :----------------------------------------------------: | :-----------------------------------------------------------: | :-------------------------------------------------------------------------------------------: | + | `RUNTIME_TOOLS_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE` | Env Mode: "PROD" or "DEV". PROD enables Keycloak integration. | "PROD" | + | `RUNTIME_TOOLS_MANAGEMENT_CONSOLE_KOGITO_APP_NAME` | Management Console app name. | See [ defaultEnvJson.js ](../runtime-tools-management-console-webapp/build/defaultEnvJson.js) | + | `RUNTIME_TOOLS_MANAGEMENT_CONSOLE_KOGITO_APP_VERSION` | Management Console app version. | See [ defaultEnvJson.js ](../runtime-tools-management-console-webapp/build/defaultEnvJson.js) | + | `RUNTIME_TOOLS_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT` | The URL that points to the Data Index service. | See [ defaultEnvJson.js ](../runtime-tools-management-console-webapp/build/defaultEnvJson.js) | + | `KOGITO_CONSOLES_KEYCLOAK_DISABLE_HEALTH_CHECK` | Disables Keycloak health-check. | See [ defaultEnvJson.js ](../runtime-tools-management-console-webapp/build/defaultEnvJson.js) | + | `KOGITO_CONSOLES_KEYCLOAK_UPDATE_TOKEN_VALIDITY` | Update token validity in minutes. | See [ defaultEnvJson.js ](../runtime-tools-management-console-webapp/build/defaultEnvJson.js) | + | `KOGITO_CONSOLES_KEYCLOAK_HEALTH_CHECK_URL` | Keycloak health-check URL. | See [ defaultEnvJson.js ](../runtime-tools-management-console-webapp/build/defaultEnvJson.js) | + | `KOGITO_CONSOLES_KEYCLOAK_REALM` | Keycloak realm name. | See [ defaultEnvJson.js ](../runtime-tools-management-console-webapp/build/defaultEnvJson.js) | + | `KOGITO_CONSOLES_KEYCLOAK_URL` | Keycloak auth URL. | See [ defaultEnvJson.js ](../runtime-tools-management-console-webapp/build/defaultEnvJson.js) | + | `KOGITO_CONSOLES_KEYCLOAK_CLIENT_ID` | Keycloak Client ID. | See [ defaultEnvJson.js ](../runtime-tools-management-console-webapp/build/defaultEnvJson.js) | ### Examples diff --git a/packages/sonataflow-management-console-image/Containerfile b/packages/sonataflow-management-console-image/Containerfile new file mode 100644 index 00000000000..1d0e875c37b --- /dev/null +++ b/packages/sonataflow-management-console-image/Containerfile @@ -0,0 +1,51 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +FROM --platform=linux/amd64 registry.access.redhat.com/ubi9/ubi-minimal:9.4 + +ARG KOGITO_MANAGEMENT_CONSOLE_PORT=8080 + +ENV SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE="PROD" + +COPY entrypoint.sh dist-dev/image-env-to-json-standalone dist-dev/EnvJson.schema.json /tmp/ + +RUN microdnf --disableplugin=subscription-manager -y install httpd \ + && microdnf --disableplugin=subscription-manager clean all \ + && echo "Mutex posixsem" >> /etc/httpd/conf/httpd.conf \ + && sed -i -e "/#ServerName www.example.com:80/aHeader set Content-Security-Policy \"frame-ancestors 'self';\"" /etc/httpd/conf/httpd.conf \ + && sed -i -e 's/Options Indexes FollowSymLinks/Options -Indexes +FollowSymLinks/' /etc/httpd/conf/httpd.conf \ + && sed -i "s/Listen 80/Listen ${KOGITO_MANAGEMENT_CONSOLE_PORT}/g" /etc/httpd/conf/httpd.conf \ + && sed -i "s/#ServerName www.example.com:80/ServerName 127.0.0.1:${KOGITO_MANAGEMENT_CONSOLE_PORT}/g" /etc/httpd/conf/httpd.conf \ + && sed -i '$ a ServerTokens Prod' /etc/httpd/conf/httpd.conf \ + && sed -i '$ a ServerSignature Off' /etc/httpd/conf/httpd.conf \ + && sed -i -e '//a RewriteEngine on\n RewriteCond %{REQUEST_FILENAME} -f [OR]\n RewriteCond %{REQUEST_FILENAME} -d\n RewriteRule ^ - [L]\n RewriteRule ^ index.html [L]' /etc/httpd/conf/httpd.conf \ + && chmod -R g=u /etc/httpd/conf \ + && mkdir /management-console \ + && mv -t /management-console /tmp/entrypoint.sh /tmp/image-env-to-json-standalone /tmp/EnvJson.schema.json \ + && chgrp -R 0 /var/log/httpd /var/run/httpd /var/www/html /management-console \ + && chmod -R g=u /var/log/httpd /var/run/httpd /var/www/html /management-console \ + && chmod +x /management-console/entrypoint.sh /management-console/image-env-to-json-standalone + +COPY dist-dev/sonataflow-management-console-webapp /management-console/app + +RUN if [ -f /management-console/app/env.json ]; then chmod a+w /management-console/app/env.json; fi + +EXPOSE ${KOGITO_MANAGEMENT_CONSOLE_PORT} + +USER 1000 + +ENTRYPOINT [ "/management-console/entrypoint.sh" ] diff --git a/packages/sonataflow-management-console-image/README.md b/packages/sonataflow-management-console-image/README.md new file mode 100644 index 00000000000..11b734e2340 --- /dev/null +++ b/packages/sonataflow-management-console-image/README.md @@ -0,0 +1,140 @@ + + +# SonataFlow Management Console Image + +This package contains the `Containerfile/Dockerfile` and scripts to build a container image for SonataFlow Management Console. It also generated a JSON Schema for the `env.json` file, enabling it to be validated. + +## Additional requirements + +- docker + +## Build + +- Enable the image to be built: + + ```bash + export KIE_TOOLS_BUILD__buildContainerImages=true + ``` + +- (Optional) The image name and tags can be customized by setting the following environment variables: + + ```bash + export KOGITO_MANAGEMENT_CONSOLE__registry= + export KOGITO_MANAGEMENT_CONSOLE__account= + export KOGITO_MANAGEMENT_CONSOLE__name= + export KOGITO_MANAGEMENT_CONSOLE__buildTag= + ``` + + > Default values can be found [here](./env/index.js). + +- After optionally setting up the environment variables, run the following in the root folder of the repository to build the package: + + ```bash + pnpm -F @kie-tools/sonataflow-management-console-image... build:prod + ``` + +- Then check if the image is correctly stored: + + ```bash + docker images + ``` + +## Run + +- Start up a clean container with: + + ```bash + docker run -t -p 8080:8080 -i --rm docker.io/apache/incubator-kie-sonataflow-management-console:main + ``` + + Management Console will be up at http://localhost:8080 + +## Customization + +1. Run a container with custom environment variables: + + [comment]: <> (//TODO: Use EnvJson.schema.json to generate this documentation somehow.. See https://github.com/kiegroup/kie-issues/issues/16) + + | Name | Description | Default | + | :-------------------------------------------------: | :-----------------------------------------------------------: | :----------------------------------------------------------------------------------------: | + | `SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE` | Env Mode: "PROD" or "DEV". PROD enables Keycloak integration. | "PROD" | + | `SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_APP_NAME` | Management Console app name. | See [ defaultEnvJson.ts ](../sonataflow-management-console-webapp/build/defaultEnvJson.ts) | + | `SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_APP_VERSION` | Management Console app version. | See [ defaultEnvJson.ts ](../sonataflow-management-console-webapp/build/defaultEnvJson.ts) | + | `SONATAFLOW_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT` | The URL that points to the Data Index service. | See [ defaultEnvJson.ts ](../sonataflow-management-console-webapp/build/defaultEnvJson.ts) | + | `KOGITO_CONSOLES_KEYCLOAK_DISABLE_HEALTH_CHECK` | Disables Keycloak health-check. | See [ defaultEnvJson.ts ](../sonataflow-management-console-webapp/build/defaultEnvJson.ts) | + | `KOGITO_CONSOLES_KEYCLOAK_UPDATE_TOKEN_VALIDITY` | Update token validity in minutes. | See [ defaultEnvJson.ts ](../sonataflow-management-console-webapp/build/defaultEnvJson.ts) | + | `KOGITO_CONSOLES_KEYCLOAK_HEALTH_CHECK_URL` | Keycloak health-check URL. | See [ defaultEnvJson.ts ](../sonataflow-management-console-webapp/build/defaultEnvJson.ts) | + | `KOGITO_CONSOLES_KEYCLOAK_REALM` | Keycloak realm name. | See [ defaultEnvJson.ts ](../sonataflow-management-console-webapp/build/defaultEnvJson.ts) | + | `KOGITO_CONSOLES_KEYCLOAK_URL` | Keycloak auth URL. | See [ defaultEnvJson.ts ](../sonataflow-management-console-webapp/build/defaultEnvJson.ts) | + | `KOGITO_CONSOLES_KEYCLOAK_CLIENT_ID` | Keycloak Client ID. | See [ defaultEnvJson.ts ](../sonataflow-management-console-webapp/build/defaultEnvJson.ts) | + + ### Examples + + 1. Using a different Data Index Service. + + ```bash + docker run -t -p 8080:8080 -e SONATAFLOW_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT= -i --rm docker.io/apache/incubator-kie-sonataflow-management-console:main + ``` + + _NOTE: Replace `docker` with `podman` if necessary._ + +2. Write a custom `Containerfile/Dockerfile` from the image: + + ```docker + FROM docker.io/apache/incubator-kie-sonataflow-management-console:main + + ENV SONATAFLOW_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT= + ``` + +3. Create the application from the image in OpenShift and set the deployment environment variable right from the OpenShift UI. + +## Custom Port + +The port used internally on the container can be changed: + +When building, set the `SONATAFLOW_MANAGEMENT_CONSOLE__port` environment variable to any port you want, and the Containerfile will be built using that port. + +--- + +Apache KIE (incubating) is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the name of Apache Incubator. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + +Some of the incubating project’s releases may not be fully compliant with ASF +policy. For example, releases may have incomplete or un-reviewed licensing +conditions. What follows is a list of known issues the project is currently +aware of (note that this list, by definition, is likely to be incomplete): + +- Hibernate, an LGPL project, is being used. Hibernate is in the process of relicensing to ASL v2 +- Some files, particularly test files, and those not supporting comments, may be missing the ASF Licensing Header +- + +- Hibernate, an LGPL project, is being used. Hibernate is in the process of + relicensing to ASL v2 +- Some files, particularly test files, and those not supporting comments, may + be missing the ASF Licensing Header + +If you are planning to incorporate this work into your product/project, please +be aware that you will need to conduct a thorough licensing review to determine +the overall implications of including this work. For the current status of this +project through the Apache Incubator visit: +https://incubator.apache.org/projects/kie.html diff --git a/packages/sonataflow-management-console-image/entrypoint.sh b/packages/sonataflow-management-console-image/entrypoint.sh new file mode 100644 index 00000000000..1b92377150b --- /dev/null +++ b/packages/sonataflow-management-console-image/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Copying the Task Console assets here is essential for when the container is running with the readOnlyRootFilesystem flag. +# But, just like any other directory modified during runtime, the /var/www/html must be a mounted volume in the container in this case. +cp -R /management-console/app/* /var/www/html + +/management-console/image-env-to-json-standalone --directory /var/www/html --json-schema /management-console/EnvJson.schema.json + +httpd -D FOREGROUND diff --git a/packages/sonataflow-management-console-image/env/index.js b/packages/sonataflow-management-console-image/env/index.js new file mode 100644 index 00000000000..c4f30e8c6f9 --- /dev/null +++ b/packages/sonataflow-management-console-image/env/index.js @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +const { varsWithName, composeEnv, getOrDefault } = require("@kie-tools-scripts/build-env"); + +const rootEnv = require("@kie-tools/root-env/env"); + +module.exports = composeEnv([rootEnv], { + vars: varsWithName({ + SONATAFLOW_MANAGEMENT_CONSOLE__registry: { + default: "docker.io", + description: "E.g., `docker.io` or `quay.io`.", + }, + SONATAFLOW_MANAGEMENT_CONSOLE__account: { + default: "apache", + description: "E.g,. `apache` or `kie-tools-bot`", + }, + SONATAFLOW_MANAGEMENT_CONSOLE__name: { + default: "incubator-kie-sonataflow-management-console", + description: "Name of the image itself.", + }, + SONATAFLOW_MANAGEMENT_CONSOLE__buildTag: { + default: rootEnv.env.root.streamName, + description: "Tag version of this image. E.g., `main` or `10.0.x` or `10.0.0", + }, + SONATAFLOW_MANAGEMENT_CONSOLE__port: { + default: 8080, + description: "The internal container port.", + }, + }), + get env() { + return { + sonataflowManagementConsoleImage: { + registry: getOrDefault(this.vars.SONATAFLOW_MANAGEMENT_CONSOLE__registry), + account: getOrDefault(this.vars.SONATAFLOW_MANAGEMENT_CONSOLE__account), + name: getOrDefault(this.vars.SONATAFLOW_MANAGEMENT_CONSOLE__name), + buildTag: getOrDefault(this.vars.SONATAFLOW_MANAGEMENT_CONSOLE__buildTag), + port: getOrDefault(this.vars.SONATAFLOW_MANAGEMENT_CONSOLE__port), + version: require("../package.json").version, + }, + }; + }, +}); diff --git a/packages/sonataflow-management-console-image/package.json b/packages/sonataflow-management-console-image/package.json new file mode 100644 index 00000000000..58e081db562 --- /dev/null +++ b/packages/sonataflow-management-console-image/package.json @@ -0,0 +1,38 @@ +{ + "private": true, + "name": "@kie-tools/sonataflow-management-console-image", + "version": "0.0.0", + "description": "", + "license": "Apache-2.0", + "homepage": "https://github.com/apache/incubator-kie-tools", + "repository": { + "type": "git", + "url": "https://github.com/apache/incubator-kie-tools.git" + }, + "bugs": { + "url": "https://github.com/apache/incubator-kie-tools/issues" + }, + "scripts": { + "build:dev": "pnpm cleanup && pnpm env-json:schema:generate && pnpm copy:assets && run-script-if --bool \"$(build-env containerImages.build)\" --then \"pnpm image:docker:build\"", + "build:prod": "pnpm cleanup && pnpm env-json:schema:generate && pnpm copy:assets && run-script-if --bool \"$(build-env containerImages.build)\" --then \"pnpm image:docker:build\"", + "cleanup": "rimraf dist-dev && mkdir dist-dev", + "copy:assets": "pnpm copy:webapp-assets && pnpm copy:image-env-to-json", + "copy:image-env-to-json": "run-script-os", + "copy:image-env-to-json:linux:darwin": "cp ./node_modules/@kie-tools/image-env-to-json/dist/linux/image-env-to-json-standalone ./dist-dev/", + "copy:image-env-to-json:win32": "pnpm powershell \"Copy-Item ./node_modules/@kie-tools/image-env-to-json/dist/linux/image-env-to-json-standalone ./dist-dev/\"", + "copy:webapp-assets": "run-script-os", + "copy:webapp-assets:linux:darwin": "cp -R ./node_modules/@kie-tools/sonataflow-management-console-webapp/dist/ ./dist-dev/sonataflow-management-console-webapp", + "copy:webapp-assets:win32": "pnpm powershell \"Copy-Item -R ./node_modules/@kie-tools/sonataflow-management-console-webapp/dist/ ./dist-dev/sonataflow-management-console-webapp\"", + "env-json:schema:generate": "ts-json-schema-generator --tsconfig ./node_modules/@kie-tools/sonataflow-management-console-webapp/tsconfig.json --path ./node_modules/@kie-tools/sonataflow-management-console-webapp/src/env/EnvJson.ts --type EnvJson --id EnvJson --out ./dist-dev/EnvJson.schema.json", + "image:docker:build": "kie-tools--image-builder build -r \"$(build-env sonataflowManagementConsoleImage.registry)\" -a \"$(build-env sonataflowManagementConsoleImage.account)\" -n \"$(build-env sonataflowManagementConsoleImage.name)\" -t \"$(build-env sonataflowManagementConsoleImage.buildTag)\" --build-arg SONATAFLOW_MANAGEMENT_CONSOLE_PORT=\"$(build-env sonataflowManagementConsoleImage.port)\"" + }, + "devDependencies": { + "@kie-tools/image-builder": "workspace:*", + "@kie-tools/image-env-to-json": "workspace:*", + "@kie-tools/root-env": "workspace:*", + "@kie-tools/sonataflow-management-console-webapp": "workspace:*", + "rimraf": "^3.0.2", + "run-script-os": "^1.1.6", + "ts-json-schema-generator": "^1.1.2" + } +} diff --git a/packages/sonataflow-management-console-webapp/build/defaultEnvJson.js b/packages/sonataflow-management-console-webapp/build/defaultEnvJson.js deleted file mode 100644 index 4a5d2ce8f53..00000000000 --- a/packages/sonataflow-management-console-webapp/build/defaultEnvJson.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const { env: buildEnv } = require("../env"); - -const version = require("../package.json").version; - -module.exports = { - defaultEnvJson: { - // RUNTIME_TOOLS_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE: buildEnv.runtimeToolsManagementConsoleWebapp.kogitoEnvMode, - RUNTIME_TOOLS_MANAGEMENT_CONSOLE_KOGITO_APP_NAME: "Management Console", - RUNTIME_TOOLS_MANAGEMENT_CONSOLE_KOGITO_APP_VERSION: version, - KOGITO_CONSOLES_KEYCLOAK_DISABLE_HEALTH_CHECK: false, - KOGITO_CONSOLES_KEYCLOAK_UPDATE_TOKEN_VALIDITY: 30, - KOGITO_CONSOLES_KEYCLOAK_HEALTH_CHECK_URL: - "http://localhost:8280/auth/realms/kogito/.well-known/openid-configuration", - KOGITO_CONSOLES_KEYCLOAK_REALM: "kogito", - KOGITO_CONSOLES_KEYCLOAK_URL: "http://localhost:8280/auth", - KOGITO_CONSOLES_KEYCLOAK_CLIENT_ID: "kogito-console-react", - SONATAFLOW_DATA_INDEX_URL: buildEnv.sonataflowManagementConsoleWebapp.sonataflowDataIndexUrl, - SONATAFLOW_OPENAPIBASE_URL: buildEnv.sonataflowManagementConsoleWebapp.sonataflowOpenApiBaseUrl, - }, -}; diff --git a/packages/sonataflow-management-console-webapp/build/defaultEnvJson.ts b/packages/sonataflow-management-console-webapp/build/defaultEnvJson.ts new file mode 100644 index 00000000000..196200af362 --- /dev/null +++ b/packages/sonataflow-management-console-webapp/build/defaultEnvJson.ts @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { EnvJson } from "../src/env/EnvJson"; + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore +import { env } from "../env"; + +const buildEnv: any = env; // build-env is not typed + +const version = require("../package.json").version; + +export const defaultEnvJson: EnvJson = { + KOGITO_CONSOLES_KEYCLOAK_CLIENT_ID: "kogito-console-react", + KOGITO_CONSOLES_KEYCLOAK_DISABLE_HEALTH_CHECK: false, + KOGITO_CONSOLES_KEYCLOAK_HEALTH_CHECK_URL: + "http://localhost:8280/auth/realms/kogito/.well-known/openid-configuration", + KOGITO_CONSOLES_KEYCLOAK_REALM: "kogito", + KOGITO_CONSOLES_KEYCLOAK_UPDATE_TOKEN_VALIDITY: 30, + KOGITO_CONSOLES_KEYCLOAK_URL: "http://localhost:8280/auth", + SONATAFLOW_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT: buildEnv.sonataflowManagementConsoleWebapp.sonataflowDataIndexUrl, + SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_APP_NAME: "SonataFlow Management Console", + SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_APP_VERSION: version, + SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE: buildEnv.sonataflowManagementConsoleWebapp.sonataflowEnvMode, +}; diff --git a/packages/sonataflow-management-console-webapp/package.json b/packages/sonataflow-management-console-webapp/package.json index 4d17b5dbab1..f9504bd6014 100644 --- a/packages/sonataflow-management-console-webapp/package.json +++ b/packages/sonataflow-management-console-webapp/package.json @@ -107,6 +107,7 @@ "svg-url-loader": "^8.0.0", "ts-jest": "^29.1.5", "ts-loader": "^9.4.2", + "ts-node": "^10.9.1", "tsconfig-paths-webpack-plugin": "^3.5.2", "typescript": "^4.6.2", "url": "^0.11.3", diff --git a/packages/sonataflow-management-console-webapp/resources/serverless-workflow-combined-editor-envelope.html b/packages/sonataflow-management-console-webapp/resources/serverless-workflow-combined-editor-envelope.html index eab79b10728..46a3acae3f9 100644 --- a/packages/sonataflow-management-console-webapp/resources/serverless-workflow-combined-editor-envelope.html +++ b/packages/sonataflow-management-console-webapp/resources/serverless-workflow-combined-editor-envelope.html @@ -14,7 +14,7 @@ ~ limitations under the License. --> - + kie_icon_rgb_fullcolor_default \ No newline at end of file + + + + + kie_icon_rgb_fullcolor_default + + + + + + + + diff --git a/packages/sonataflow-management-console-webapp/tsconfig.json b/packages/sonataflow-management-console-webapp/tsconfig.json index 75257953093..252a34162b4 100644 --- a/packages/sonataflow-management-console-webapp/tsconfig.json +++ b/packages/sonataflow-management-console-webapp/tsconfig.json @@ -8,11 +8,18 @@ "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "target": "es6", - "allowJs": true, "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false }, "include": ["src"], - "preserveSymlinks": true + "preserveSymlinks": true, + + "ts-node": { + "esm": true, + "compilerOptions": { + "esModuleInterop": true, + "module": "CommonJS" + } + } } diff --git a/packages/sonataflow-management-console-webapp/webpack.config.js b/packages/sonataflow-management-console-webapp/webpack.config.js deleted file mode 100644 index d54c626e099..00000000000 --- a/packages/sonataflow-management-console-webapp/webpack.config.js +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const path = require("path"); -const { merge } = require("webpack-merge"); -const NodePolyfillPlugin = require("node-polyfill-webpack-plugin"); -const HtmlWebpackPlugin = require("html-webpack-plugin"); -const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin"); -const CopyPlugin = require("copy-webpack-plugin"); -const FileManagerPlugin = require("filemanager-webpack-plugin"); -const common = require("@kie-tools-core/webpack-base/webpack.common.config"); -const swEditorAssets = require("@kie-tools/serverless-workflow-diagram-editor-assets"); -const { env: buildEnv } = require("./env"); -const { defaultEnvJson } = require("./build/defaultEnvJson"); - -const BG_IMAGES_DIRNAME = "bgimages"; - -module.exports = async (env) => { - return merge(common(env), { - entry: { - index: path.resolve(__dirname, "src", "index.tsx"), - "serverless-workflow-combined-editor-envelope": "./src/envelope/ServerlessWorkflowCombinedEditorEnvelopeApp.ts", - "serverless-workflow-diagram-editor-envelope": "./src/envelope/ServerlessWorkflowDiagramEditorEnvelopeApp.ts", - "serverless-workflow-text-editor-envelope": "./src/envelope/ServerlessWorkflowTextEditorEnvelopeApp.ts", - }, - devServer: { - static: { - directory: "./dist", - }, - host: buildEnv.sonataflowManagementConsoleWebapp.host, - port: buildEnv.sonataflowManagementConsoleWebapp.port, - compress: true, - historyApiFallback: true, - hot: true, - client: { - overlay: { - warnings: false, - errors: true, - runtimeErrors: false, - }, - progress: true, - }, - proxy: { - "/svg": { - target: "http://localhost:4000", - secure: false, - changeOrigin: true, - }, - }, - }, - plugins: [ - new HtmlWebpackPlugin({ - template: "./src/index.html", - inject: false, - minify: false, - }), - new CopyPlugin({ - patterns: [ - { from: "./resources", to: "./resources" }, - { - from: "./resources/serverless-workflow-combined-editor-envelope.html", - to: "./serverless-workflow-combined-editor-envelope.html", - }, - { - from: "./resources/serverless-workflow-diagram-editor-envelope.html", - to: "./serverless-workflow-diagram-editor-envelope.html", - }, - { - from: "./resources/serverless-workflow-text-editor-envelope.html", - to: "./serverless-workflow-text-editor-envelope.html", - }, - { - from: path.join(path.dirname(require.resolve("@kie-tools/dashbuilder-client/package.json")), "/dist"), - to: "./monitoring-webapp", - }, - { - from: "./resources/monitoring-webapp", - to: "./monitoring-webapp", - }, - { - from: "./src/static/env.json", - to: "./env.json", - transform: () => JSON.stringify(defaultEnvJson, null, 2), - }, - { - from: swEditorAssets.swEditorPath(), - to: "./diagram", - globOptions: { ignore: ["**/WEB-INF/**/*", "**/*.html"] }, - }, - { - context: swEditorAssets.swEditorFontsPath(), - from: "fontawesome-webfont.*", - to: "./fonts", - force: true, - }, - ], - }), - new FileManagerPlugin({ - events: { - onEnd: { - mkdir: ["./dist/resources/webapp/"], - copy: [ - { source: "./dist/*.js", destination: "./dist/resources/webapp/" }, - { source: "./dist/*.map", destination: "./dist/resources/webapp/" }, - { source: "./dist/fonts", destination: "./dist/resources/webapp/fonts" }, - { - source: "./dist/monitoring-webapp", - destination: "./dist/resources/webapp/monitoring-webapp", - }, - ], - }, - }, - }), - new MonacoWebpackPlugin({ - languages: ["json"], - }), - new NodePolyfillPlugin(), - ], - module: { - rules: [ - { - test: /\.(css|sass|scss)$/, - use: [require.resolve("style-loader"), require.resolve("css-loader"), require.resolve("sass-loader")], - }, - { - test: /\.(svg|ttf|eot|woff|woff2)$/, - use: { - loader: require.resolve("file-loader"), - options: { - // Limit at 50k. larger files emited into separate files - limit: 5000, - outputPath: "fonts", - name: "[path][name].[ext]", - }, - }, - }, - { - test: /\.svg$/, - include: (input) => input.indexOf("background-filter.svg") > 1, - use: [ - { - loader: require.resolve("url-loader"), - options: { - limit: 5000, - outputPath: "svgs", - name: "[name].[ext]", - }, - }, - ], - }, - { - test: /\.svg$/, - include: (input) => input.indexOf(BG_IMAGES_DIRNAME) > -1, - use: { - loader: require.resolve("svg-url-loader"), - options: {}, - }, - }, - { - test: /\.(jpg|jpeg|png|gif)$/i, - use: [ - { - loader: require.resolve("url-loader"), - options: { - limit: 5000, - outputPath: "images", - name: "[name].[ext]", - }, - }, - ], - }, - ], - }, - resolve: { - fallback: { - https: require.resolve("https-browserify"), - http: require.resolve("stream-http"), - }, - }, - ignoreWarnings: [/Failed to parse source map/], - }); -}; diff --git a/packages/sonataflow-management-console-webapp/webpack.config.ts b/packages/sonataflow-management-console-webapp/webpack.config.ts new file mode 100644 index 00000000000..d0f297368c6 --- /dev/null +++ b/packages/sonataflow-management-console-webapp/webpack.config.ts @@ -0,0 +1,207 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import * as path from "path"; +import { merge } from "webpack-merge"; +import NodePolyfillPlugin from "node-polyfill-webpack-plugin"; +import HtmlWebpackPlugin from "html-webpack-plugin"; +import MonacoWebpackPlugin from "monaco-editor-webpack-plugin"; +import CopyPlugin from "copy-webpack-plugin"; +import FileManagerPlugin from "filemanager-webpack-plugin"; +import common from "@kie-tools-core/webpack-base/webpack.common.config"; +import * as swEditorAssets from "@kie-tools/serverless-workflow-diagram-editor-assets"; +import { defaultEnvJson } from "./build/defaultEnvJson"; + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore +import { env } from "./env"; + +const BG_IMAGES_DIRNAME = "bgimages"; +const buildEnv: any = env; // build-env is not typed + +export default async (env: any, argv: any) => { + return [ + { + ...merge(common(env), { + entry: { + index: path.resolve(__dirname, "src", "index.tsx"), + "serverless-workflow-combined-editor-envelope": + "./src/envelope/ServerlessWorkflowCombinedEditorEnvelopeApp.ts", + "serverless-workflow-diagram-editor-envelope": "./src/envelope/ServerlessWorkflowDiagramEditorEnvelopeApp.ts", + "serverless-workflow-text-editor-envelope": "./src/envelope/ServerlessWorkflowTextEditorEnvelopeApp.ts", + }, + plugins: [ + new HtmlWebpackPlugin({ + template: "./src/index.html", + inject: false, + minify: false, + }), + new CopyPlugin({ + patterns: [ + { from: "./resources", to: "./resources" }, + { + from: "./resources/serverless-workflow-combined-editor-envelope.html", + to: "./serverless-workflow-combined-editor-envelope.html", + }, + { + from: "./resources/serverless-workflow-diagram-editor-envelope.html", + to: "./serverless-workflow-diagram-editor-envelope.html", + }, + { + from: "./resources/serverless-workflow-text-editor-envelope.html", + to: "./serverless-workflow-text-editor-envelope.html", + }, + { + from: path.join(path.dirname(require.resolve("@kie-tools/dashbuilder-client/package.json")), "/dist"), + to: "./monitoring-webapp", + }, + { + from: "./resources/monitoring-webapp", + to: "./monitoring-webapp", + }, + { + from: "./src/static/env.json", + to: "./env.json", + transform: () => JSON.stringify(defaultEnvJson, null, 2), + }, + { + from: swEditorAssets.swEditorPath(), + to: "./diagram", + globOptions: { ignore: ["**/WEB-INF/**/*", "**/*.html"] }, + }, + { + context: swEditorAssets.swEditorFontsPath(), + from: "fontawesome-webfont.*", + to: "./fonts", + force: true, + }, + ], + }), + new FileManagerPlugin({ + events: { + onEnd: { + mkdir: ["./dist/resources/webapp/"], + copy: [ + { source: "./dist/*.js", destination: "./dist/resources/webapp/" }, + { source: "./dist/*.map", destination: "./dist/resources/webapp/" }, + { source: "./dist/fonts", destination: "./dist/resources/webapp/fonts" }, + { + source: "./dist/monitoring-webapp", + destination: "./dist/resources/webapp/monitoring-webapp", + }, + ], + }, + }, + }), + new MonacoWebpackPlugin({ + languages: ["json"], + }), + new NodePolyfillPlugin(), + ], + module: { + rules: [ + { + test: /\.(css|sass|scss)$/, + use: [require.resolve("style-loader"), require.resolve("css-loader"), require.resolve("sass-loader")], + }, + { + test: /\.(svg|ttf|eot|woff|woff2)$/, + use: { + loader: require.resolve("file-loader"), + options: { + // Limit at 50k. larger files emited into separate files + limit: 5000, + outputPath: "fonts", + name: "[path][name].[ext]", + }, + }, + }, + { + test: /\.svg$/, + include: (input) => input.indexOf("background-filter.svg") > 1, + use: [ + { + loader: require.resolve("url-loader"), + options: { + limit: 5000, + outputPath: "svgs", + name: "[name].[ext]", + }, + }, + ], + }, + { + test: /\.svg$/, + include: (input) => input.indexOf(BG_IMAGES_DIRNAME) > -1, + use: { + loader: require.resolve("svg-url-loader"), + options: {}, + }, + }, + { + test: /\.(jpg|jpeg|png|gif)$/i, + use: [ + { + loader: require.resolve("url-loader"), + options: { + limit: 5000, + outputPath: "images", + name: "[name].[ext]", + }, + }, + ], + }, + ], + }, + resolve: { + fallback: { + https: require.resolve("https-browserify"), + http: require.resolve("stream-http"), + }, + }, + ignoreWarnings: [/Failed to parse source map/], + }), + devServer: { + static: { + directory: "./dist", + }, + host: buildEnv.sonataflowManagementConsoleWebapp.host, + port: buildEnv.sonataflowManagementConsoleWebapp.port, + compress: true, + historyApiFallback: true, + hot: true, + client: { + overlay: { + warnings: false, + errors: true, + runtimeErrors: false, + }, + progress: true, + }, + proxy: { + "/svg": { + target: "http://localhost:4000", + secure: false, + changeOrigin: true, + }, + }, + }, + }, + ]; +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 649e873c57c..10aa8450820 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10766,6 +10766,9 @@ importers: ts-loader: specifier: ^9.4.2 version: 9.4.2(typescript@4.8.4)(webpack@5.88.2(@swc/core@1.3.92)(webpack-cli@4.10.0)) + ts-node: + specifier: ^10.9.1 + version: 10.9.1(@swc/core@1.3.92)(@types/node@20.14.2)(typescript@4.8.4) tsconfig-paths-webpack-plugin: specifier: ^3.5.2 version: 3.5.2 diff --git a/repo/graph.dot b/repo/graph.dot index d0f231f6ac8..01b055c536b 100644 --- a/repo/graph.dot +++ b/repo/graph.dot @@ -180,6 +180,7 @@ digraph G { "swf-vscode-extension" [ color = "blue", fontcolor = "blue", style = "rounded" ]; "@kie-tools/sonataflow-image-common" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie-tools/sonataflow-devmode-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; + "@kie-tools/sonataflow-management-console-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie-tools/sonataflow-management-console-webapp" [ color = "blue", fontcolor = "blue", style = "rounded" ]; "@kie-tools/stunner-editors-dmn-loader" [ color = "blue", fontcolor = "blue", style = "rounded" ]; "@kie-tools/unitables" [ color = "blue", fontcolor = "blue", style = "rounded" ]; @@ -552,6 +553,9 @@ digraph G { "@kie-tools/sonataflow-devmode-image" -> "@kie-tools/sonataflow-quarkus-devui" [ style = "dashed", color = "black" ]; "@kie-tools/sonataflow-image-common" -> "@kie-tools/python-venv" [ style = "dashed", color = "black" ]; "@kie-tools/sonataflow-image-common" -> "@kie-tools/root-env" [ style = "dashed", color = "black" ]; + "@kie-tools/sonataflow-management-console-image" -> "@kie-tools/image-builder" [ style = "dashed", color = "black" ]; + "@kie-tools/sonataflow-management-console-image" -> "@kie-tools/image-env-to-json" [ style = "dashed", color = "black" ]; + "@kie-tools/sonataflow-management-console-image" -> "@kie-tools/sonataflow-management-console-webapp" [ style = "dashed", color = "black" ]; "@kie-tools/sonataflow-management-console-webapp" -> "@kie-tools-core/react-hooks" [ style = "solid", color = "blue" ]; "@kie-tools/sonataflow-management-console-webapp" -> "@kie-tools/runtime-tools-process-webapp-components" [ style = "solid", color = "blue" ]; "@kie-tools/sonataflow-management-console-webapp" -> "@kie-tools/runtime-tools-shared-webapp-components" [ style = "solid", color = "blue" ]; diff --git a/repo/graph.json b/repo/graph.json index 94104712fbd..cd5607c5f6e 100644 --- a/repo/graph.json +++ b/repo/graph.json @@ -187,6 +187,7 @@ { "id": "@kie-tools/serverless-workflow-jq-expressions" }, { "id": "@kie-tools/serverless-workflow-service-catalog" }, { "id": "swf-vscode-extension" }, + { "id": "@kie-tools/sonataflow-management-console-image" }, { "id": "@kie-tools/sonataflow-management-console-webapp" }, { "id": "vscode-extension-dashbuilder-editor" }, { "id": "vscode-extension-kie-ba-bundle" }, @@ -2286,6 +2287,21 @@ "target": "@kie-tools/vscode-extension-common-test-helpers", "weight": 1 }, + { + "source": "@kie-tools/sonataflow-management-console-image", + "target": "@kie-tools/image-builder", + "weight": 1 + }, + { + "source": "@kie-tools/sonataflow-management-console-image", + "target": "@kie-tools/image-env-to-json", + "weight": 1 + }, + { + "source": "@kie-tools/sonataflow-management-console-image", + "target": "@kie-tools/sonataflow-management-console-webapp", + "weight": 1 + }, { "source": "@kie-tools/sonataflow-management-console-webapp", "target": "@kie-tools-core/react-hooks", @@ -2573,6 +2589,7 @@ ["sonataflow-deployment-webapp", "packages/sonataflow-deployment-webapp"], ["@kie-tools/sonataflow-devmode-image", "packages/sonataflow-devmode-image"], ["@kie-tools/sonataflow-image-common", "packages/sonataflow-image-common"], + ["@kie-tools/sonataflow-management-console-image", "packages/sonataflow-management-console-image"], ["@kie-tools/sonataflow-management-console-webapp", "packages/sonataflow-management-console-webapp"], ["@kie-tools/sonataflow-mock-server", "packages/sonataflow-mock-server"], ["@kie-tools/sonataflow-operator", "packages/sonataflow-operator"],