Skip to content

Commit

Permalink
[7.17] [build] Only use buildx if cross compiling (#128560) (#129781)
Browse files Browse the repository at this point in the history
* [build] Only use buildx if cross compiling

* reuse variable

* fix conditional
  • Loading branch information
jbudz committed Apr 7, 2022
1 parent 92626a1 commit fc6ea53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/dev/build/tasks/os_packages/docker_generator/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export async function runDockerGenerator(
imageTag,
dockerBuildDir,
dockerTargetFilename,
dockerCrossCompile,
baseOSImage,
dockerBuildDate,
ubi: flags.ubi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface TemplateContext {
version: string;
license: string;
artifactsDir: string;
dockerCrossCompile: boolean;
imageTag: string;
dockerBuildDir: string;
dockerTargetFilename: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ import { TemplateContext } from '../template_context';
function generator({
imageTag,
imageFlavor,
dockerCrossCompile,
version,
dockerTargetFilename,
baseOSImage,
architecture,
}: TemplateContext) {
const dockerArchitecture = architecture === 'aarch64' ? 'linux/arm64' : 'linux/amd64';
const dockerTargetName = `${imageTag}${imageFlavor}:${version}`;
const dockerBuild = dockerCrossCompile
? `docker buildx build --platform ${dockerArchitecture} -t ${dockerTargetName} -f Dockerfile . || exit 1;`
: `docker build -t ${dockerTargetName} -f Dockerfile . || exit 1;`;
return dedent(`
#!/usr/bin/env bash
#
Expand Down Expand Up @@ -55,7 +60,7 @@ function generator({
retry_docker_pull ${baseOSImage}
echo "Building: kibana${imageFlavor}-docker"; \\
docker buildx build --platform ${dockerArchitecture} -t ${imageTag}${imageFlavor}:${version} -f Dockerfile . || exit 1;
${dockerBuild}
docker save ${imageTag}${imageFlavor}:${version} | gzip -c > ${dockerTargetFilename}
Expand Down

0 comments on commit fc6ea53

Please sign in to comment.