This is an automated email from the ASF dual-hosted git repository.
ranand pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git
The following commit(s) were added to refs/heads/main by this push:
new 92fb61548b9 kie-issues#3331: Provide option in `image-builder` to use
default Docker driver with BuildKit (#3332)
92fb61548b9 is described below
commit 92fb61548b998e933c79ffb33e862e059e7d51ad
Author: Rishiraj Anand <[email protected]>
AuthorDate: Thu Oct 30 23:49:41 2025 +0530
kie-issues#3331: Provide option in `image-builder` to use default Docker
driver with BuildKit (#3332)
---
packages/image-builder/README.md | 1 +
packages/image-builder/src/bin.ts | 62 +++++++++++++++++++++++++--------------
2 files changed, 41 insertions(+), 22 deletions(-)
diff --git a/packages/image-builder/README.md b/packages/image-builder/README.md
index b68d1a83bef..435d1f8768a 100644
--- a/packages/image-builder/README.md
+++ b/packages/image-builder/README.md
@@ -15,6 +15,7 @@ Options:
-e, --engine The build engine to be used [string]
[choices: "docker", "podman"] [default: "docker"]
-p, --push Push the image to the registry [boolean]
[default: false]
--allowHostNetworkAccess Allows host network access during build
[boolean] [default: false]
+ --useDefaultBuilder Allows docker buildx to use default builder
[boolean] [default: false]
-f, --containerfile Path to the Containerfile/Dockerfile [string]
[default: "Containerfile"]
-c, --context Path to the build context [string] [default:
"./"]
--build-arg Build args for the builder in the format
'<arg>=<value>', where <value> is a string (Can be used multiple times)
[array] [default: []]
diff --git a/packages/image-builder/src/bin.ts
b/packages/image-builder/src/bin.ts
index a1ca8569543..27cb675cb37 100644
--- a/packages/image-builder/src/bin.ts
+++ b/packages/image-builder/src/bin.ts
@@ -35,6 +35,7 @@ type ArgsType = {
push: boolean;
buildArg: string[];
arch?: string[];
+ useDefaultBuilder: boolean;
allowHostNetworkAccess: boolean;
};
@@ -62,27 +63,31 @@ function getImageFullNames(args: ArgsType) {
return args.tags.map((tag) => `${imageFullNameWithoutTags}:${tag}`);
}
-function createAndUseDockerBuilder(args: { allowHostNetworkAccess: boolean }) {
- try {
- console.info("[image-builder] Checking for existing kie-tools-builder...");
- execSync("docker buildx inspect kie-tools-builder", { stdio: "inherit" });
- console.info("[image-builder] kie-tools-builder found, using it.");
- execSync("docker buildx use kie-tools-builder", { stdio: "inherit" });
- } catch (e) {
- console.info("[image-builder] kie-tools-builder not found, creating it.");
- execSync(
- `docker buildx create
- --buildkitd-flags '--allow-insecure-entitlement network.host'
- --name kie-tools-builder
- --driver docker-container
- --bootstrap
- --use`
- .split("\n")
- .join(" "),
- {
- stdio: "inherit",
- }
- );
+function createAndUseDockerBuilder(args: { allowHostNetworkAccess: boolean;
useDefaultBuilder: boolean }) {
+ if (args.useDefaultBuilder) {
+ execSync("docker buildx use default", { stdio: "inherit" });
+ } else {
+ try {
+ console.info("[image-builder] Checking for existing
kie-tools-builder...");
+ execSync("docker buildx inspect kie-tools-builder", { stdio: "inherit"
});
+ console.info("[image-builder] kie-tools-builder found, using it.");
+ execSync("docker buildx use kie-tools-builder", { stdio: "inherit" });
+ } catch (e) {
+ console.info("[image-builder] kie-tools-builder not found, creating
it.");
+ execSync(
+ `docker buildx create
+ --buildkitd-flags '--allow-insecure-entitlement network.host'
+ --name kie-tools-builder
+ --driver docker-container
+ --bootstrap
+ --use`
+ .split("\n")
+ .join(" "),
+ {
+ stdio: "inherit",
+ }
+ );
+ }
}
}
@@ -99,7 +104,10 @@ function checkBuildEngine(args: ArgsType) {
}
function buildArchImage(args: ArgsType & { arch: string[] | undefined },
imageFullNames: string[]) {
- createAndUseDockerBuilder({ allowHostNetworkAccess:
args.allowHostNetworkAccess });
+ createAndUseDockerBuilder({
+ allowHostNetworkAccess: args.allowHostNetworkAccess,
+ useDefaultBuilder: args.useDefaultBuilder,
+ });
console.log(`[image-builder] Building arch image ${args.arch}`);
const buildPlatformCommand = `docker buildx build
${args.allowHostNetworkAccess ? "--allow network.host --network host" : ""}
@@ -283,6 +291,12 @@ Also useful to aid on developing images and pushing them
to Kubernetes/OpenShift
describe: "Allows host network access during build",
type: "boolean",
},
+ useDefaultBuilder: {
+ demandOption: false,
+ default: false,
+ describe: "Allows docker buildx to use default builder",
+ type: "boolean",
+ },
containerfile: {
alias: "f",
demandOption: false,
@@ -354,6 +368,7 @@ Also useful to aid on developing images and pushing them to
Kubernetes/OpenShift
- engine: ${args.engine}
- push: ${args.push}
- allowHostNetworkAccess: ${args.allowHostNetworkAccess}
+ - useDefaultBuilder: ${args.useDefaultBuilder}
- arch: ${args.arch}
`);
if (!checkNativeArch(args.arch) && args.engine !== "docker") {
@@ -382,6 +397,7 @@ Also useful to aid on developing images and pushing them to
Kubernetes/OpenShift
- engine: ${args.engine}
- push: ${args.push}
- allowHostNetworkAccess: ${args.allowHostNetworkAccess}
+ - useDefaultBuilder: ${args.useDefaultBuilder}
- arch: linux/amd64`);
if (args.engine !== "docker") {
@@ -424,6 +440,7 @@ Also useful to aid on developing images and pushing them to
Kubernetes/OpenShift
- engine: ${args.engine}
- push: ${args.push}
- arch: linux/amd64
+ - useDefaultBuilder: ${args.useDefaultBuilder}
- allowHostNetworkAccess: ${args.allowHostNetworkAccess} (ignored)
- kindClusterName: ${args.kindClusterName}
`);
@@ -464,6 +481,7 @@ Also useful to aid on developing images and pushing them to
Kubernetes/OpenShift
- buildArg: ${args.buildArg?.join(" ") ?? " - "}
- engine: ${args.engine} (ignored)
- push: ${args.push}
+ - useDefaultBuilder: ${args.useDefaultBuilder}
- allowHostNetworkAccess: ${args.allowHostNetworkAccess} (ignored)
- arch: linux/amd64
`);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]