Why you no longer need a Dockerfile in .NET 7

preview_player
Показать описание
Until the 28th of Nov 2022 use discount code BF2022 for up to 25% off

Hello everybody I'm Nick and in this video I will show you the Docker related updated that Microsoft added in the .NET 7 SDK. You no longer need a Dockerfile to specify how your project should be built.

Don't forget to comment, like and subscribe :)

Social Media:

#csharp #dotnet #docke
Рекомендации по теме
Комментарии
Автор

I don't like "magic" like this, where they hide actual implementation. I would consider it good if it generated dockerfile the way like source generators do so I can view it and really understand what's going on.

lordicemaniac
Автор

You are my source for keeping up with my tech stack. Thank you for showing me this cool new .NET 7 feature!

cokobware
Автор

Whether you are managing the csproj file or a docker file, I see no difference. I do like what MS is doing and I appreciate it, but I am a fan of having a separate Dockerfile, also sometimes you might have 2 or more Dockerfiles in a project for different environments that you'd like your application to run in.

RoughSubset
Автор

This is one of those things that I hope don’t really catch on. I’m very positive about dotnet’s other changes, but I think a dotnet specific way to interact with Docker isn’t going to be good long term.

Denominus
Автор

Super cool to see my team's feature on a Nick Chapsas video. Tons of engagement in the comments that I'll go through and respond to, but to cover the common questions:

* No, we don't want to replace docker files for everyone! We want to reduce friction and get rid of the 80% docker files that had no value. If you have specific needs (native libraries, integration with tooling that expects Docker files), then definitely still keep that! Just like NoSQL means 'not only' SQL, there's a broad ecosystem of container-adjacent tools that work like this new tool does (e.g. ko for golang, and jib for Java). This is just that, for .NET!
* It's really really fast in comparison :) makes me happy every time I build a container.
* It does work with alternative container runtimes like podman and nerdctl. I have explicitly manually tested these, and they remain part of our goals. I'd like to expand our support for them in the future.
* I think if project files had better intellisense it would be a nicer experience overall. I have plans in this space (I'm also the MSBuild PM), but nothing concrete yet.

Glad you had a good time with it, Nick, and thanks for the highlight :)

ChetHusk
Автор

The purpose of having the dockerfile in the project directorx is that you can build multiple projects from the same build context. Say you have two projects in a solution, you can now build both using docker build -f project1 . and docker build -f project2 .

cn-ml
Автор

Excellent new feature in net 7 Thanks for this explanation Nick 👍

adiazwise
Автор

Another nugget of Nick Chapsas GOLD! Thanks Nick!

DuelingTreeMike
Автор

You can keep the Dockerfile in the project folder and run it from the solution directory using -f option in docker command, the context of the Dockerfile while be the solution directory. In this way you can use project reference (dotnet add reference) inside the container, you juste need to tel to your Dockerfile which project to copy from Host to the container (you can because the context is the solution dir not the project one)

thewrath
Автор

Genuine questions II have to deal with in my company:

- What if I want to duplicate base docker file configs for other stacks that are not in C# but are shared between projects?
- What if I want separate dev config from deploy config (ie. sqlite on local and postgres in prod) (docker-compose)?
- What if I want to inject from .env files config like keys/secrets or native templates that I rather have seprate, how is the support for this (docker-compose)?
- If Docker gets updated, do I now have to wait on Microsoft's release schedule to add an interface to bind to this property in their own file?
- Why do you start writing docker config in a .cs file but with more characters (xml-ish vs yaml), I thought your point was to write less?
- How does this work with docker-compose in general?
- How much of Docker & Docker Compose config can it bind to?
- What if my company takes on a legacy project where they work with exising Docker files in an *Existing team*, why should I now make things harder for the collab team without any to little advantage.

Dockerfile seems an odd one to optimize in general. I re-use base files I get from DevOps, they hardly grow to a size that is unreadable, and they also rarely change. Unless u visually don't like the look of it in ur file system, it seems over optimising for little benefit, as you don't work on them in day-to-day operations anyway

xdarrenx
Автор

Ok it has a lot of customization but at that point it's so much text you might as well use the Dockerfile! Why learn a new syntax and lock in to the microsoft feature when you can just use Dockerfile?

Crozz
Автор

Would you consider making a video about TPL with threadpool interactions, execution context, async state machine and all things related and how you can easily run into thread pool starvation if you misuse these techniques?
It's easy to find superficial explainations about these topics on the web, but an indepth guide to everything async would be really valuable I think!

EikeSchwass
Автор

If your dockerfile is anemic, yes. But in my case a run a lot of things like tests, private nuget and format

viniciusbeloni
Автор

Thanks for sharing. I still prefer using Docker Compose to configure everything in one place and for multiple applications as in the Clean Architecture Example you mentioned. I think Docker Init makes it very easy to getting started with autogenerating the docker and docker compose files.

Harody
Автор

Great tutorial!! Best on youtube about this topic.

monicadallapria
Автор

Hi Nick, great video as usual. Can you please share the official documentation ?

Guillen
Автор

i don't know, perhaps i'm old fashion but i prefer the docker image approach. For example in my use case i have to install the datadog agent and the grpc-health-probe via curl and i don't want go crazy on the csproj configuration

Eldest
Автор

One nice thing about this, if they implemented it correctly of course from the MS side, is that this way layering can be done for you and you are less likely to mess up. Wrong layering can fill up an artifact storage quite quickly..

I like the idea, not sure if I like how it is split between Item and Property groups. Maybe this should actually not be part of the csproj at all or optionally can be pulled out 🤔
Imho, don’t want this to become a mess like the poms in Java projects..

ArchaicFlux
Автор

If this would also produce a dockerfile, I'd be more into it I think. Then it would be more of a syntactic sugar which is perfectly fine. Removing it from view completely is like to cause more problems/complexity than it solves for larger organizations.

dennycrane
Автор

@nickchapsas can you put a page up on your website that links all of the cool tools, extensions and shells you use in your videos? I am finding I want to use some things you use, but don't know where to find them to try them out!

cokobware