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

[9.101.x-prod][SRVLOGIC-384] - Productize OpenShift Serverless Logic Management Console Image #45

Merged
merged 8 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions packages/osl-management-console-image/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!generated
target
generated/tests
generated/scripts
generated/Makefile
generated/**/tests/
37 changes: 37 additions & 0 deletions packages/osl-management-console-image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# OpenShift Serverless Logic Management Console Image

Package based on [`sonataflow-management-console-image`](../sonataflow-management-console-image).
This image is based on its version upstream, adding a thin layer to pull the base Management Console WebApp from a given repository.
Internally, the package will run a few preparation scritps to:

1. Pull the webapp in zip formant from a given URL. This app must be based on the [`sonataflow-management-console-webapp`](../sonataflow-management-console-webapp).
2. Save the artifact in zip format to the local Cekit Cache.
3. Update the [`generated/modules`](generated/modules) directory with MD5 and artifact name.
4. Save everything needed to build this image with Cekit in the [`generated`](generated) directory. This directory must be commited to the git branch since it will be used by internal tools to build the final image.
5. Finally build the image locally, so users can verify and run tests if necessary.

## Usage

Export the following variables before running it:

```shell
export KIE_TOOLS_BUILD__buildContainerImages=true
# The SonataFlow Management Console WebApp artifact in zip format
export OSL_MANAGEMENT_CONSOLE_IMAGE__artifactUrl=<artifact URL>
# Image name/tag information. This information is optional, you can see the package sonataflow-management-console-image-env for the default values.
export SONATAFLOW_MANAGEMENT_CONSOLE__registry=registry.access.redhat.com
export SONATAFLOW_MANAGEMENT_CONSOLE__account=openshift-serverless-1
export SONATAFLOW_MANAGEMENT_CONSOLE__name=logic-management-console-rhel8
export SONATAFLOW_MANAGEMENT_CONSOLE__buildTag=1.34

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rgdoliveira @ricardozanini double checking if this shouldn't be 1.34.*0*

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domhanak This is just an example. Cekit will override the tag in runtime.

# Quarkus/Kogito version. This information will be set in the image labels and internal builds.
# Optionally you can also use Cekit overrides when building the final image in the internal systems.
export QUARKUS_PLATFORM_version=3.8.6
export KOGITO_RUNTIME_version=9.101-redhat

pnpm build:dev # build:prod also works, does the same currently.
```

Then you can export the directory `generated` to any system to build the image via Cekit.

> [!IMPORTANT]
> Do not modify any file in the `generated` directory. Always use the `pnpm build:dev` to generate this package.
39 changes: 39 additions & 0 deletions packages/osl-management-console-image/env/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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, require("@kie-tools/sonataflow-management-console-image-env/env")], {
vars: varsWithName({
OSL_MANAGEMENT_CONSOLE_IMAGE__artifactUrl: {
default: "",
description: "The internal repository where to find the Management Console app zip file.",
},
}),
get env() {
return {
oslManagementConsoleImage: {
artifactUrl: getOrDefault(this.vars.OSL_MANAGEMENT_CONSOLE_IMAGE__artifactUrl),
version: require("../package.json").version,
},
};
},
});
42 changes: 42 additions & 0 deletions packages/osl-management-console-image/generated/content_sets.yaml
Original file line number Diff line number Diff line change
@@ -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.
#
# This is a file defining which content sets (yum repositories) are needed to
# update content in this image. Data provided here helps determine which images
# are vulnerable to specific CVEs. Generally you should only need to update this
# file when:
# 1. You start depending on a new product
# 2. You are preparing new product release and your content sets will change
#
# See https://mojo.redhat.com/docs/DOC-1023066 for more information on
# maintaining this file and the format and examples
#
# You should have one top level item for each architecture being built. Most
# likely this will be x86_64 and ppc64le initially.
---
x86_64:
- rhel-8-for-x86_64-baseos-rpms
- rhel-8-for-x86_64-appstream-rpms
- rhocp-4.7-for-rhel-8-x86_64-rpms
ppc64le:
- rhel-8-for-ppc64le-baseos-rpms
- rhel-8-for-ppc64le-appstream-rpms
- rhocp-4.7-for-rhel-8-ppc64le-rpms
aarch64:
- rhel-8-for-aarch64-baseos-rpms
- rhel-8-for-aarch64-appstream-rpms
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#
# 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: "openshift-serverless-1/logic-management-console-rhel8"
from: "registry.access.redhat.com/ubi8/httpd-24:latest"
version: "1.34.0"
description: "OpenShift Serverless Logic Management Console Image"

labels:
- name: "io.quarkus.platform.version"
value: "3.8.6"
- name: "org.kie.kogito.version"
value: "999-20240905-SNAPSHOT"
- name: "maintainer"
value: "Red Hat <[email protected]>"
- name: "io.k8s.description"
value: "OpenShift Serverless Logic Management Console Image."
- name: "io.k8s.display-name"
value: "OpenShift Serverless Logic Management Console"
- name: "io.openshift.tags"
value: "sonataflow,serverless,workflow,osl,serverless-logic"
- name: "io.openshift.expose-services"
value: "8080:http"
- name: "com.redhat.component"
value: "openshift-serverless-1-logic-management-console-rhel8-container"

modules:
repositories:
- path: modules
install:
- name: org.kie.kogito.system.user
- name: org.kie.kogito.project.versions
- name: com.redhat.osl.management.console

ports:
- value: 8080

envs:
- name: SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE
value: PROD
- name: SUMMARY
value: "OpenShift Serverless Logic Management Console"

run:
workdir: "/home/kogito/management-console"
user: 1001
cmd:
- "/home/kogito/management-console/launch/entrypoint.sh"

packages:
content_sets_file: content_sets.yaml

osbs:
configuration:
container:
platforms:
only:
- x86_64
compose:
pulp_repos: true
extra_dir: osbs-extra/logic-management-console-rhel8
repository:
name: containers/openshift-serverless-1-logic-management-console
branch: openshift-serverless-1.34-rhel-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# 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.kogito.project.versions
version: "0.0.0"
description: "Kogito Project versions information"

envs:
- name: "KOGITO_VERSION"
value: "999-20240905-SNAPSHOT"
description: Defines the Kogito version to be used by the builder images. Not intended to be changed by end user.
- name: "QUARKUS_PLATFORM_VERSION"
value: "3.8.6"
description: Defines the Quarkus Platform version to be used by the builder images. Not intended to be changed by end user.
- name: "SONATAFLOW_QUARKUS_DEVUI_VERSION"
value: "### SET ME DURING BUILD PROCESS ###"
description: Defines the SonataFlow Quarkus Dev UI version to be used by the devmode image. Not intended to be changed by end user.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
#
# 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.
#

# Check if group 1001 exists, if not, create it
if ! getent group kogito >/dev/null; then
groupadd -r kogito -g ${USER_ID}
fi

# Check if user 1001 exists, if not, reuse it for kogito
if ! id "${USER_ID}" >/dev/null 2>&1; then
useradd -u "${USER_ID}" -r -g kogito -G root -m -d "${KOGITO_HOME}" -s /sbin/nologin -c "Kogito user" ${USER}
else
echo "User with UID ${USER_ID} already exists, reusing it."
# Change home directory and group for the existing user
usermod -d "${KOGITO_HOME}" -g kogito ${USER}
fi

mkdir -p "${KOGITO_HOME}"/bin
chmod ug+rwX "${KOGITO_HOME}"

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# 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.kogito.system.user
version: "0.0.0"

execute:
- script: add-user

envs:
- name: "KOGITO_HOME"
value: "/home/kogito"
# Force override here since some images depends on OpenJDK, which sets home to /home/jboss. Might be worth removing the kogito user and keep jboss instead. TODO: open an issue to track it and link to Kogito Operator deprecation.
- name: "HOME"
value: "/home/kogito"
- name: "USER"
value: "kogito"
- name: "USER_ID"
value: 1001
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$id": "EnvJson",
"$ref": "#/definitions/EnvJson",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"EnvJson": {
"additionalProperties": false,
"properties": {
"KOGITO_CONSOLES_KEYCLOAK_CLIENT_ID": {
"type": "string"
},
"KOGITO_CONSOLES_KEYCLOAK_DISABLE_HEALTH_CHECK": {
"type": "boolean"
},
"KOGITO_CONSOLES_KEYCLOAK_HEALTH_CHECK_URL": {
"type": "string"
},
"KOGITO_CONSOLES_KEYCLOAK_REALM": {
"type": "string"
},
"KOGITO_CONSOLES_KEYCLOAK_UPDATE_TOKEN_VALIDITY": {
"type": "number"
},
"KOGITO_CONSOLES_KEYCLOAK_URL": {
"type": "string"
},
"SONATAFLOW_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT": {
"type": "string"
},
"SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_APP_NAME": {
"type": "string"
},
"SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_APP_VERSION": {
"type": "string"
},
"SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE": {
"enum": ["DEV", "PROD"],
"type": "string"
}
},
"required": [
"SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_ENV_MODE",
"SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_APP_NAME",
"SONATAFLOW_MANAGEMENT_CONSOLE_KOGITO_APP_VERSION",
"SONATAFLOW_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT"
],
"type": "object"
}
}
}
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"

run-httpd
Binary file not shown.
Loading
Loading