Skip to content

Commit

Permalink
support docker-cross-compile flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz committed Mar 23, 2022
1 parent 189fa27 commit 0a73165
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/dev/build/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ it('build default and oss dist for current platform, without packages, by defaul
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
"dockerCrossCompile": false,
"dockerPush": false,
"dockerTagQualifier": null,
"downloadCloudDependencies": true,
Expand Down Expand Up @@ -67,6 +68,7 @@ it('builds packages if --all-platforms is passed', () => {
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,
"dockerCrossCompile": false,
"dockerPush": false,
"dockerTagQualifier": null,
"downloadCloudDependencies": true,
Expand Down Expand Up @@ -98,6 +100,7 @@ it('limits packages if --rpm passed with --all-platforms', () => {
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,
"dockerCrossCompile": false,
"dockerPush": false,
"dockerTagQualifier": null,
"downloadCloudDependencies": true,
Expand Down Expand Up @@ -129,6 +132,7 @@ it('limits packages if --deb passed with --all-platforms', () => {
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
"dockerCrossCompile": false,
"dockerPush": false,
"dockerTagQualifier": null,
"downloadCloudDependencies": true,
Expand Down Expand Up @@ -161,6 +165,7 @@ it('limits packages if --docker passed with --all-platforms', () => {
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
"dockerCrossCompile": false,
"dockerPush": false,
"dockerTagQualifier": null,
"downloadCloudDependencies": true,
Expand Down Expand Up @@ -200,6 +205,7 @@ it('limits packages if --docker passed with --skip-docker-ubi and --all-platform
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": false,
"dockerCrossCompile": false,
"dockerPush": false,
"dockerTagQualifier": null,
"downloadCloudDependencies": true,
Expand Down Expand Up @@ -232,6 +238,7 @@ it('limits packages if --all-platforms passed with --skip-docker-ubuntu', () =>
"createGenericFolders": true,
"createPlatformFolders": true,
"createRpmPackage": true,
"dockerCrossCompile": false,
"dockerPush": false,
"dockerTagQualifier": null,
"downloadCloudDependencies": true,
Expand Down
3 changes: 3 additions & 0 deletions src/dev/build/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function readCliArgs(argv: string[]) {
'skip-os-packages',
'rpm',
'deb',
'docker-cross-compile',
'docker-images',
'docker-push',
'skip-docker-contexts',
Expand Down Expand Up @@ -52,6 +53,7 @@ export function readCliArgs(argv: string[]) {
rpm: null,
deb: null,
'docker-images': null,
'docker-cross-compile': false,
'docker-push': false,
'docker-tag-qualifier': null,
'version-qualifier': '',
Expand Down Expand Up @@ -112,6 +114,7 @@ export function readCliArgs(argv: string[]) {
const buildOptions: BuildOptions = {
isRelease: Boolean(flags.release),
versionQualifier: flags['version-qualifier'],
dockerCrossCompile: Boolean(flags['docker-cross-compile']),
dockerPush: Boolean(flags['docker-push']),
dockerTagQualifier: flags['docker-tag-qualifier'],
initialize: !Boolean(flags['skip-initialize']),
Expand Down
1 change: 1 addition & 0 deletions src/dev/build/build_distributables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as Tasks from './tasks';

export interface BuildOptions {
isRelease: boolean;
dockerCrossCompile: boolean;
dockerPush: boolean;
dockerTagQualifier: string | null;
downloadFreshNode: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/dev/build/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if (showHelp) {
--rpm {dim Only build the rpm packages}
--deb {dim Only build the deb packages}
--docker-images {dim Only build the Docker images}
--docker-cross-compile {dim Produce arm64 and amd64 Docker images}
--docker-contexts {dim Only build the Docker build contexts}
--skip-docker-ubi {dim Don't build the docker ubi image}
--skip-docker-ubuntu {dim Don't build the docker ubuntu image}
Expand Down
11 changes: 11 additions & 0 deletions src/dev/build/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface Options {
isRelease: boolean;
targetAllPlatforms: boolean;
versionQualifier?: string;
dockerCrossCompile: boolean;
dockerTagQualifier: string | null;
dockerPush: boolean;
}
Expand All @@ -35,6 +36,7 @@ export class Config {
isRelease,
targetAllPlatforms,
versionQualifier,
dockerCrossCompile,
dockerTagQualifier,
dockerPush,
}: Options) {
Expand All @@ -51,6 +53,7 @@ export class Config {
versionQualifier,
pkg,
}),
dockerCrossCompile,
dockerTagQualifier,
dockerPush,
isRelease
Expand All @@ -63,6 +66,7 @@ export class Config {
private readonly nodeVersion: string,
private readonly repoRoot: string,
private readonly versionInfo: VersionInfo,
private readonly dockerCrossCompile: boolean,
private readonly dockerTagQualifier: string | null,
private readonly dockerPush: boolean,
public readonly isRelease: boolean
Expand Down Expand Up @@ -96,6 +100,13 @@ export class Config {
return this.dockerPush;
}

/**
* Get docker cross compile
*/
getDockerCrossCompile() {
return this.dockerCrossCompile;
}

/**
* Convert an absolute path to a relative path, based from the repo
*/
Expand Down
3 changes: 2 additions & 1 deletion src/dev/build/tasks/os_packages/docker_generator/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export async function runDockerGenerator(

const dockerPush = config.getDockerPush();
const dockerTagQualifier = config.getDockerTagQualfiier();
const dockerCrossCompile = config.getDockerCrossCompile();
const publicArtifactSubdomain = config.isRelease ? 'artifacts' : 'snapshots-no-kpi';

const scope: TemplateContext = {
Expand Down Expand Up @@ -110,7 +111,7 @@ export async function runDockerGenerator(
arm64: 'aarch64',
};
const buildArchitectureSupported = hostTarget[process.arch] === flags.architecture;
if (flags.architecture && !buildArchitectureSupported) {
if (flags.architecture && !buildArchitectureSupported && !dockerCrossCompile) {
return;
}

Expand Down

0 comments on commit 0a73165

Please sign in to comment.