support multi arch build

This commit is contained in:
David Hiendl 2023-12-02 22:10:37 +01:00
parent 9d76cc2074
commit 56f48b78ce
3 changed files with 24 additions and 4 deletions

View File

@ -80,8 +80,8 @@ inputs:
description: "" description: ""
default: "1" default: "1"
docker_multi_arch: docker_arch_list:
description: "" description: "if set to true use linux/amd64,linux/arm64, otherwise specifiy arch list manually"
default: "false" default: "false"
dockerfile: dockerfile:

12
dist/index.js vendored
View File

@ -62251,6 +62251,17 @@ function prepareDockerArgs(destinations) {
dockerArgs.unshift(getDockerContextDir()); dockerArgs.unshift(getDockerContextDir());
if (isNonEmptyStr(core.getInput('docker_arch_list'))) {
if (!core.getBooleanInput('use_buildx')) {
throw new Error('Unsupported configuration: Cannot build multiarch without enabling buildx');
}
let archList = (core.getInput('docker_arch_list'));
if (archList === 'true' || archList === '1') {
archList = 'linux/amd64,linux/arm64';
}
dockerArgs.push('--platform ' + archList);
}
if (core.getBooleanInput('squash_layers')) { if (core.getBooleanInput('squash_layers')) {
dockerArgs.push('--squash'); dockerArgs.push('--squash');
} }
@ -62300,7 +62311,6 @@ function executeDockerBuild(dockerArgs, destinations) {
throw new Error('docker build failed'); throw new Error('docker build failed');
} }
console.log('proc error check'); // TODO remove debug
if (proc.error != null) { if (proc.error != null) {
throw proc.error; throw proc.error;
} }

View File

@ -149,6 +149,17 @@ export function prepareDockerArgs(destinations) {
dockerArgs.unshift(getDockerContextDir()); dockerArgs.unshift(getDockerContextDir());
if (isNonEmptyStr(core.getInput('docker_arch_list'))) {
if (!core.getBooleanInput('use_buildx')) {
throw new Error('Unsupported configuration: Cannot build multiarch without enabling buildx');
}
let archList = (core.getInput('docker_arch_list'));
if (archList === 'true' || archList === '1') {
archList = 'linux/amd64,linux/arm64';
}
dockerArgs.push('--platform ' + archList);
}
if (core.getBooleanInput('squash_layers')) { if (core.getBooleanInput('squash_layers')) {
dockerArgs.push('--squash'); dockerArgs.push('--squash');
} }
@ -198,7 +209,6 @@ export function executeDockerBuild(dockerArgs, destinations) {
throw new Error('docker build failed'); throw new Error('docker build failed');
} }
console.log('proc error check'); // TODO remove debug
if (proc.error != null) { if (proc.error != null) {
throw proc.error; throw proc.error;
} }