Skip to content

Commit

Permalink
redundant dockerfile issue with build
Browse files Browse the repository at this point in the history
  • Loading branch information
prathameshzarkar9 committed May 15, 2024
1 parent c1c8b08 commit f90f8a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/spec-node/containerFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ export async function extendImage(params: DockerResolverParameters, config: Subs
cliHost.mkdirp(emptyTempDir);
args.push(
'--target', featureBuildInfo.overrideTarget,
'-t', updatedImageName,
...additionalImageNames.map(name => ['-t', name]).flat(),
'-f', dockerfilePath,
...additionalImageNames.length > 0 ? additionalImageNames.map(name => ['-t', name]).flat() : ['-t', updatedImageName],
emptyTempDir
);

Expand All @@ -125,7 +124,7 @@ export async function extendImage(params: DockerResolverParameters, config: Subs
await dockerCLI(infoParams, ...args);
}
return {
updatedImageName: [ updatedImageName ],
updatedImageName: additionalImageNames.length > 0 ? additionalImageNames : [updatedImageName],
imageMetadata: getDevcontainerMetadata(imageBuildInfo.metadata, config, featuresConfig),
imageDetails: async () => imageBuildInfo.imageDetails,
};
Expand Down
16 changes: 16 additions & 0 deletions src/test/cli.build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ describe('Dev Containers CLI', function () {

describe('Command build', () => {

it('should correctly configure the image name to push from --image-name with --push true', async () => {
const testFolder = `${__dirname}/configs/example`;
try {
const tags = await shellExec(`docker images --format "{{.Tag}}" demo`);
const imageTags = tags.stdout.trim().split('\n').filter(tag => tag !== '<none>');
if (imageTags.length > 1) {
console.log(`Image demo has more than one tag: ${imageTags.join(', ')}`);
} else {
await shellExec(`${cli} build --workspace-folder ${testFolder} --image-name demo:v1`);
assert.ok(false, 'should not succeed');
}
} catch (error) {
assert.equal(error.code, 'ERR_ASSERTION', 'Should fail with ERR_ASSERTION');
}
});

buildKitOptions.forEach(({ text, options }) => {
it(`should execute successfully with valid image config [${text}]`, async () => {
const testFolder = `${__dirname}/configs/image`;
Expand Down

0 comments on commit f90f8a7

Please sign in to comment.