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#2571] [sonataflow-management-console] Convert Containerfiles to Cekit #2573

Merged
merged 4 commits into from
Sep 12, 2024
Merged
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
7 changes: 7 additions & 0 deletions packages/sonataflow-management-console-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"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\"",
"cekit:build": "pnpm cleanup && pnpm env-json:schema:generate && pnpm copy:assets && cekit:copy && pnpm cekit:setup:env && make -C ./dist-dev build",
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved
"cekit:copy": "run-script-os",
"cekit:copy:linux:darwin": "rimraf dist-dev && cp -R ./node_modules/@kie-tools/sonataflow-image-common/resources ./dist-dev/ && cp -R resources/* ./dist-dev/",
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved
"cekit:setup:env": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && cross-env SWF_IMAGE_REGISTRY=$(build-env sonataflowManagementConsoleImageEnv.registry) SWF_IMAGE_REGISTRY_ACCOUNT=$(build-env sonataflowManagementConsoleImageEnv.account) SWF_IMAGE_NAME=$(build-env sonataflowManagementConsoleImageEnv.name) SWF_IMAGE_TAG=$(build-env sonataflowManagementConsoleImageEnv.buildTag) QUARKUS_PLATFORM_VERSION=$(build-env quarkusPlatform.version) KOGITO_VERSION=$(build-env kogitoRuntime.version) SONATAFLOW_MANAGEMENT_CONSOLE_PORT=$(build-env sonataflowManagementConsoleImageEnv.port)",
"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",
Expand All @@ -29,9 +33,12 @@
"devDependencies": {
"@kie-tools/image-builder": "workspace:*",
"@kie-tools/image-env-to-json": "workspace:*",
"@kie-tools/python-venv": "workspace:*",
"@kie-tools/root-env": "workspace:*",
"@kie-tools/sonataflow-image-common": "workspace:*",
"@kie-tools/sonataflow-management-console-image-env": "workspace:*",
"@kie-tools/sonataflow-management-console-webapp": "workspace:*",
"cross-env": "^7.0.3",
"rimraf": "^3.0.2",
"run-script-os": "^1.1.6",
"ts-json-schema-generator": "^1.1.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#
# 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.
#
- name: "docker.io/apache/incubator-kie-sonataflow-devmode"
from: "registry.access.redhat.com/ubi9/httpd-24:1-336.1725850633"
version: "0.0.0"
description: "SonataFlow Management Console Image"

labels:
- name: "io.quarkus.platform.version"
value: "### SET ME DURING BUILD PROCESS ###"
- name: "org.kie.kogito.version"
value: "### SET ME DURING BUILD PROCESS ###"
- name: "maintainer"
value: "Apache KIE <dev@kie.apache.org>"
- name: "io.k8s.description"
value: "SonataFlow Management Console Image."
- name: "io.k8s.display-name"
value: "Sonataflow Management Console"
- name: "io.openshift.tags"
value: "sonataflow,serverless,workflow"
- name: "io.openshift.expose-services"
value: "$KOGITO_MANAGEMENT_CONSOLE_PORT:http"
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved

modules:
repositories:
- path: modules
install:
- name: org.kie.kogito.system.user
- name: org.kie.kogito.logging
- name: org.kie.kogito.project.versions
- name: org.kie.sonataflow.management.console

ports:
- value: $KOGITO_MANAGEMENT_CONSOLE_PORT
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved

run:
workdir: "/home/kogito/management-console"
user: 1001
cmd:
- "/home/kogito/management-console/launch/entrypoint.sh"
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/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.
#
set -e

# 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 "${KOGITO_HOME}/management-console/app/*" "${HTTPD_DATA_PATH}/html"

"${KOGITO_HOME}/management-console/image-env-to-json-standalone" --directory "${HTTPD_DATA_PATH}/html" --json-schema "${KOGITO_HOME}/management-console/EnvJson.schema.json"

httpd -D FOREGROUND
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/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.
#
set -e

SOURCES_DIR=/tmp/artifacts
SCRIPT_DIR=$(dirname "${0}")
MGMT_CONSOLE_HOME="${KOGITO_HOME}/management-console"

# Configure the default httpd conf
echo "Mutex posixsem" >> "${HTTPD_MAIN_CONF_PATH}/httpd.conf"
sed -i -e "/#ServerName www.example.com:80/aHeader set Content-Security-Policy \"frame-ancestors 'self';\"" "${HTTPD_MAIN_CONF_PATH}/httpd.conf"
sed -i -e 's/Options Indexes FollowSymLinks/Options -Indexes +FollowSymLinks/' "${HTTPD_MAIN_CONF_PATH}/httpd.conf"
sed -i "s/Listen 80/Listen ${KOGITO_MANAGEMENT_CONSOLE_PORT}/g" "${HTTPD_MAIN_CONF_PATH}/httpd.conf"
sed -i "s/#ServerName www.example.com:80/ServerName 127.0.0.1:${KOGITO_MANAGEMENT_CONSOLE_PORT}/g" "${HTTPD_MAIN_CONF_PATH}/httpd.conf"
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved
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 '${HTTPD_DATA_PATH}/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"

# Set the required paths
mkdir -p "${MGMT_CONSOLE_HOME}"

# Copy the entrypoint and other init scripts
cp -v "${SCRIPT_DIR}"/added/* "${MGMT_CONSOLE_HOME}"/launch

# Copy the application
cp -vr "${SOURCES_DIR}/management-console/"* "${MGMT_CONSOLE_HOME}/"

# Fixing permissions
chmod +x "${MGMT_CONSOLE_HOME}/launch/entrypoint.sh" "${MGMT_CONSOLE_HOME}/image-env-to-json-standalone"
chown -R "${KOGITO_USER}" "${MGMT_CONSOLE_HOME}"

if [ -f "${MGMT_CONSOLE_HOME}/app/env.json" ]; then chmod a+w "${MGMT_CONSOLE_HOME}/app/env.json"; fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# 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.
#
schema_version: 1
name: org.kie.sonataflow.management.console
version: "0.0.0"
description: "SonataFlow Management Console Launch Scripts and Configurations"

execute:
- script: configure-httpd.sh

artifacts:
- name: management-console-app
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved
path: ./dist-dev/sonataflow-management-console-webapp
target: management-console
Loading
Loading