Skip to content

Commit 9c58d6f

Browse files
jogoldrix0rrr
authored andcommitted
fix(toolkit): correctly pass build args to docker build (#2634)
The option name (`--build-arg`) and value should be passed as separate array items.
1 parent 6450758 commit 9c58d6f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/aws-cdk/lib/docker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ export async function prepareContainerAsset(asset: ContainerImageAssetMetadataEn
5757
}
5858
}
5959

60+
const buildArgs = ([] as string[]).concat(...Object.entries(asset.buildArgs || {}).map(([k, v]) => ['--build-arg', `${k}=${v}`]));
6061
const baseCommand = [
6162
'docker', 'build',
62-
...Object.entries(asset.buildArgs || {}).map(([k, v]) => `--build-arg ${k}=${v}`),
63+
...buildArgs,
6364
'--tag', latest,
6465
asset.path
6566
];

packages/aws-cdk/test/test.docker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export = {
9292
}
9393

9494
// THEN
95-
const command = ['docker', 'build', '--build-arg a=b', '--build-arg c=d', '--tag', `uri:latest`, '/foo'];
95+
const command = ['docker', 'build', '--build-arg', 'a=b', '--build-arg', 'c=d', '--tag', `uri:latest`, '/foo'];
9696
test.ok(shellStub.calledWith(command));
9797

9898
prepareEcrRepositoryStub.restore();

0 commit comments

Comments
 (0)