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

[10.0.x] NO-ISSUE: Use maven-m2-repo-via-http to build sonataflow-builder/devmode-images #2616

Merged
merged 1 commit into from
Sep 24, 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
2 changes: 1 addition & 1 deletion devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
},
"[email protected]": {
"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",
Expand Down
11 changes: 11 additions & 0 deletions packages/sonataflow-builder-image/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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], {
Expand All @@ -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 {
Expand All @@ -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),
},
},
};
},
Expand Down
14 changes: 11 additions & 3 deletions packages/sonataflow-builder-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
11 changes: 11 additions & 0 deletions packages/sonataflow-devmode-image/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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], {
Expand All @@ -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 {
Expand All @@ -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),
},
},
};
},
Expand Down
14 changes: 11 additions & 3 deletions packages/sonataflow-devmode-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
2 changes: 1 addition & 1 deletion packages/sonataflow-image-common/resources/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?=

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<settings
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd"
>
<mirrors>
<mirror>
<id>kie-tools--maven-m2-repo-via-http-allowed</id>
<mirrorOf>kie-tools--maven-m2-repo-via-http</mirrorOf>
<name>Mirror to override default blocking mirror that blocks http.</name>
<url>http://$M2_REPO_VIA_HTTP_URL_WITHOUT_PROTOCOL</url>
</mirror>
</mirrors>

<proxies>
<!-- ### configured http proxy ### -->
</proxies>

<profiles>
<!-- ### extra maven repositories ### -->

<profile>
<id>kie-tools--maven-m2-repo-via-http-allowed-profile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>kie-tools--maven-m2-repo-via-http</id>
<name>KIE Tools :: Maven M2 Repo via HTTP</name>
<url>http://$M2_REPO_VIA_HTTP_URL_WITHOUT_PROTOCOL/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>kie-tools--maven-m2-repo-via-http</id>
<name>KIE Tools :: Maven M2 Repo via HTTP</name>
<url>http://$M2_REPO_VIA_HTTP_URL_WITHOUT_PROTOCOL/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>

<profile>
<id>kogito-images</id>
<repositories>
<repository>
<id>apache-public-repository-group</id>
<name>Apache Public Repository Group</name>
<url>https://repository.apache.org/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<!-- ### configured repositories ### -->
</repositories>

<pluginRepositories>
<pluginRepository>
<id>apache-public-repository-group</id>
<name>Apache Public Repository Group</name>
<url>https://repository.apache.org/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
<!-- ### configured plugin repositories ### -->
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!-- ### extra maven profile ### -->
<activeProfile>kogito-images</activeProfile>
<activeProfile>kie-tools--maven-m2-repo-via-http-allowed-profile</activeProfile>
</activeProfiles>
</settings>
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions repo/graph.dot
Original file line number Diff line number Diff line change
Expand Up @@ -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" ];
Expand Down
10 changes: 10 additions & 0 deletions repo/graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading