microsoft / microsoft/aspire

Customize the base image for project resources

Open
#13,143 3 comments 6 reactions 0 assignees View on GitHub
area-app-model
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

It's not easily possible to customize the docker image created by `/t:PublishContainer` for project resources. For example, if you need to `apt install` some fonts, you need to take full control over the build and deploy steps.

Alternatively, you can specify a custom runtime base image, but then you need to setup the infrastructure to maintain that.

``` C#
var webapp = builder.AddProject("webapp")
.WithDockerfileBaseImage(runtimeImage: "myregistry.dev/aspnet:10.0-noble-with-extras");
```

### Describe the solution you'd like

It would be cool if you could pass in a `ContainerResource` reference to `WithDockerfileBaseImage`.

``` C#
var runtimeBase = builder.AddDockerfileBuilder("myruntimebase", "path/to/context", dockerfile =>
{
dockerfile.Builder
.From("mcr.microsoft.com/dotnet/aspnet:10.0-noble")
.Run("apt-get update && apt-get install -y fonts-dejavu && rm -rf /var/lib/apt/lists/*")
.Copy("./vendor-libs/", "/var/lib/");
});

var webapp = builder.AddProject("webapp")
.WithDockerfileBaseImage(runtimeImage: runtimeBase);
```

### Additional context

https://discord.com/channels/1361488941836140614/1442135030599123098

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.