assembled docker args

This commit is contained in:
2023-12-02 21:52:09 +01:00
parent ae96735c11
commit 9d76cc2074
4 changed files with 59 additions and 9 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ try {
console.log('dockerArgs:', JSON.stringify(dockerArgs, null, 2));
}
executeDockerBuild(dockerArgs);
executeDockerBuild(dockerArgs, destinations);
}
catch (error) {
console.log('Failed to build docker image', error);
+28 -3
View File
@@ -164,16 +164,41 @@ export function prepareDockerArgs(destinations) {
return dockerArgs;
}
export function executeDockerBuild(dockerArgs) {
export function executeDockerBuild(dockerArgs, destinations) {
const dockerArgsStr = dockerArgs.join(' ');
const dockerSubCmd = core.getBooleanInput('use_buildx') ? 'buildx build' : 'build';
const isBuildX = core.getBooleanInput('use_buildx');
let dockerSubCmd = isBuildX ? 'buildx build' : 'build';
if (core.getBooleanInput('docker_push')) {
dockerSubCmd += ' --push';
}
const execStr = `docker ${dockerSubCmd} ${dockerArgsStr}`;
console.log(`executing: ${execStr}`);
const proc = child_process.spawnSync(`docker ${dockerSubCmd} ${dockerArgsStr}`, {
const proc = child_process.spawnSync(execStr, {
shell: true,
stdio: 'inherit',
cwd : getDockerContextDir()
});
// push for legacy builder
// if (!isBuildX && core.getBooleanInput('docker_push')) {
// destinations.forEach(dst => {
// const pushProc = child_process.spawnSync('docker push ' + dst, {
// shell: true,
// stdio: 'inherit',
// cwd : getDockerContextDir()
// });
// if (pushProc.status != null && pushProc.status > 0) {
// throw new Error('docker push ' + dst + ' failed');
// }
// });
// }
if (proc.status != null && proc.status > 0) {
throw new Error('docker build failed');
}
console.log('proc error check'); // TODO remove debug
if (proc.error != null) {
throw proc.error;
}