Skip to content
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

kie-tools#2695: [SonataFlow Management Console Image] Use mod_proxy to proxy request to the data-index #2750

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/sonataflow-management-console-image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ 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.

## Run the Docker Image Locally

1. This command will start the container and configure it to access your local data-index service from the container.
Replace `<HOST_IP_ADDRESS>` with the IP address of your host machine.

```bash
docker run --rm -it -p 8080:8080 \
-e SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE='DEV' \
-e SONATAFLOW_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT='http://<HOST_IP_ADDRESS>:4000/graphql' \
docker.io/apache/incubator-kie-sonataflow-management-console:main
```

2. In a separate terminal, start Sonataflow Dev App for the Data Index service.

```bash
cd ../sonataflow-dev-app
pnpm start
```

---

Apache KIE (incubating) is an effort undergoing incubation at The Apache Software
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,22 @@ sed -i "s/Listen 80/Listen ${SONATAFLOW_MANAGEMENT_CONSOLE_PORT}/g" "${HTTPD_MAI
sed -i "s/#ServerName www.example.com:80/ServerName 127.0.0.1:${SONATAFLOW_MANAGEMENT_CONSOLE_PORT}/g" "${HTTPD_MAIN_CONF_PATH}/httpd.conf"
sed -i '$ a ServerTokens Prod' "${HTTPD_MAIN_CONF_PATH}/httpd.conf"
sed -i '$ a ServerSignature Off' "${HTTPD_MAIN_CONF_PATH}/httpd.conf"
sed -i -e '/<Directory "\/var\/www\/html">/a RewriteEngine on\n RewriteCond %{REQUEST_FILENAME} -f [OR]\n RewriteCond %{REQUEST_FILENAME} -d\n RewriteRule ^ - [L]\n RewriteRule ^ index.html [L]' "${HTTPD_MAIN_CONF_PATH}/httpd.conf"

# Add RewriteRules
sed -i -e '/<Directory "\/var\/www\/html">/a \
RewriteEngine on \
# Data Index rewrite rules \
RewriteCond %{REQUEST_URI} ^\/graphql([\/\?$]|$) \
RewriteCond %{ENV:SONATAFLOW_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT} ^$ \
RewriteRule ^.*$ - [R=503,L] \
RewriteCond %{REQUEST_URI} ^\/graphql([\/\?$]|$) \
RewriteCond %{ENV:SONATAFLOW_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT} ^(.*)$ \
RewriteRule ^.*$ %1 [P,L]\n \
RewriteCond %{REQUEST_FILENAME} -f [OR] \
RewriteCond %{REQUEST_FILENAME} -d \
RewriteRule ^ - [L] \
RewriteRule ^ index.html [L]\n' \
"${HTTPD_MAIN_CONF_PATH}/httpd.conf"

# Set the required paths
mkdir -p "${MGMT_CONSOLE_HOME}/launch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const defaultEnvJson: EnvJson = {
KOGITO_CONSOLES_KEYCLOAK_REALM: "kogito",
KOGITO_CONSOLES_KEYCLOAK_UPDATE_TOKEN_VALIDITY: 30,
KOGITO_CONSOLES_KEYCLOAK_URL: "http://localhost:8280",
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,
Expand Down
5 changes: 0 additions & 5 deletions packages/sonataflow-management-console-webapp/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ const { varsWithName, composeEnv, getOrDefault } = require("@kie-tools-scripts/b

module.exports = composeEnv([require("@kie-tools/root-env/env")], {
vars: varsWithName({
SONATAFLOW_MANAGEMENT_CONSOLE_WEBAPP__sonataflowDataIndexUrl: {
default: "http://localhost:4000/graphql",
description: "URL for the Data Index service",
},
SONATAFLOW_MANAGEMENT_CONSOLE_WEBAPP__sonataflowEnvMode: {
default: "DEV",
description: "DEV or PROD. PROD enables Keycloak integration",
Expand All @@ -41,7 +37,6 @@ module.exports = composeEnv([require("@kie-tools/root-env/env")], {
get env() {
return {
sonataflowManagementConsoleWebapp: {
sonataflowDataIndexUrl: getOrDefault(this.vars.SONATAFLOW_MANAGEMENT_CONSOLE_WEBAPP__sonataflowDataIndexUrl),
sonataflowEnvMode: getOrDefault(this.vars.SONATAFLOW_MANAGEMENT_CONSOLE_WEBAPP__sonataflowEnvMode),
host: getOrDefault(this.vars.SONATAFLOW_MANAGEMENT_CONSOLE_WEBAPP__host),
port: getOrDefault(this.vars.SONATAFLOW_MANAGEMENT_CONSOLE_WEBAPP__port),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* 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.
*/
export const DATA_INDEX_ENDPOINT = "/graphql";
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ export interface EnvJson extends KogitoConsolesKeycloakEnv {
SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE: "DEV" | "PROD";
SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_APP_NAME: string;
SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_APP_VERSION: string;
SONATAFLOW_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT: string;
}
3 changes: 3 additions & 0 deletions packages/sonataflow-management-console-webapp/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ import {
import { initEnv } from "./env/Env";
import { ENV_PREFIX } from "./env/EnvConstants";
import { EnvJson } from "./env/EnvJson";
import { DATA_INDEX_ENDPOINT } from "./AppConstants";

window["DATA_INDEX_ENDPOINT"] = DATA_INDEX_ENDPOINT;

const onLoadFailure = (): void => {
ReactDOM.render(<KeycloakUnavailablePage />, document.getElementById("root"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,14 @@ export default async (webpackEnv: any, webpackArgv: any) => {
},
progress: true,
},
proxy: {
"/svg": {
proxy: [
{
context: (path, req) => req.method === "POST" || path.startsWith("/graphql") || path === "/q/openapi.json",
target: "http://localhost:4000",
secure: false,
changeOrigin: true,
},
},
],
},
},
];
Expand Down
Loading