Skip to content

Commit

Permalink
[build] Only use buildx if cross compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz committed Mar 25, 2022
1 parent 32ac1a5 commit 7565665
Show file tree
Hide file tree
Showing 3 changed files with 7 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 @@ -92,6 +92,7 @@ export async function runDockerGenerator(
dockerTargetFilename,
dockerPush,
dockerTagQualifier,
dockerCrossCompile,
baseOSImage,
dockerBuildDate,
ubi: flags.ubi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface TemplateContext {
artifactsDir: string;
dockerPush: boolean;
dockerTagQualifier: string | null;
dockerCrossCompile: boolean;
imageTag: string;
dockerBuildDir: string;
dockerTargetFilename: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function generator({
imageFlavor,
dockerPush,
dockerTagQualifier,
dockerCrossCompile,
version,
dockerTargetFilename,
baseOSImage,
Expand All @@ -24,6 +25,9 @@ function generator({
dockerTagQualifier ? '-' + dockerTagQualifier : ''
}`;
const dockerArchitecture = architecture === 'aarch64' ? 'linux/arm64' : 'linux/amd64';
const dockerBuild = dockerCrossCompile
? `docker build -t ${imageTag}${imageFlavor}:${version} -f Dockerfile . || exit 1;`
: `docker buildx build --platform ${dockerArchitecture} -t ${dockerTargetName} -f Dockerfile . || exit 1;`;
return dedent(`
#!/usr/bin/env bash
#
Expand Down Expand Up @@ -60,7 +64,7 @@ function generator({
retry_docker_pull ${baseOSImage}
echo "Building: kibana${imageFlavor}-docker"; \\
docker buildx build --platform ${dockerArchitecture} -t ${dockerTargetName} -f Dockerfile . || exit 1;
${dockerBuild}
docker save ${dockerTargetName} | gzip -c > ${dockerTargetFilename}
Expand Down

0 comments on commit 7565665

Please sign in to comment.