DockerComposeServiceExtensions Methods
ClassMethods4 members
Provides extension methods for customizing Docker Compose service resources.
AsEnvironmentPlaceholder(IManifestExpressionProvider, DockerComposeServiceResource)Section titled AsEnvironmentPlaceholder(IManifestExpressionProvider, DockerComposeServiceResource)extensionstring Creates a placeholder for an environment variable in the Docker Compose file.
public static class DockerComposeServiceExtensions{ public static string AsEnvironmentPlaceholder( this IManifestExpressionProvider manifestExpressionProvider, DockerComposeServiceResource dockerComposeService) { // ... }}Parameters
manifestExpressionProviderIManifestExpressionProviderThe manifest expression provider.dockerComposeServiceDockerComposeServiceResourceThe Docker Compose service resource to associate the environment variable with.Returns
stringA string representing the environment variable placeholder in Docker Compose syntax (e.g., ${ENV_VAR}).Remarks
This overload is not available in polyglot app hosts because
ApplicationModel.IManifestExpressionProvider is not ATS-compatible.AsEnvironmentPlaceholder(IResourceBuilder<ParameterResource>, DockerComposeServiceResource)Section titled AsEnvironmentPlaceholder(IResourceBuilder<ParameterResource>, DockerComposeServiceResource)extensionstring Creates a Docker Compose environment variable placeholder for the specified
ApplicationModel.ParameterResource. public static class DockerComposeServiceExtensions{ public static string AsEnvironmentPlaceholder( this IResourceBuilder<ParameterResource> builder, DockerComposeServiceResource dockerComposeService) { // ... }}Parameters
builderIResourceBuilder<ParameterResource>The resource builder for the parameter resource.dockerComposeServiceDockerComposeServiceResourceThe Docker Compose service resource to associate the environment variable with.Returns
stringA string representing the environment variable placeholder in Docker Compose syntax (e.g., ${ENV_VAR}).Remarks
Use this overload with parameter builders returned by methods such as
ParameterResourceBuilderExtensions.AddParameter. AsEnvironmentPlaceholder(ParameterResource, DockerComposeServiceResource)Section titled AsEnvironmentPlaceholder(ParameterResource, DockerComposeServiceResource)extensionstring Creates a Docker Compose environment variable placeholder for this
ApplicationModel.ParameterResource. public static class DockerComposeServiceExtensions{ public static string AsEnvironmentPlaceholder( this ParameterResource parameter, DockerComposeServiceResource dockerComposeService) { // ... }}Parameters
parameterParameterResourceThe parameter resource for which to create the environment variable placeholder.dockerComposeServiceDockerComposeServiceResourceThe Docker Compose service resource to associate the environment variable with.Returns
stringA string representing the environment variable placeholder in Docker Compose syntax (e.g., ${ENV_VAR}).Remarks
This overload is not available in polyglot app hosts. Use the builder or manifest-expression overload instead.
PublishAsDockerComposeService(IResourceBuilder<T>, Action<DockerComposeServiceResource, Service>)Section titled PublishAsDockerComposeService(IResourceBuilder<T>, Action<DockerComposeServiceResource, Service>)extensionIResourceBuilder<T> Publishes the specified resource as a Docker Compose service.
public static class DockerComposeServiceExtensions{ public static IResourceBuilder<T> PublishAsDockerComposeService<T>( this IResourceBuilder<T> builder, Action<DockerComposeServiceResource, Service> configure) { // ... }}Parameters
builderIResourceBuilder<T>The resource builder.configureAction<DockerComposeServiceResource, Service>The configuration action for the Docker Compose service.Returns
IResourceBuilder<T>The updated resource builder.Remarks
This method checks if the application is in publish mode. If it is, it adds a customization annotation that will be applied by the DockerComposeInfrastructure when generating the Docker Compose service.
builder.AddContainer( "redis", "redis:alpine").PublishAsDockerComposeService((resource, service) =>{ service.Name = "redis";});