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 Apr 30, 2024
1 parent c1c8b08 commit 9b10555
Show file tree
Hide file tree
Showing 3 changed files with 27 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
15 changes: 15 additions & 0 deletions src/test/cli.build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ describe('Dev Containers CLI', function () {

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

it('should fail to push --image-name with --push true', async () => {
let success = false;
const testFolder = `${__dirname}/configs/example-push`;
try {
await shellExec(`${cli} build --workspace-folder ${testFolder} --image-name demo:v1 --push true`);
} catch (error) {
assert.equal(error.error.code, 1, 'Should fail with exit code 1');
const res = JSON.parse(error.stdout);
assert.equal(res.outcome, 'error');
assert.match(JSON.stringify(error.error.message), /unauthorized: access token has insufficient scopes/);
assert.match(JSON.stringify(error.error.message), /pushing demo:v1 with docker/);
}
assert.equal(success, false, 'expect non-successful call');
});

buildKitOptions.forEach(({ text, options }) => {
it(`should execute successfully with valid image config [${text}]`, async () => {
const testFolder = `${__dirname}/configs/image`;
Expand Down
10 changes: 10 additions & 0 deletions src/test/configs/example-push/.devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Example devcontainer.json configuration,
// wired into the vscode launch task (.vscode/launch.json)
{
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "16.18.1"
}
}
}

0 comments on commit 9b10555

Please sign in to comment.