forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[7.17] [build] Cross compile docker images (elastic#128272)
* [build] Cross compile docker images * typo * debug * Revert "[build] Cross compile docker images" This reverts commit 621780e. * revert * support docker-cross-compile flag * fix types/tests * fix more tests * download cloud dependencies based on cross compile flag * fix array * fix more tests
- Loading branch information
Showing
14 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ const config = new Config( | |
buildSha: 'abcd1234', | ||
buildVersion: '8.0.0', | ||
}, | ||
false, | ||
true | ||
); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import Path from 'path'; | ||
import del from 'del'; | ||
import Axios from 'axios'; | ||
import { Task, downloadToDisk, downloadToString } from '../lib'; | ||
|
||
export const DownloadCloudDependencies: Task = { | ||
description: 'Downloading cloud dependencies', | ||
|
||
async run(config, log, build) { | ||
const downloadBeat = async (beat: string, id: string) => { | ||
const subdomain = config.isRelease ? 'artifacts' : 'snapshots'; | ||
const version = config.getBuildVersion(); | ||
const buildId = id.match(/[0-9]\.[0-9]\.[0-9]-[0-9a-z]{8}/); | ||
const buildIdUrl = buildId ? `${buildId[0]}/` : ''; | ||
|
||
const localArchitecture = [process.arch === 'arm64' ? 'arm64' : 'x86_64']; | ||
const allArchitectures = ['arm64', 'x86_64']; | ||
const architectures = config.getDockerCrossCompile() ? allArchitectures : localArchitecture; | ||
const downloads = architectures.map(async (arch) => { | ||
const url = `https://${subdomain}-no-kpi.elastic.co/${buildIdUrl}downloads/beats/${beat}/${beat}-${version}-linux-${arch}.tar.gz`; | ||
const checksum = await downloadToString({ log, url: url + '.sha512', expectStatus: 200 }); | ||
const destination = config.resolveFromRepo('.beats', Path.basename(url)); | ||
return downloadToDisk({ | ||
log, | ||
url, | ||
destination, | ||
shaChecksum: checksum.split(' ')[0], | ||
shaAlgorithm: 'sha512', | ||
maxAttempts: 3, | ||
}); | ||
}); | ||
return Promise.all(downloads); | ||
}; | ||
|
||
let buildId = ''; | ||
if (!config.isRelease) { | ||
const manifestUrl = `https://artifacts-api.elastic.co/v1/versions/${config.getBuildVersion()}/builds/latest`; | ||
try { | ||
const manifest = await Axios.get(manifestUrl); | ||
buildId = manifest.data.build.build_id; | ||
} catch (e) { | ||
log.error( | ||
`Unable to find Elastic artifacts for ${config.getBuildVersion()} at ${manifestUrl}.` | ||
); | ||
throw e; | ||
} | ||
} | ||
await del([config.resolveFromRepo('.beats')]); | ||
|
||
await downloadBeat('metricbeat', buildId); | ||
await downloadBeat('filebeat', buildId); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters