Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build/docker] Add support for centos ARM builds #84831

Merged
merged 41 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f604e34
[build/docker] Add support for centos ARM builds
jbudz Dec 2, 2020
6f325d2
update snapshots
jbudz Dec 2, 2020
0d2cce2
Merge branch 'master' of github.com:elastic/kibana into docker/archit…
jbudz Dec 3, 2020
3b565b5
Merge branch 'master' into docker/architecture
jbudz Dec 4, 2020
8bc4add
Merge branch 'master' into docker/architecture
jbudz Dec 7, 2020
09163aa
Merge branch 'master' into docker/architecture
jbudz Dec 7, 2020
c10c26d
always generate docker bundle, only build image for native host
jbudz Dec 7, 2020
a2946b0
update logs to specify package architecture
jbudz Dec 7, 2020
353a305
Merge branch 'master' into docker/architecture
kibanamachine Dec 8, 2020
4cccd58
node architecture first
jbudz Dec 9, 2020
a126007
Merge branch 'master' into docker/architecture
jbudz Dec 9, 2020
791ad36
fix types
jbudz Dec 9, 2020
0369613
set image architecture name
jbudz Dec 9, 2020
9212860
fix context
jbudz Dec 9, 2020
4ca411b
Merge branch 'master' into docker/architecture
kibanamachine Dec 14, 2020
beeec42
Merge branch 'master' into docker/architecture
kibanamachine Dec 16, 2020
7cdc6f9
Merge branch 'master' into docker/architecture
kibanamachine Dec 17, 2020
eee3c31
Merge branch 'master' into docker/architecture
jbudz Dec 22, 2020
900cf67
wip
jbudz Dec 28, 2020
154ba3f
Merge branch 'master' into docker/architecture
jbudz Dec 30, 2020
fcccf98
split docker flags into docker-images and docker-bundles
jbudz Dec 30, 2020
6687d58
Merge branch 'docker/architecture' of github.com:jbudz/kibana into do…
jbudz Dec 30, 2020
a797291
fix typo
jbudz Dec 30, 2020
cb901cd
bundles -> contexts
jbudz Dec 30, 2020
60ef70c
remove unusued export
jbudz Dec 30, 2020
d7964fb
Merge branch 'master' into docker/architecture
jbudz Jan 4, 2021
92554cb
support --skip-centos and --skip-ubi
jbudz Jan 4, 2021
3af58a0
Merge branch 'master' into docker/architecture
kibanamachine Jan 11, 2021
01a12fc
Merge branch 'master' into docker/architecture
jbudz Jan 13, 2021
749c203
consistent architecture matching
jbudz Jan 13, 2021
f00cc29
align image and context filenames
jbudz Jan 14, 2021
64a3a34
translate config architecture to node
jbudz Jan 18, 2021
4df4a3d
Merge branch 'master' into docker/architecture
jbudz Jan 18, 2021
5bec37e
fix x64 host
jbudz Jan 19, 2021
034d478
squash architecture specific contexts
jbudz Jan 20, 2021
6326411
Merge branch 'master' into docker/architecture
kibanamachine Jan 21, 2021
33eab33
fix types
jbudz Jan 21, 2021
1a6f2cd
Merge branch 'master' into docker/architecture
kibanamachine Jan 25, 2021
6ab6178
Merge remote-tracking branch 'upstream/master' into docker/architecture
Jan 27, 2021
88c1705
Merge branch 'master' into docker/architecture
jbudz Jan 27, 2021
288710e
fix ubi context
jbudz Jan 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 53 additions & 15 deletions src/dev/build/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ it('build default and oss dist for current platform, without packages, by defaul
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": false,
"createDockerUbiPackage": false,
"createDockerCentOS": false,
"createDockerContexts": false,
"createDockerUBI": false,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
Expand All @@ -53,8 +54,9 @@ it('builds packages if --all-platforms is passed', () => {
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerPackage": true,
"createDockerUbiPackage": true,
"createDockerCentOS": true,
"createDockerContexts": true,
"createDockerUBI": true,
"createRpmPackage": true,
"downloadFreshNode": true,
"isRelease": false,
Expand All @@ -76,8 +78,9 @@ it('limits packages if --rpm passed with --all-platforms', () => {
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": false,
"createDockerUbiPackage": false,
"createDockerCentOS": false,
"createDockerContexts": false,
"createDockerUBI": false,
"createRpmPackage": true,
"downloadFreshNode": true,
"isRelease": false,
Expand All @@ -99,8 +102,9 @@ it('limits packages if --deb passed with --all-platforms', () => {
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerPackage": false,
"createDockerUbiPackage": false,
"createDockerCentOS": false,
"createDockerContexts": false,
"createDockerUBI": false,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
Expand All @@ -115,16 +119,17 @@ it('limits packages if --deb passed with --all-platforms', () => {
});

it('limits packages if --docker passed with --all-platforms', () => {
expect(readCliArgs(['node', 'scripts/build', '--all-platforms', '--docker']))
expect(readCliArgs(['node', 'scripts/build', '--all-platforms', '--docker-images']))
.toMatchInlineSnapshot(`
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": true,
"createDockerUbiPackage": true,
"createDockerCentOS": true,
"createDockerContexts": false,
"createDockerUBI": true,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
Expand All @@ -139,16 +144,24 @@ it('limits packages if --docker passed with --all-platforms', () => {
});

it('limits packages if --docker passed with --skip-docker-ubi and --all-platforms', () => {
expect(readCliArgs(['node', 'scripts/build', '--all-platforms', '--docker', '--skip-docker-ubi']))
.toMatchInlineSnapshot(`
expect(
readCliArgs([
'node',
'scripts/build',
'--all-platforms',
'--docker-images',
'--skip-docker-ubi',
])
).toMatchInlineSnapshot(`
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": true,
"createDockerUbiPackage": false,
"createDockerCentOS": true,
"createDockerContexts": false,
"createDockerUBI": false,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
Expand All @@ -161,3 +174,28 @@ it('limits packages if --docker passed with --skip-docker-ubi and --all-platform
}
`);
});

it('limits packages if --all-platforms passed with --skip-docker-centos', () => {
expect(readCliArgs(['node', 'scripts/build', '--all-platforms', '--skip-docker-centos']))
.toMatchInlineSnapshot(`
Object {
"buildOptions": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerCentOS": false,
"createDockerContexts": true,
"createDockerUBI": true,
"createRpmPackage": true,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
},
"log": <ToolingLog>,
"showHelp": false,
"unknownFlags": Array [],
}
`);
});
22 changes: 16 additions & 6 deletions src/dev/build/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ export function readCliArgs(argv: string[]) {
'skip-os-packages',
'rpm',
'deb',
'docker',
'docker-images',
'docker-contexts',
'skip-docker-ubi',
'skip-docker-centos',
'release',
'skip-node-download',
'verbose',
Expand All @@ -42,7 +44,8 @@ export function readCliArgs(argv: string[]) {
debug: true,
rpm: null,
deb: null,
docker: null,
'docker-images': null,
'docker-contexts': null,
oss: null,
'version-qualifier': '',
},
Expand All @@ -69,7 +72,7 @@ export function readCliArgs(argv: string[]) {

// In order to build a docker image we always need
// to generate all the platforms
if (flags.docker) {
if (flags['docker-images'] || flags['docker-contexts']) {
flags['all-platforms'] = true;
}

Expand All @@ -79,7 +82,12 @@ export function readCliArgs(argv: string[]) {
}

// build all if no flags specified
if (flags.rpm === null && flags.deb === null && flags.docker === null) {
if (
flags.rpm === null &&
flags.deb === null &&
flags['docker-images'] === null &&
flags['docker-contexts'] === null
) {
return true;
}

Expand All @@ -95,8 +103,10 @@ export function readCliArgs(argv: string[]) {
createArchives: !Boolean(flags['skip-archives']),
createRpmPackage: isOsPackageDesired('rpm'),
createDebPackage: isOsPackageDesired('deb'),
createDockerPackage: isOsPackageDesired('docker'),
createDockerUbiPackage: isOsPackageDesired('docker') && !Boolean(flags['skip-docker-ubi']),
createDockerCentOS:
isOsPackageDesired('docker-images') && !Boolean(flags['skip-docker-centos']),
createDockerUBI: isOsPackageDesired('docker-images') && !Boolean(flags['skip-docker-ubi']),
createDockerContexts: isOsPackageDesired('docker-contexts'),
targetAllPlatforms: Boolean(flags['all-platforms']),
};

Expand Down
24 changes: 16 additions & 8 deletions src/dev/build/build_distributables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export interface BuildOptions {
createArchives: boolean;
createRpmPackage: boolean;
createDebPackage: boolean;
createDockerPackage: boolean;
createDockerUbiPackage: boolean;
createDockerUBI: boolean;
createDockerCentOS: boolean;
createDockerContexts: boolean;
versionQualifier: string | undefined;
targetAllPlatforms: boolean;
}
Expand Down Expand Up @@ -95,12 +96,19 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions
// control w/ --rpm or --skip-os-packages
await run(Tasks.CreateRpmPackage);
}
if (options.createDockerPackage) {
// control w/ --docker or --skip-docker-ubi or --skip-os-packages
await run(Tasks.CreateDockerPackage);
if (options.createDockerUbiPackage) {
await run(Tasks.CreateDockerUbiPackage);
}
if (options.createDockerUBI) {
// control w/ --docker-images or --skip-docker-ubi or --skip-os-packages
await run(Tasks.CreateDockerUBI);
}

if (options.createDockerCentOS) {
// control w/ --docker-images or --skip-docker-centos or --skip-os-packages
await run(Tasks.CreateDockerCentOS);
}

if (options.createDockerContexts) {
// control w/ --docker-contexts or --skip-os-packages
await run(Tasks.CreateDockerContexts);
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/dev/build/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ if (showHelp) {
--skip-archives {dim Don't produce tar/zip archives}
--skip-os-packages {dim Don't produce rpm/deb/docker packages}
--all-platforms {dim Produce archives for all platforms, not just this one}
--rpm {dim Only build the rpm package}
--deb {dim Only build the deb package}
--docker {dim Only build the docker image}
--rpm {dim Only build the rpm packages}
--deb {dim Only build the deb packages}
--docker-images {dim Only build the Docker images}
--docker-contexts {dim Only build the Docker build contexts}
--skip-docker-ubi {dim Don't build the docker ubi image}
--skip-docker-centos {dim Don't build the docker centos image}
--release {dim Produce a release-ready distributable}
--version-qualifier {dim Suffix version with a qualifier}
--skip-node-download {dim Reuse existing downloads of node.js}
Expand Down
54 changes: 45 additions & 9 deletions src/dev/build/tasks/os_packages/create_os_package_tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { Task } from '../../lib';
import { runFpm } from './run_fpm';
import { runDockerGenerator, runDockerGeneratorForUBI } from './docker_generator';
import { runDockerGenerator } from './docker_generator';

export const CreateDebPackage: Task = {
description: 'Creating deb package',
Expand Down Expand Up @@ -49,20 +49,56 @@ export const CreateRpmPackage: Task = {
},
};

export const CreateDockerPackage: Task = {
description: 'Creating docker package',
export const CreateDockerCentOS: Task = {
description: 'Creating Docker CentOS image',

async run(config, log, build) {
// Builds Docker targets for default and oss
await runDockerGenerator(config, log, build);
await runDockerGenerator(config, log, build, {
ubi: false,
context: false,
architecture: 'x64',
image: true,
});
await runDockerGenerator(config, log, build, {
ubi: false,
context: false,
architecture: 'aarch64',
image: true,
});
},
};

export const CreateDockerUbiPackage: Task = {
description: 'Creating docker ubi package',
export const CreateDockerUBI: Task = {
description: 'Creating Docker UBI image',

async run(config, log, build) {
// Builds Docker target default with ubi7 base image
await runDockerGeneratorForUBI(config, log, build);
if (!build.isOss()) {
await runDockerGenerator(config, log, build, {
ubi: true,
context: false,
architecture: 'x64',
image: true,
});
}
},
};

export const CreateDockerContexts: Task = {
description: 'Creating Docker build contexts',

async run(config, log, build) {
await runDockerGenerator(config, log, build, {
ubi: false,
context: true,
image: false,
});

if (!build.isOss()) {
await runDockerGenerator(config, log, build, {
ubi: true,
context: true,
image: false,
});
}
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export async function bundleDockerFiles(config: Config, log: ToolingLog, scope:
log.info(
`Generating kibana${scope.imageFlavor}${scope.ubiImageFlavor} docker build context bundle`
);

const dockerFilesDirName = `kibana${scope.imageFlavor}${scope.ubiImageFlavor}-${scope.version}-docker-build-context`;
const dockerFilesBuildDir = resolve(scope.dockerBuildDir, dockerFilesDirName);
const dockerFilesOutputDir = config.resolveFromTarget(`${dockerFilesDirName}.tar.gz`);
Expand Down
2 changes: 1 addition & 1 deletion src/dev/build/tasks/os_packages/docker_generator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* Public License, v 1.
*/

export { runDockerGenerator, runDockerGeneratorForUBI } from './run';
export { runDockerGenerator } from './run';
Loading