microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
173 stars 26 forks source link

Unable to push an image to a repository with multiple image tags #412

Open amammes opened 5 months ago

amammes commented 5 months ago

My app is C# Asp.Net 8.0.1 - VS2022 Version 17.9.0 Preview 3.0.

I would like to publish my image with multiple tags using a single pubxml, for example:

projectname:1
projectname:1.2
projectname:1.2.3
projectname:latest
projectname:{{last_git_commit_sha}}

Among several tests, I tried putting this in the pubxml, but only the last tag is used.

<PublishImageTag>1</PublishImageTag>  
<PublishImageTag>1.2</PublishImageTag>  
<PublishImageTag>1.2.3</PublishImageTag>  

I believe this requires calling docker tag and docker push in a loop, once for each tag. Been trying to figure out a way to do this for a couple of days. Is there a way to do this directly from csproj, pubxml, and/or Dockerfile? Thanks

dbreshears commented 5 months ago

I don't believe there is any way to handle this currently in csproj, pubxml, and/or Dockerfile. I would recommend to log a suggestion for this at https://developercommunity.visualstudio.com/VisualStudio/suggest and it will get routed to the team that owns Publish.

amammes commented 5 months ago

Is there a way to do this directly from csproj, pubxml, and/or Dockerfile?

That suggestion page does not work. Whatever I do, after clicking submit it says "Unexpected error" "Sign-in required. Please sign-in again and retry.". But I AM signed in with my Microsoft account. I tried from Chrome, Chrome incognito and Edge, all fail the same way

dbreshears commented 5 months ago

Unfortanate timing, I think there may have been an outage. Feel free to try again later, however I opened a suggestion directly on the internal backlog with a link to this.

NCarlsonMSFT commented 5 months ago

@amammes I did some digging: while the publish experience in VS does not have support for this, if you are willing to use the new container image publish feature in the .NET SDK they do provide a property for specifying multiple image tags ContainerImageTags.

Note: Support for debugging SDK published containers is only in 17.9+ which is still in Preview. Note2: I tested how our debugging support handles the ContainerImageTags property and found it caused a conflict. but you can work-around it with a condition:
<ContainerImageTags Condition="'$(ContainerImageTag)' == ''">tag1;tag2</ContainerImageTags>