dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.92k stars 479 forks source link

Add Default Labels to `FromDockerfile ` #4523

Open afscrome opened 5 months ago

afscrome commented 5 months 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 5 months ago

cc @mitchdenny

mitchdenny commented 5 months 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 4 months 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 4 months 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.