Skip to content

Commit

Permalink
kie-issues#1001: Copy the kogito-swf-{devmode,builder} images from …
Browse files Browse the repository at this point in the history
…kogito-images to `kie-tools` (#2235)
  • Loading branch information
pefernan authored Apr 23, 2024
1 parent 5d4bfa5 commit 4d3c285
Show file tree
Hide file tree
Showing 88 changed files with 4,960 additions and 5 deletions.
18 changes: 18 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ runs:
with:
maven-version: 3.9.6

- uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Setup docker (macOS only)
if: runner.os == 'macOS'
shell: bash
Expand Down Expand Up @@ -134,6 +138,20 @@ runs:
pnpm -r exec 'bash' '-c' 'echo -ntp >> .mvn/maven.config'
pnpm -r exec 'bash' '-c' 'echo -Xmx2g > .mvn/jvm.config'
- name: "Install s2i pre-reqs (Ubuntu only)"
shell: bash
run: |
echo "STEP: Install libbtrfs-dev (Ubuntu only)"
cd ${{ inputs.working_dir }}
if [ "${{ runner.os }}" == "Linux" ]; then
sudo apt-get -y install libbtrfs-dev libgpgme-dev libdevmapper-dev > /dev/null 2>&1
fi
- name: "Setup s2i (source-to-image)"
shell: bash
run: |
go install github.com/openshift/source-to-image/cmd/[email protected]
- name: "Install Fluxbox (Ubuntu only)"
shell: bash
run: |
Expand Down
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,16 @@ packages/bpmn-marshaller/**/ts-gen
packages/dmn-marshaller/**/ts-gen
packages/scesim-marshaller/**/ts-gen

# kogito-sf-{builder|devmode}-image: excluding module build folders
!packages/kogito-swf-common/resources/**/build
!packages/kogito-swf-builder/resources/**/build
!packages/kogito-swf-devmode/resources/**/build
!packages/kogito-swf-common/test-resources/
!packages/kogito-swf-builder/test-resources/
!packages/kogito-swf-devmode/test-resources/

__pycache__
packages/python-venv/venv

# devbox
.devbox
.devbox
67 changes: 67 additions & 0 deletions packages/kogito-swf-builder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# kogito-swf-builder

This package contains the `cekit` image descriptor (`kogito-swf-builder-image.yaml`) and modules needed to build the `kogito-swf-builder`
image along with the modules and scripts provided in `@kie-tools/kogito-swf-common`.

## Additional requirements

- **python3** with the following packages installed:
- `behave` `lxml` `docker` `docker-squash` `elementPath` `pyyaml` `ruamel.yaml` `python-dateutil` `Jinja2` `pykwalify` `colorlog` `click`
- **cekit 4.11.0**: [docs.cekit.io](https://docs.cekit.io/en/latest/index.html)
- **s2i**: [source-to-image](https://github.com/openshift/source-to-image)
- **make**
- **docker** or **podman**

## 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_SWF_BUILDER_IMAGE__registry=<registry>
export KOGITO_SWF_BUILDER_IMAGE__account=<account>
export KOGITO_SWF_BUILDER_IMAGE__name=<image-name>
export KOGITO_SWF_BUILDER_IMAGE__buildTag=<image-tag>
```

> 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/kogito-swf-builder build:prod
```

- Then check if the image is correctly stored:

```bash
docker images
```

or

```bash
podman images
```

## Testing the generated image (only for Linux)

- With the image generated, run:

```bash
pnpm -F @kie-tools/kogito-swf-builder image:test
```

## Envs

| Name | Description | Default |
| :----------------------------------: | :------------------------------------------------: | :------------------: |
| `KOGITO_SWF_BUILDER_IMAGE__registry` | Registry where the generated image will be pushed. | "quay.io" |
| `KOGITO_SWF_BUILDER_IMAGE__account` | Account where image will be stored. | "kiegroup" |
| `KOGITO_SWF_BUILDER_IMAGE__name` | SWF Builder Image name. | "kogito-swf-builder" |
| `KOGITO_SWF_BUILDER_IMAGE__buildTag` | Tag to use . | "latest" |
52 changes: 52 additions & 0 deletions packages/kogito-swf-builder/env/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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");

module.exports = composeEnv([require("@kie-tools/root-env/env")], {
vars: varsWithName({
KOGITO_SWF_BUILDER_IMAGE__registry: {
default: "quay.io",
description: "The image registry.",
},
KOGITO_SWF_BUILDER_IMAGE__account: {
default: "kiegroup",
description: "The image registry account.",
},
KOGITO_SWF_BUILDER_IMAGE__name: {
default: "kogito-swf-builder",
description: "The image name.",
},
KOGITO_SWF_BUILDER_IMAGE__buildTag: {
default: "latest",
description: "The image tag.",
},
}),
get env() {
return {
kogitoSwfBuilder: {
registry: getOrDefault(this.vars.KOGITO_SWF_BUILDER_IMAGE__registry),
account: getOrDefault(this.vars.KOGITO_SWF_BUILDER_IMAGE__account),
name: getOrDefault(this.vars.KOGITO_SWF_BUILDER_IMAGE__name),
tag: getOrDefault(this.vars.KOGITO_SWF_BUILDER_IMAGE__buildTag),
version: require("../package.json").version,
},
};
},
});
36 changes: 36 additions & 0 deletions packages/kogito-swf-builder/install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 { execSync } = require("child_process");

const buildEnv = require("./env");
const path = require("path");
const pythonVenvDir = path.dirname(require.resolve("@kie-tools/python-venv/package.json"));
const kogitoSwfCommonDir = path.dirname(require.resolve("@kie-tools/kogito-swf-common/package.json"));

const activateCmd =
process.platform === "win32"
? `${pythonVenvDir}\\venv\\Scripts\\Activate.bat`
: `. ${pythonVenvDir}/venv/bin/activate`;

execSync(
`${activateCmd} && \
python ${kogitoSwfCommonDir}/resources/scripts/versions_manager.py --bump-to ${buildEnv.env.kogitoSwfBuilder.version} --source-folder ./resources`,
{ stdio: "inherit" }
);
46 changes: 46 additions & 0 deletions packages/kogito-swf-builder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"private": true,
"name": "@kie-tools/kogito-swf-builder",
"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": "run-script-if --bool \"$(build-env containerImages.build)\" --then \"pnpm copy-assets\" \"pnpm image:build\"",
"build:prod": "pnpm build:dev && pnpm image:test",
"copy-assets": "run-script-os",
"copy-assets:linux:darwin": "rimraf build && cp -R ./node_modules/@kie-tools/kogito-swf-common/resources build && cp -R resources/* build",
"copy-test-assets": "run-script-os",
"copy-test-assets:linux:darwin": "cp -R ./node_modules/@kie-tools/kogito-swf-common/test-resources/* build && cp -R test-resources/* build",
"image:build": "run-script-os",
"image:build:darwin:win32": "echo \"Build skipped on macOS and Windows\"",
"image:build:linux": "pnpm setup:env make -C ./build build",
"image:test": "run-script-if --ignore-errors \"$(build-env tests.ignoreFailures)\" --bool \"$(build-env tests.run)\" --then \"run-script-os\"",
"image:test:darwin:win32": "echo \"Tests skipped on macOS and Windows\"",
"image:test:linux": "pnpm copy-test-assets && pnpm setup:env make -C ./build test-image",
"install": "node install.js",
"setup:env": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && cross-env SWF_IMAGE_REGISTRY=$(build-env kogitoSwfBuilder.registry) SWF_IMAGE_REGISTRY_ACCOUNT=$(build-env kogitoSwfBuilder.account) SWF_IMAGE_NAME=$(build-env kogitoSwfBuilder.name) SWF_IMAGE_TAG=$(build-env kogitoSwfBuilder.tag) QUARKUS_PLATFORM_VERSION=$(build-env quarkusPlatform.version) KOGITO_VERSION=$(build-env kogitoRuntime.version)"
},
"devDependencies": {
"@kie-tools/kogito-swf-common": "workspace:*",
"@kie-tools/python-venv": "workspace:*",
"@kie-tools/root-env": "workspace:*",
"cross-env": "^7.0.3",
"rimraf": "^3.0.2",
"run-script-os": "^1.1.6"
},
"kieTools": {
"requiredPreinstalledCliCommands": [
"python",
"make",
"s2i"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#
# 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: builder
from: "registry.access.redhat.com/ubi8/openjdk-17:1.19"
version: "0.0.0"
modules:
repositories:
- path: modules
install:
- name: org.kie.kogito.system.user
- name: org.kie.kogito.logging
- name: org.kie.kogito.launch.scripts
- name: org.kie.kogito.dynamic.resources
- name: org.kie.kogito.maven.common
- name: org.kie.kogito.project.versions
- name: org.kie.kogito.swf.common.scripts
- name: org.kie.kogito.swf.builder.build-config
- name: org.kie.kogito.swf.common.build

- name: "quay.io/kiegroup/kogito-swf-builder"
from: "registry.access.redhat.com/ubi8/openjdk-17:1.19"
version: "0.0.0"
description: "Kogito Serverless Workflow base builder with Quarkus extensions libraries preinstalled"

labels:
- name: "io.openshift.s2i.scripts-url"
value: "image:///usr/local/s2i"
- name: "io.openshift.s2i.destination"
value: "/tmp"
- 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 <[email protected]>"
- name: "io.k8s.description"
value: "Kogito Serverless Workflow base builder with Quarkus extensions libraries preinstalled."
- name: "io.k8s.display-name"
value: "Kogito SWF Builder"
- name: "io.openshift.tags"
value: "kogito,builder,serverless,workflow"

modules:
repositories:
- path: modules
install:
- name: org.kie.kogito.system.user
- name: org.kie.kogito.logging
- name: org.kie.kogito.launch.scripts
- name: org.kie.kogito.dynamic.resources
- name: org.kie.kogito.maven.common
- name: org.kie.kogito.project.versions
- name: org.kie.kogito.swf.common.scripts
- name: org.kie.kogito.swf.builder.runtime.community

run:
workdir: "/home/kogito/${PROJECT_ARTIFACT_ID}"
user: 1001
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# 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.swf.builder.build-config
version: "0.0.0"
description: "Kogito Serverless Workflow builder image build configuration"

envs:
- name: "SCRIPT_DEBUG"
value: "false"
- name: QUARKUS_EXTENSIONS
# Follow up issue to remove KOGITO_VERSION: https://issues.redhat.com/browse/KOGITO-9270
value: quarkus-kubernetes,smallrye-health,org.apache.kie.sonataflow:sonataflow-quarkus:${KOGITO_VERSION},org.kie:kie-addons-quarkus-knative-eventing:${KOGITO_VERSION},org.kie:kogito-addons-quarkus-microprofile-config-service-catalog:${KOGITO_VERSION},org.kie:kie-addons-quarkus-kubernetes:${KOGITO_VERSION},org.kie:kie-addons-quarkus-events-process:${KOGITO_VERSION},org.kie:kie-addons-quarkus-process-management:${KOGITO_VERSION},org.kie:kie-addons-quarkus-source-files:${KOGITO_VERSION},org.kie:kogito-addons-quarkus-knative-serving:${KOGITO_VERSION},org.kie:kogito-addons-quarkus-jobs-knative-eventing:${KOGITO_VERSION}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env 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

mkdir -p "${KOGITO_HOME}"/.m2/repository
mkdir -p "${KOGITO_HOME}/${PROJECT_ARTIFACT_ID}"

# Unzip Quarkus app and Maven repository
tar xf "${SOURCES_DIR}"/kogito-swf-quarkus-app.tar -C "${KOGITO_HOME}/${PROJECT_ARTIFACT_ID}"
tar xf "${SOURCES_DIR}"/kogito-swf-maven-repo.tar -C "${KOGITO_HOME}"/.m2/repository

chown -R 1001:0 "${KOGITO_HOME}"
chmod -R ug+rwX "${KOGITO_HOME}"
Loading

0 comments on commit 4d3c285

Please sign in to comment.