vscode-docker icon indicating copy to clipboard operation
vscode-docker copied to clipboard

Create and use `${packageName}:${packageVersion}` for Node.js image tag

Open karolz-ms opened this issue 5 years ago • 4 comments

This was reproduced on Windows 10 2004, WSL2 Docker Desktop 2.3.0.0, Docker extension version 1.2.0, VS Code version 1.45.1

Repro steps:

  1. Create a simple Node.js app
  2. Scaffold Docker files using VS Code Docker extension
  3. Ensure that package.json has both name and version properties set (e.g. guestbook-express and 1.0.0, respectively).
  4. Run docker-build task

Expected: the resulting image should be tagged as guestbook-express:1.0.0--at least that was the intent of the design https://code.visualstudio.com/docs/containers/reference#_nodejs-dockerbuild Actual: the resulting image is tagged as guestbookexpress:latest (note wrong tag and removed hyphen in the name).

Further problem: 5. Open tasks.json and set dockerBuild.tag property to guestbook-express:1.0.0 6. Run docker-build task again

Expected: the resulting image should be tagged as the task parameters say it should Actual: nope, it is still guestbookexpress:latest 😠

karolz-ms avatar May 26 '20 01:05 karolz-ms

@karolz-ms For now at least it's intentional that we do not use package.json's version though that's a reasonable change we could make. The most appropriate way to do it would be variable substitution, e.g.

"dockerBuild": {
    "tag": "${packageName}:${packageVersion}"
}

The design says it will reuse the package.json name (which it does, though it removes dashes [another reasonable change we could make]), but does not say it will reuse the version.

I propose we use this issue to make two changes:

  1. Allow dashes in the image name wherever they are appropriate (which is anywhere in the middle of the tag/image name, i.e. not the first or last character).
  2. Create the above variable substitution parameters, and use them as the default tag. Continue to use package.json name + :latest if there is nothing specified, so that those with previously-scaffolded Node.js docker-build tasks do not encounter issues from changed behavior.

I was not able to reproduce second issue: image image image

bwateratmsft avatar May 26 '20 13:05 bwateratmsft

The "further problem" (steps 5 and 6) are a dup of https://github.com/microsoft/vscode/issues/98617

karolz-ms avatar May 26 '20 23:05 karolz-ms

@bwateratmsft your proposal sounds very good to me

karolz-ms avatar May 26 '20 23:05 karolz-ms

@karolz-ms Ok, I'll change the title to reflect what this bug is now about. :smile:

bwateratmsft avatar May 27 '20 13:05 bwateratmsft