dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.44k stars 361 forks source link

Add Default Labels to `FromDockerfile ` #4523

Open afscrome opened 1 month ago

afscrome commented 1 month ago

Follow on from https://github.com/dotnet/aspire/issues/4346#issuecomment-2169204891.

When building images with FromDockerfile, we should consider adding some default labels to the image.

This could include open container labels, similar to those the Dotnet SDK , as well as some aspire specific labels (e.g. project name, resource name, aspire version). The aspire specific labels should be consistent with #4425.

radical commented 1 month ago

cc @mitchdenny

mitchdenny commented 1 month ago

@afscrome we just got some updated capabilities from DCP to support adding labels to containers so it looks like we might be able to do this. What kind of labels would you find useful.

We'd also accept a PR for this if you are interested!

Alirexaa commented 2 weeks ago

Hi @mitchdenny, are there any documents about DCP? I want to take this issue, but I can not find any docs about DCP to start this.

mitchdenny commented 2 weeks ago

@Alirexaa DCP is closed source at this point in time. However the labels properties are exposed here:

https://github.com/dotnet/aspire/blob/2249f7d4d114784ed4f117a60b1b2963d971bd92/src/Aspire.Hosting/Dcp/Model/Container.cs#L54

If you were to update the ApplicationExecutor.cs to populate labels they should show up in Docker.