diff --git a/devbox.lock b/devbox.lock index 810e96da462..df86104abb0 100644 --- a/devbox.lock +++ b/devbox.lock @@ -304,7 +304,7 @@ }, "python@3.12.2": { "last_modified": "2024-03-22T11:26:23Z", - "plugin_version": "0.0.3", + "plugin_version": "0.0.4", "resolved": "github:NixOS/nixpkgs/a3ed7406349a9335cb4c2a71369b697cecd9d351#python312", "source": "devbox-search", "version": "3.12.2", diff --git a/packages/sonataflow-builder-image/env/index.js b/packages/sonataflow-builder-image/env/index.js index 4c6bfb01333..6295a12bb6a 100644 --- a/packages/sonataflow-builder-image/env/index.js +++ b/packages/sonataflow-builder-image/env/index.js @@ -19,6 +19,10 @@ const { varsWithName, composeEnv, getOrDefault } = require("@kie-tools-scripts/build-env"); +const { + env: { mavenM2RepoViaHttpImage: mavenM2RepoViaHttpImageEnv }, +} = require("@kie-tools/maven-m2-repo-via-http-image/env"); + const rootEnv = require("@kie-tools/root-env/env"); module.exports = composeEnv([rootEnv], { @@ -39,6 +43,10 @@ module.exports = composeEnv([rootEnv], { default: rootEnv.env.root.streamName, description: "The image tag.", }, + SONATAFLOW_BUILDER_IMAGE__mavenM2RepoViaHttpImage: { + default: `${mavenM2RepoViaHttpImageEnv.registry}/${mavenM2RepoViaHttpImageEnv.account}/${mavenM2RepoViaHttpImageEnv.name}:${mavenM2RepoViaHttpImageEnv.tag}`, + description: "The image tag for the Maven M2 Repo via HTTP. Used during the build only.", + }, }), get env() { return { @@ -48,6 +56,9 @@ module.exports = composeEnv([rootEnv], { name: getOrDefault(this.vars.SONATAFLOW_BUILDER_IMAGE__name), tag: getOrDefault(this.vars.SONATAFLOW_BUILDER_IMAGE__buildTag), version: require("../package.json").version, + dev: { + mavenM2RepoViaHttpImage: getOrDefault(this.vars.SONATAFLOW_BUILDER_IMAGE__mavenM2RepoViaHttpImage), + }, }, }; }, diff --git a/packages/sonataflow-builder-image/package.json b/packages/sonataflow-builder-image/package.json index 4b3de651bef..f79a6efd7e9 100644 --- a/packages/sonataflow-builder-image/package.json +++ b/packages/sonataflow-builder-image/package.json @@ -13,10 +13,14 @@ "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", + "build": "run-script-if --bool \"$(build-env containerImages.build)\" --then \"pnpm m2-repo-via-http:container:run\" \"pnpm copy-assets\" \"pnpm image:build\" --finally \"pnpm m2-repo-via-http:container:kill\"", + "build:dev": "pnpm build", + "build:prod": "pnpm build && pnpm image:test", + "copy:maven-m2-repo-via-http-image--settings-xml": "run-script-os", + "copy:maven-m2-repo-via-http-image--settings-xml:linux:darwin": "M2_REPO_VIA_HTTP_URL_WITHOUT_PROTOCOL=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' m2-repo-via-http) envsubst < build/modules/kogito-maven/common/maven/maven-m2-repo-via-http-settings.xml.envsubst > build/modules/kogito-maven/common/maven/maven-m2-repo-via-http-settings.xml && rm build/modules/kogito-maven/common/maven/maven-m2-repo-via-http-settings.xml.envsubst", + "copy:maven-m2-repo-via-http-image--settings-xml:win32": "echo \"Build skipped on macOS and Windows\"", "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-assets:linux:darwin": "rimraf build && cp -R ./node_modules/@kie-tools/sonataflow-image-common/resources build && cp -R resources/* build && pnpm copy:maven-m2-repo-via-http-image--settings-xml", "copy-test-assets": "run-script-os", "copy-test-assets:linux:darwin": "cp -R ./node_modules/@kie-tools/sonataflow-image-common/test-resources/* build && cp -R test-resources/* build", "format": "prettier --write . --ignore-path=../../.prettierignore --ignore-path=../../.gitignore", @@ -27,9 +31,13 @@ "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 && pnpm format", + "m2-repo-via-http:container:kill": "(docker container kill m2-repo-via-http || true) && (docker container rm m2-repo-via-http || true)", + "m2-repo-via-http:container:run": "(pnpm m2-repo-via-http:container:kill || true) && docker run --name m2-repo-via-http -v \"$(mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout):/var/www/html\" -dit $(build-env sonataflowBuilderImage.dev.mavenM2RepoViaHttpImage)", "setup:env": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && cross-env SWF_IMAGE_REGISTRY=$(build-env sonataflowBuilderImage.registry) SWF_IMAGE_REGISTRY_ACCOUNT=$(build-env sonataflowBuilderImage.account) SWF_IMAGE_NAME=$(build-env sonataflowBuilderImage.name) SWF_IMAGE_TAG=$(build-env sonataflowBuilderImage.tag) QUARKUS_PLATFORM_VERSION=$(build-env quarkusPlatform.version) KOGITO_VERSION=$(build-env kogitoRuntime.version)" }, "devDependencies": { + "@kie-tools/image-builder": "workspace:*", + "@kie-tools/maven-m2-repo-via-http-image": "workspace:*", "@kie-tools/python-venv": "workspace:*", "@kie-tools/root-env": "workspace:*", "@kie-tools/sonataflow-image-common": "workspace:*", diff --git a/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/runtime/community/configure.sh b/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/runtime/community/configure.sh index 8d26bb5940e..66318545159 100644 --- a/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/runtime/community/configure.sh +++ b/packages/sonataflow-builder-image/resources/modules/sonataflow/builder/runtime/community/configure.sh @@ -31,3 +31,6 @@ tar xf "${SOURCES_DIR}"/kogito-swf-maven-repo.tar -C "${KOGITO_HOME}"/.m2/reposi chown -R 1001:0 "${KOGITO_HOME}" chmod -R ug+rwX "${KOGITO_HOME}" + +# Cleanup Maven M2 Repo Via HTTP Settings XML +rm ${MAVEN_CONTAINER_BUILD_SETTINGS_PATH} diff --git a/packages/sonataflow-devmode-image/env/index.js b/packages/sonataflow-devmode-image/env/index.js index 660f9197301..e927ea7817a 100644 --- a/packages/sonataflow-devmode-image/env/index.js +++ b/packages/sonataflow-devmode-image/env/index.js @@ -20,6 +20,10 @@ const { varsWithName, composeEnv, getOrDefault } = require("@kie-tools-scripts/build-env"); const sonataFlowQuarkusDevUiEnv = require("@kie-tools/sonataflow-quarkus-devui/env"); +const { + env: { mavenM2RepoViaHttpImage: mavenM2RepoViaHttpImageEnv }, +} = require("@kie-tools/maven-m2-repo-via-http-image/env"); + const rootEnv = require("@kie-tools/root-env/env"); module.exports = composeEnv([rootEnv], { @@ -44,6 +48,10 @@ module.exports = composeEnv([rootEnv], { default: sonataFlowQuarkusDevUiEnv.env.sonataflowQuarkusDevuiExtension.version, description: "SonataFlow Quarkus Dev UI version", }, + SONATAFLOW_DEVMODE_IMAGE__mavenM2RepoViaHttpImage: { + default: `${mavenM2RepoViaHttpImageEnv.registry}/${mavenM2RepoViaHttpImageEnv.account}/${mavenM2RepoViaHttpImageEnv.name}:${mavenM2RepoViaHttpImageEnv.tag}`, + description: "The image tag for the Maven M2 Repo via HTTP. Used during the build only.", + }, }), get env() { return { @@ -54,6 +62,9 @@ module.exports = composeEnv([rootEnv], { tag: getOrDefault(this.vars.SONATAFLOW_DEVMODE_IMAGE__buildTag), version: require("../package.json").version, sonataflowQuarkusDevUiVersion: getOrDefault(this.vars.SONATAFLOW_DEVMODE_IMAGE__sonataflowQuarkusDevUiVersion), + dev: { + mavenM2RepoViaHttpImage: getOrDefault(this.vars.SONATAFLOW_DEVMODE_IMAGE__mavenM2RepoViaHttpImage), + }, }, }; }, diff --git a/packages/sonataflow-devmode-image/package.json b/packages/sonataflow-devmode-image/package.json index c6b2a47de7b..3b1ba4d462a 100644 --- a/packages/sonataflow-devmode-image/package.json +++ b/packages/sonataflow-devmode-image/package.json @@ -13,10 +13,14 @@ "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", + "build": "run-script-if --bool \"$(build-env containerImages.build)\" --then \"pnpm m2-repo-via-http:container:run\" \"pnpm copy-assets\" \"pnpm image:build\" --finally \"pnpm m2-repo-via-http:container:kill\"", + "build:dev": "pnpm build", + "build:prod": "pnpm build && pnpm image:test", + "copy:maven-m2-repo-via-http-image--settings-xml": "run-script-os", + "copy:maven-m2-repo-via-http-image--settings-xml:linux:darwin": "M2_REPO_VIA_HTTP_URL_WITHOUT_PROTOCOL=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' m2-repo-via-http) envsubst < build/modules/kogito-maven/common/maven/maven-m2-repo-via-http-settings.xml.envsubst > build/modules/kogito-maven/common/maven/maven-m2-repo-via-http-settings.xml && rm build/modules/kogito-maven/common/maven/maven-m2-repo-via-http-settings.xml.envsubst", + "copy:maven-m2-repo-via-http-image--settings-xml:win32": "echo \"Build skipped on macOS and Windows\"", "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 && pnpm copy-devui-repo", + "copy-assets:linux:darwin": "rimraf build && cp -R ./node_modules/@kie-tools/sonataflow-image-common/resources build && cp -R resources/* build && pnpm copy-devui-repo && pnpm copy:maven-m2-repo-via-http-image--settings-xml", "copy-devui-repo": "tar -C ~/.m2/repository/org/apache/kie/ -cvf build/modules/sonataflow/devmode/build-config/sonataflow-quarkus-devui-maven-repo.tar sonataflow && tar -C ~/.m2/repository/org/kie/ -cvf build/modules/sonataflow/devmode/build-config/kie-tools-maven-base-maven-repo.tar kie-tools-maven-base", "copy-test-assets": "run-script-os", "copy-test-assets:linux:darwin": "cp -R ./node_modules/@kie-tools/sonataflow-image-common/test-resources/* build && cp -R test-resources/* build", @@ -28,9 +32,13 @@ "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 && pnpm format", + "m2-repo-via-http:container:kill": "(docker container kill m2-repo-via-http || true) && (docker container rm m2-repo-via-http || true)", + "m2-repo-via-http:container:run": "(pnpm m2-repo-via-http:container:kill || true) && docker run --name m2-repo-via-http -v \"$(mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout):/var/www/html\" -dit $(build-env sonataflowDevModeImage.dev.mavenM2RepoViaHttpImage)", "setup:env": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && cross-env SWF_IMAGE_REGISTRY=$(build-env sonataflowDevModeImage.registry) SWF_IMAGE_REGISTRY_ACCOUNT=$(build-env sonataflowDevModeImage.account) SWF_IMAGE_NAME=$(build-env sonataflowDevModeImage.name) SWF_IMAGE_TAG=$(build-env sonataflowDevModeImage.tag) QUARKUS_PLATFORM_VERSION=$(build-env quarkusPlatform.version) KOGITO_VERSION=$(build-env kogitoRuntime.version) SONATAFLOW_QUARKUS_DEVUI_VERSION=$(build-env sonataflowDevModeImage.sonataflowQuarkusDevUiVersion)" }, "devDependencies": { + "@kie-tools/image-builder": "workspace:*", + "@kie-tools/maven-m2-repo-via-http-image": "workspace:*", "@kie-tools/python-venv": "workspace:*", "@kie-tools/root-env": "workspace:*", "@kie-tools/sonataflow-image-common": "workspace:*", diff --git a/packages/sonataflow-devmode-image/resources/modules/sonataflow/devmode/runtime/community/configure.sh b/packages/sonataflow-devmode-image/resources/modules/sonataflow/devmode/runtime/community/configure.sh index 7404a5c1e5f..ce0b195d4ec 100644 --- a/packages/sonataflow-devmode-image/resources/modules/sonataflow/devmode/runtime/community/configure.sh +++ b/packages/sonataflow-devmode-image/resources/modules/sonataflow/devmode/runtime/community/configure.sh @@ -32,3 +32,6 @@ tar xf "${SOURCES_DIR}"/kogito-swf-maven-repo.tar -C "${KOGITO_HOME}"/.m2/reposi chown -R 1001:0 "${KOGITO_HOME}" chmod -R ug+rwX "${KOGITO_HOME}" + +# Cleanup Maven M2 Repo Via HTTP Settings XML +rm ${MAVEN_CONTAINER_BUILD_SETTINGS_PATH} \ No newline at end of file diff --git a/packages/sonataflow-image-common/resources/Makefile b/packages/sonataflow-image-common/resources/Makefile index 79c1803284a..4f7bf623b31 100644 --- a/packages/sonataflow-image-common/resources/Makefile +++ b/packages/sonataflow-image-common/resources/Makefile @@ -19,7 +19,7 @@ # Image build envs CEKIT_BUILD_OPTIONS ?= -CEKIT_CMD := cekit ${CEKIT_BUILD_OPTIONS} +CEKIT_CMD := cekit BUILD_ENGINE ?= docker BUILD_ENGINE_OPTIONS ?= diff --git a/packages/sonataflow-image-common/resources/modules/kogito-maven/common/maven/maven-m2-repo-via-http-settings.xml.envsubst b/packages/sonataflow-image-common/resources/modules/kogito-maven/common/maven/maven-m2-repo-via-http-settings.xml.envsubst new file mode 100644 index 00000000000..e85c5fc1703 --- /dev/null +++ b/packages/sonataflow-image-common/resources/modules/kogito-maven/common/maven/maven-m2-repo-via-http-settings.xml.envsubst @@ -0,0 +1,107 @@ + + + + kie-tools--maven-m2-repo-via-http-allowed + kie-tools--maven-m2-repo-via-http + Mirror to override default blocking mirror that blocks http. + http://$M2_REPO_VIA_HTTP_URL_WITHOUT_PROTOCOL + + + + + + + + + + + + kie-tools--maven-m2-repo-via-http-allowed-profile + + true + + + + kie-tools--maven-m2-repo-via-http + KIE Tools :: Maven M2 Repo via HTTP + http://$M2_REPO_VIA_HTTP_URL_WITHOUT_PROTOCOL/ + default + + true + never + + + true + never + + + + + + + kie-tools--maven-m2-repo-via-http + KIE Tools :: Maven M2 Repo via HTTP + http://$M2_REPO_VIA_HTTP_URL_WITHOUT_PROTOCOL/ + default + + true + never + + + true + never + + + + + + + kogito-images + + + apache-public-repository-group + Apache Public Repository Group + https://repository.apache.org/content/groups/public/ + default + + true + never + + + true + never + + + + + + + + apache-public-repository-group + Apache Public Repository Group + https://repository.apache.org/content/groups/public/ + default + + true + never + + + true + never + + + + + + + + + kogito-images + kie-tools--maven-m2-repo-via-http-allowed-profile + + diff --git a/packages/sonataflow-image-common/resources/modules/kogito-maven/common/module.yaml b/packages/sonataflow-image-common/resources/modules/kogito-maven/common/module.yaml index d4b95ce8573..fdc7a140d12 100644 --- a/packages/sonataflow-image-common/resources/modules/kogito-maven/common/module.yaml +++ b/packages/sonataflow-image-common/resources/modules/kogito-maven/common/module.yaml @@ -28,6 +28,9 @@ envs: - name: "MAVEN_SETTINGS_PATH" description: "The location of the settings.xml file" value: "${KOGITO_HOME}/.m2/settings.xml" + - name: "MAVEN_CONTAINER_BUILD_SETTINGS_PATH" + description: "The location of the settings.xml file during container image build" + value: "${KOGITO_HOME}/.m2/maven-m2-repo-via-http-settings.xml" - name: "HTTP_PROXY" description: "The location of the http proxy, will be used for both Maven builds and Java runtime." example: "http://127.0.0.1:8080" diff --git a/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/configure.sh b/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/configure.sh index 50897c656b1..fb47d792dc7 100644 --- a/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/configure.sh +++ b/packages/sonataflow-image-common/resources/modules/sonataflow/common/build/configure.sh @@ -33,11 +33,11 @@ chmod -R ug+rwX "${KOGITO_HOME}" cd "${KOGITO_HOME}" -# Create app -"${LAUNCH_DIR}"/create-app.sh +# Create app (settings.xml path is replaced only for these commands and automatically restored when they end) +env MAVEN_SETTINGS_PATH=${MAVEN_CONTAINER_BUILD_SETTINGS_PATH} "${LAUNCH_DIR}"/create-app.sh -"${BUILD_DIR}"/cleanup_project.sh -"${BUILD_DIR}"/zip_files.sh +env MAVEN_SETTINGS_PATH=${MAVEN_CONTAINER_BUILD_SETTINGS_PATH} "${BUILD_DIR}"/cleanup_project.sh +env MAVEN_SETTINGS_PATH=${MAVEN_CONTAINER_BUILD_SETTINGS_PATH} "${BUILD_DIR}"/zip_files.sh chown -R 1001:0 "${KOGITO_HOME}" chmod -R ug+rwX "${KOGITO_HOME}" \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fdb07546c0f..1219f3aeb32 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10299,6 +10299,12 @@ importers: packages/sonataflow-builder-image: devDependencies: + '@kie-tools/image-builder': + specifier: workspace:* + version: link:../image-builder + '@kie-tools/maven-m2-repo-via-http-image': + specifier: workspace:* + version: link:../maven-m2-repo-via-http-image '@kie-tools/python-venv': specifier: workspace:* version: link:../python-venv @@ -10501,6 +10507,12 @@ importers: packages/sonataflow-devmode-image: devDependencies: + '@kie-tools/image-builder': + specifier: workspace:* + version: link:../image-builder + '@kie-tools/maven-m2-repo-via-http-image': + specifier: workspace:* + version: link:../maven-m2-repo-via-http-image '@kie-tools/python-venv': specifier: workspace:* version: link:../python-venv diff --git a/repo/graph.dot b/repo/graph.dot index 738fe698794..47528d1ea6e 100644 --- a/repo/graph.dot +++ b/repo/graph.dot @@ -541,10 +541,12 @@ digraph G { "swf-vscode-extension" -> "@kie-tools-core/webpack-base" [ style = "dashed", color = "blue" ]; "swf-vscode-extension" -> "@kie-tools/serverless-workflow-diagram-editor-assets" [ style = "dashed", color = "blue" ]; "swf-vscode-extension" -> "@kie-tools/vscode-extension-common-test-helpers" [ style = "dashed", color = "blue" ]; + "@kie-tools/sonataflow-builder-image" -> "@kie-tools/maven-m2-repo-via-http-image" [ style = "dashed", color = "black" ]; "@kie-tools/sonataflow-builder-image" -> "@kie-tools/sonataflow-image-common" [ style = "dashed", color = "black" ]; "sonataflow-deployment-webapp" -> "@kie-tools-core/react-hooks" [ style = "solid", color = "blue" ]; "sonataflow-deployment-webapp" -> "@kie-tools/runtime-tools-shared-webapp-components" [ style = "solid", color = "blue" ]; "sonataflow-deployment-webapp" -> "@kie-tools/runtime-tools-swf-webapp-components" [ style = "solid", color = "blue" ]; + "@kie-tools/sonataflow-devmode-image" -> "@kie-tools/maven-m2-repo-via-http-image" [ style = "dashed", color = "black" ]; "@kie-tools/sonataflow-devmode-image" -> "@kie-tools/sonataflow-image-common" [ style = "dashed", color = "black" ]; "@kie-tools/sonataflow-devmode-image" -> "@kie-tools/sonataflow-quarkus-devui" [ style = "dashed", color = "black" ]; "@kie-tools/sonataflow-image-common" -> "@kie-tools/python-venv" [ style = "dashed", color = "black" ]; diff --git a/repo/graph.json b/repo/graph.json index 16bb2c60b77..7a21f3e08fb 100644 --- a/repo/graph.json +++ b/repo/graph.json @@ -1854,11 +1854,21 @@ "target": "@kie-tools/sonataflow-devmode-image", "weight": 1 }, + { + "source": "@kie-tools/sonataflow-builder-image", + "target": "@kie-tools/maven-m2-repo-via-http-image", + "weight": 1 + }, { "source": "@kie-tools/sonataflow-builder-image", "target": "@kie-tools/sonataflow-image-common", "weight": 1 }, + { + "source": "@kie-tools/sonataflow-devmode-image", + "target": "@kie-tools/maven-m2-repo-via-http-image", + "weight": 1 + }, { "source": "@kie-tools/sonataflow-devmode-image", "target": "@kie-tools/sonataflow-image-common",