Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redundant dockerfile issue with build #812

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 14 additions & 0 deletions src/test/cli.build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ 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 {
await shellExec(`${cli} build --workspace-folder ${testFolder} --image-name demo:v1`);
const tags = await shellExec(`docker images --format "{{.Tag}}" demo`);
const imageTags = tags.stdout.trim().split('\n').filter(tag => tag !== '<none>');
if (imageTags.length === 1) {
assert.ok(false, 'should not succeed');
}
prathameshzarkar9 marked this conversation as resolved.
Show resolved Hide resolved
} catch (error) {
assert.equal(error.code, 'ERR_ASSERTION', 'Should fail with ERR_ASSERTION');
}
});
prathameshzarkar9 marked this conversation as resolved.
Show resolved Hide resolved

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