Skip to content

Commit

Permalink
[build] Cross compile docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz committed Mar 22, 2022
1 parent 201b352 commit 621780e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
14 changes: 2 additions & 12 deletions src/dev/build/tasks/os_packages/docker_generator/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export async function runDockerGenerator(
const dockerBuildDate = flags.dockerBuildDate || new Date().toISOString();
// That would produce oss, default and default-ubi7
const dockerBuildDir = config.resolveFromRepo('build', 'kibana-docker', `default${imageFlavor}`);
const imageArchitecture = flags.architecture === 'aarch64' ? '-aarch64' : '';
const imageArchitecture = flags.architecture === 'aarch64' ? 'arm64' : 'amd64';
const dockerTargetFilename = config.resolveFromTarget(
`kibana${imageFlavor}-${version}-docker-image${imageArchitecture}.tar.gz`
`kibana${imageFlavor}-${version}-docker-image-${imageArchitecture}.tar.gz`
);
const dependencies = [
resolve(artifactsDir, artifactTarball),
Expand Down Expand Up @@ -104,16 +104,6 @@ export async function runDockerGenerator(
publicArtifactSubdomain,
};

type HostArchitectureToDocker = Record<string, string>;
const hostTarget: HostArchitectureToDocker = {
x64: 'x64',
arm64: 'aarch64',
};
const buildArchitectureSupported = hostTarget[process.arch] === flags.architecture;
if (flags.architecture && !buildArchitectureSupported) {
return;
}

// Create the docker build target folder
await mkdirp(dockerBuildDir);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function generator({
const dockerTargetName = `${imageTag}${imageFlavor}:${version}${
dockerTagQualifier ? '-' + dockerTagQualifier : ''
}`;
const dockerArchitecutre = architecture === 'aarch64' ? 'linux/arm64' : 'linux/amd64';
return dedent(`
#!/usr/bin/env bash
#
Expand Down Expand Up @@ -59,7 +60,7 @@ function generator({
retry_docker_pull ${baseOSImage}
echo "Building: kibana${imageFlavor}-docker"; \\
docker build -t ${dockerTargetName} -f Dockerfile . || exit 1;
docker buildx build --platform ${dockerArchitecutre} -t ${dockerTargetName} -f Dockerfile . || exit 1;
docker save ${dockerTargetName} | gzip -c > ${dockerTargetFilename}
Expand Down

0 comments on commit 621780e

Please sign in to comment.