Skip to content

Allow pull_policy to be defined for the docker compose published services #13793

@Kuurama

Description

@Kuurama

Is there an existing issue for this?

  • I have searched the existing issues

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

When having a basic deployment to docker compose using Aspire.Hosting.Docker 13.1.0 preview,
I would like to be able to configure the published services pull_policy:

builder.AddDockerComposeEnvironment("myproj-env")
services:
  api:
    image: "${API_IMAGE}"
    pull_policy: always
    environment:

When using dotnet aspire within a CI/CD pipeline, and uploading the images to ghcr.io or docker hub with the latest tag. We can't control if the images will be always pulled on docker compose up.

Because docker compose up might not pull the images without that field. (I use dokploy for deployment, and have to use this pull_policy: always for my images to get pulled when they use the same latest tag, because most of it it automated).

The current fix is to push the generated docker compose with the pull_policy happended manually, and only change it when you need to regenerate it. But I still think there should be a method to set it on a docker compose service.

Describe the solution you'd like

I'm not too sure if that's the correct place to put this settings, but given the description of the classes, maybe something like this fits:

builder.AddProject<Foo>("foo")
.PublishAsDockerComposeService((dockerComposeServiceResource, service) => service.PullPolicy = ImagePullPolicy.Always);

It might be just like adding the following to the Aspire.Hosting.Docker.Resources.ComposeNodes.Service class:

[YamlMember(Alias = "pull_policy", SerializeAs = typeof(string))]
public ImagePullPolicy? PullPolicy { get; set; }

// With ImagePullPolicy namespace being the existing Aspire.Hosting.ApplicationModel.ImagePullPolicy enum.

(I don't know if the provided code is how the yaml mapping works, but perhaps it can help describing the api in more details).

Additional context

No response

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions