Support AsEnvironmentPlaceholder on DockerComposeEnvironmentResource
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 201
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.
`AsEnvironmentPlaceholder` currently only accept `DockerComposeServiceResource` (only used to resolve `DockerComposeEnvironmentResource` through the `Parent` property). This limits it to the `PublishAsDockerComposeService` method. It would be great if it's possible to add `ParameterResource` to the environment directly through `var compose = builder.AddDockerComposeEnvironment("compose")`.
### Describe the solution you'd like
Refactor to use `public static string AsEnvironmentPlaceholder(..., DockerComposeEnvironmentResource dockerComposeService)` internally to avoid code duplication.
### Additional context
`DockerComposeEnvironmentResource.AddEnvironmentVariable` is currently `internal` and I found no other proper way to add more things to `.env` through Aspire. I have a registry prefix and version tag that I want to add to some images. As it's project references, it will still generate environment variables for the image (even when not used in the compose as it's just adding the string directly to the compose).
I'm using ``
Contributor guide
Research direction
Start with AsEnvironmentPlaceholder, DockerComposeEnvironmentResource, and PublishAsDockerComposeService, then inspect how AddEnvironmentVariable is used. Confirm the environment resource can accept a ParameterResource directly and that the generated Docker Compose .env values remain correct without duplicating the existing service-resolution behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, docker-compose
- Domain
- devops
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100