Skip to content

Commit

Permalink
Fix .gitignore conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo Zanini <[email protected]>
  • Loading branch information
ricardozanini committed Sep 23, 2024
2 parents 1a0e2d5 + 09ba5dd commit c5bb20d
Show file tree
Hide file tree
Showing 157 changed files with 8,736 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ packages/scesim-marshaller/**/ts-gen
!packages/sonataflow-builder-image/test-resources/
!packages/sonataflow-devmode-image/test-resources/

# kogito-images: excluding test-resources
!packages/kogito-data-index-ephemeral-image/test-resources/
!packages/kogito-data-index-postgresql-image/test-resources/
!packages/kogito-jobs-service-ephemeral-image/test-resources/
!packages/kogito-jobs-service-postgresql-image/test-resources/
!packages/kogito-jobs-service-allinone-image/test-resources/
!packages/kogito-jit-runner-image/test-resources/

__pycache__
packages/python-venv/venv

Expand Down
53 changes: 53 additions & 0 deletions packages/kogito-base-builder-image/env/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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({
KOGITO_BASE_BUILDER_IMAGE__registry: {
default: "docker.io",
description: "The image registry.",
},
KOGITO_BASE_BUILDER_IMAGE__account: {
default: "apache",
description: "The image registry account.",
},
KOGITO_BASE_BUILDER_IMAGE__name: {
default: "incubator-kie-kogito-base-builder",
description: "The image name.",
},
KOGITO_BASE_BUILDER_IMAGE__buildTag: {
default: rootEnv.env.root.streamName,
description: "The image tag.",
},
}),
get env() {
return {
kogitoBaseBuilderImage: {
registry: getOrDefault(this.vars.KOGITO_BASE_BUILDER_IMAGE__registry),
account: getOrDefault(this.vars.KOGITO_BASE_BUILDER_IMAGE__account),
name: getOrDefault(this.vars.KOGITO_BASE_BUILDER_IMAGE__name),
buildTag: getOrDefault(this.vars.KOGITO_BASE_BUILDER_IMAGE__buildTag),
},
};
},
});
64 changes: 64 additions & 0 deletions packages/kogito-base-builder-image/install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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 fs = require("fs");

const buildEnv = require("./env");
const path = require("path");
const pythonVenvDir = path.dirname(require.resolve("@kie-tools/python-venv/package.json"));
const sonataflowImageCommonDir = path.dirname(require.resolve("@kie-tools/sonataflow-image-common/package.json"));
const replaceInFile = require("replace-in-file");

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

execSync(
`${activateCmd} && \
python3 ${sonataflowImageCommonDir}/resources/scripts/versions_manager.py --bump-to ${buildEnv.env.kogitoBaseBuilderImage.buildTag} --source-folder ./resources`,
{ stdio: "inherit" }
);

// Find and read the -image.yaml file
const resourcesPath = path.resolve(__dirname, "./resources");
const files = fs.readdirSync(resourcesPath);
const imageYamlFiles = files.filter((fileName) => fileName.endsWith("-image.yaml"));
if (imageYamlFiles.length !== 1) {
throw new Error("There should only be one -image.yaml file on ./resources!");
}
const originalYamlPath = path.join(resourcesPath, imageYamlFiles[0]);
let imageYaml = fs.readFileSync(originalYamlPath, "utf8");

const imageUrl = `${buildEnv.env.kogitoBaseBuilderImage.registry}/${buildEnv.env.kogitoBaseBuilderImage.account}/${buildEnv.env.kogitoBaseBuilderImage.name}`;

// Replace the whole string between quotes ("") with the image name
imageYaml = imageYaml.replace(/(?<=")(.*kogito-base-builder.*)(?=")/gm, imageUrl);

// Write file and then rename it to match the image name
fs.writeFileSync(originalYamlPath, imageYaml);
fs.renameSync(originalYamlPath, path.join(resourcesPath, `${buildEnv.env.kogitoBaseBuilderImage.name}-image.yaml`));

// Replace image URL in .feature files
replaceInFile.sync({
files: ["**/*.feature"],
from: /@docker.io\/apache\/.*/g,
to: `@${imageUrl}`,
});
48 changes: 48 additions & 0 deletions packages/kogito-base-builder-image/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"private": true,
"name": "@kie/kogito-base-builder-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": "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/sonataflow-image-common/resources build && cp -R resources/* build",
"copy-test-assets": "run-script-os",
"copy-test-assets:linux:darwin": "cp -R test-resources/. build",
"format": "prettier --write . --ignore-path=../../.prettierignore --ignore-path=../../.gitignore",
"image:build": "run-script-os",
"image:build:darwin:linux": "pnpm setup:env make -C ./build build",
"image:build:win32": "echo \"Build skipped on Windows\"",
"image:test": "run-script-if --ignore-errors \"$(build-env tests.ignoreFailures)\" --bool \"$(build-env endToEndTests.run)\" --then \"mkdir -p build/target/test/results\" \"run-script-os\" --finally \"mkdir -p build/target/test/results && cp -r build/target/test/results dist-tests-e2e/\"",
"image:test:darwin:linux": "pnpm copy-test-assets && pnpm setup:env make -C ./build test-image",
"image:test:win32": "echo \"Tests skipped on Windows\"",
"install": "node install.js && pnpm format",
"setup:env": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && cross-env KOGITO_IMAGE_REGISTRY=$(build-env kogitoBaseBuilderImage.registry) KOGITO_IMAGE_REGISTRY_ACCOUNT=$(build-env kogitoBaseBuilderImage.account) KOGITO_IMAGE_NAME=$(build-env kogitoBaseBuilderImage.name) KOGITO_IMAGE_TAG=$(build-env kogitoBaseBuilderImage.buildTag) QUARKUS_PLATFORM_VERSION=$(build-env quarkusPlatform.version) KOGITO_VERSION=$(build-env kogitoRuntime.version)"
},
"devDependencies": {
"@kie-tools/python-venv": "workspace:*",
"@kie-tools/root-env": "workspace:*",
"@kie-tools/sonataflow-image-common": "workspace:*",
"cross-env": "^7.0.3",
"replace-in-file": "^7.1.0",
"rimraf": "^3.0.2",
"run-script-os": "^1.1.6"
},
"kieTools": {
"requiredPreinstalledCliCommands": [
"python3",
"make",
"s2i"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# 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: "docker.io/apache/incubator-kie-kogito-base-builder"
version: "main"
from: "registry.access.redhat.com/ubi8/openjdk-17:1.19"
description: "Image with JDK and Maven, used as a base image. It is used by Web Tools !"

labels:
- name: "io.openshift.s2i.scripts-url"
value: "image:///usr/local/s2i"
- name: "io.openshift.s2i.destination"
value: "/tmp"
- name: "io.openshift.expose-services"
value: "8080:http"
- 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: "Platform for building Kogito based on JDK and Maven"
- name: "io.k8s.display-name"
value: "Kogito based on JDK and Maven"
- name: "io.openshift.tags"
value: "base-builder,kogito"

packages:
manager: microdnf

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.security.custom.truststores

run:
workdir: "/home/kogito"
user: 1001
53 changes: 53 additions & 0 deletions packages/kogito-data-index-ephemeral-image/env/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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({
KOGITO_DATA_INDEX_EPHEMERAL_IMAGE__registry: {
default: "docker.io",
description: "The image registry.",
},
KOGITO_DATA_INDEX_EPHEMERAL_IMAGE__account: {
default: "apache",
description: "The image registry account.",
},
KOGITO_DATA_INDEX_EPHEMERAL_IMAGE__name: {
default: "incubator-kie-kogito-data-index-ephemeral",
description: "The image name.",
},
KOGITO_DATA_INDEX_EPHEMERAL_IMAGE__buildTag: {
default: rootEnv.env.root.streamName,
description: "The image tag.",
},
}),
get env() {
return {
kogitoDataIndexEphemeralImage: {
registry: getOrDefault(this.vars.KOGITO_DATA_INDEX_EPHEMERAL_IMAGE__registry),
account: getOrDefault(this.vars.KOGITO_DATA_INDEX_EPHEMERAL_IMAGE__account),
name: getOrDefault(this.vars.KOGITO_DATA_INDEX_EPHEMERAL_IMAGE__name),
buildTag: getOrDefault(this.vars.KOGITO_DATA_INDEX_EPHEMERAL_IMAGE__buildTag),
},
};
},
});
67 changes: 67 additions & 0 deletions packages/kogito-data-index-ephemeral-image/install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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 fs = require("fs");

const buildEnv = require("./env");
const path = require("path");
const pythonVenvDir = path.dirname(require.resolve("@kie-tools/python-venv/package.json"));
const sonataflowImageCommonDir = path.dirname(require.resolve("@kie-tools/sonataflow-image-common/package.json"));
const replaceInFile = require("replace-in-file");

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

execSync(
`${activateCmd} && \
python3 ${sonataflowImageCommonDir}/resources/scripts/versions_manager.py --bump-to ${buildEnv.env.kogitoDataIndexEphemeralImage.buildTag} --source-folder ./resources`,
{ stdio: "inherit" }
);

// Find and read the -image.yaml file
const resourcesPath = path.resolve(__dirname, "./resources");
const files = fs.readdirSync(resourcesPath);
const imageYamlFiles = files.filter((fileName) => fileName.endsWith("-image.yaml"));
if (imageYamlFiles.length !== 1) {
throw new Error("There should only be one -image.yaml file on ./resources!");
}
const originalYamlPath = path.join(resourcesPath, imageYamlFiles[0]);
let imageYaml = fs.readFileSync(originalYamlPath, "utf8");

const imageUrl = `${buildEnv.env.kogitoDataIndexEphemeralImage.registry}/${buildEnv.env.kogitoDataIndexEphemeralImage.account}/${buildEnv.env.kogitoDataIndexEphemeralImage.name}`;

// Replace the whole string between quotes ("") with the image name
imageYaml = imageYaml.replace(/(?<=")(.*kogito-data-index-ephemeral.*)(?=")/gm, imageUrl);

// Write file and then rename it to match the image name
fs.writeFileSync(originalYamlPath, imageYaml);
fs.renameSync(
originalYamlPath,
path.join(resourcesPath, `${buildEnv.env.kogitoDataIndexEphemeralImage.name}-image.yaml`)
);

// Replace image URL in .feature files
replaceInFile.sync({
files: ["**/*.feature"],
from: /@docker.io\/apache\/.*/g,
to: `@${imageUrl}`,
});
Loading

0 comments on commit c5bb20d

Please sign in to comment.