dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.47k stars 10.03k forks source link

Dockerfile support in webapi template? #5429

Open omerlh opened 6 years ago

omerlh commented 6 years ago

Adding sample docker file the can be used to deploy the app (based on one of the official samples) could make it a lot easier for people who start with .NET and want to run their code on Docker.
I find myself many times just copy an existing dockerfile from another project, or from the official samples. If that makes sense, I would be happy to open a pull request.

mkArtakMSFT commented 6 years ago

Thanks for contacting us, @omerlh. @glennc, @danroth27 what do you think guys?

mkArtakMSFT commented 6 years ago

@omerlh, it seems docker support is already available for Web API projects. You can enable it on project creation or add Docker support after the project is created using the right click gesture on the project.

mkArtakMSFT commented 6 years ago

@omerlh, wondering why don't you have the option. What version of VS are you using? It's available on VS 2017.

omerlh commented 6 years ago

I'm using the dotnet new command - how can I test it? I've looked in the code and didn't noticed it - this is why I've opened an issue...

mkArtakMSFT commented 6 years ago

I see. So this is really an ask to make it as part of the default Web API template. I don't think that's a change we want to make, but I will rely on @danroth27 and @glennc to make the decision.

omerlh commented 6 years ago

May I ask why not?

danroth27 commented 6 years ago

@glennc Has there been any thinking done about creating a CLI experience for adding docker support to ASP.NET Core projects like we have in VS?

glennc commented 6 years ago

Let me clarify a couple of things to make sure everyone is on the same page. The right click gesture in VS comes from the docker tooling team, it does more than just having a docker file it configures your project to allow F5 debugging into your app inside the container.

We have talked a lot about having a Dockerfile as an option when creating ASP.NET Core projects. Initially we didn't do it because the VS tooling had no way of knowing if we created the Dockerfile or not, which meant if you used the CLI option you wouldn't be able to use the VS option without deleting and re-creating all the files. AFAIK that bug is now fixed. After that we wanted an experience where you could do dotnet new --docker and get a good default dockerfile with an extended syntax of dotnet new --docker=windows or something like that to determine which OS base you wanted. Support for that wasn't available in the templating engine until, I think, the last release. Last I looked at this I had gotten that feature added but hadn't come back to it.

So after all that. Yes we should have a Dockerfile as part of our templates that you can generate when creating a template. But it needs to be behind a switch and you have to be able to choose between Windows and Linux containers. The contents of the file also shouldn't be significantly different to what you would get from the VS option. Once we have the option here we should talk to the VS tooling team to have them defer to our option to add the Dockerfile, which presumably means an item template for addition of the Dockerfile after the project has been created. Right?

Nothing's as easy at is it seems ;)

omerlh commented 6 years ago

Thanks for clarifying :) So, to summarize, can we say this is on the roadmap and will be available sometime in the future?

mkArtakMSFT commented 6 years ago

Your understanding is correct, @omerlh.

mkArtakMSFT commented 4 years ago

VS now lets you add We've moved this issue to the Backlog milestone. This means that it is not going to happen for the coming release. We will reassess the backlog following the current release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.