Skip to content

Commit

Permalink
fix(toolkit): correctly pass build args to docker build (#2634)
Browse files Browse the repository at this point in the history
The option name (`--build-arg`) and value should be passed as separate array items.
  • Loading branch information
jogold authored and rix0rrr committed May 24, 2019
1 parent 6450758 commit 9c58d6f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/aws-cdk/lib/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ export async function prepareContainerAsset(asset: ContainerImageAssetMetadataEn
}
}

const buildArgs = ([] as string[]).concat(...Object.entries(asset.buildArgs || {}).map(([k, v]) => ['--build-arg', `${k}=${v}`]));
const baseCommand = [
'docker', 'build',
...Object.entries(asset.buildArgs || {}).map(([k, v]) => `--build-arg ${k}=${v}`),
...buildArgs,
'--tag', latest,
asset.path
];
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/test/test.docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export = {
}

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

prepareEcrRepositoryStub.restore();
Expand Down

0 comments on commit 9c58d6f

Please sign in to comment.