ContainerResource

Handle
📦 Aspire.Hosting v17.0.0
interface ContainerResource
extends IComputeResource,
IResource,
IResourceWithArgs,
IResourceWithEndpoints,
IResourceWithEnvironment,
IResourceWithProbes,
IResourceWithWaitSupport {
publishAsConnectionString(): ContainerResource;
publishAsContainer(): ContainerResource;
withBindMount(
source: string,
target: string,
isReadOnly?: boolean): ContainerResource;
withBuildArg(
name: string,
value: string | ParameterResource): ContainerResource;
withBuildSecret(
name: string,
value: ParameterResource): ContainerResource;
withContainerCertificatePaths(
customCertificatesDestination?: string,
defaultCertificateBundlePaths?: string[],
defaultCertificateDirectoryPaths?: string[]): ContainerResource;
withContainerFiles(
destinationPath: string,
sourcePath: string,
options?: ContainerFilesOptions): ContainerResource;
withContainerFilesCallback(destinationPath: string, callback: (arg1: ContainerFileSystemCallbackContext, arg2: cancellationToken) => Promise<ContainerFileSystemItem[]>, options?: ContainerFilesOptions): ContainerResource;
withContainerName(name: string): ContainerResource;
withContainerNetworkAlias(alias: string): ContainerResource;
withContainerRuntimeArgs(args: string[]): ContainerResource;
withDockerfile(
contextPath: string,
dockerfilePath?: string,
stage?: string): ContainerResource;
withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise<void>, stage?: string): ContainerResource;
withDockerfileFactory(contextPath: string, dockerfileFactory: (arg: DockerfileFactoryContext) => Promise<string>, stage?: string): ContainerResource;
withEntrypoint(entrypoint: string): ContainerResource;
withImage(
image: string,
tag?: string): ContainerResource;
withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResource;
withImageRegistry(registry: string): ContainerResource;
withImageSHA256(sha256: string): ContainerResource;
withImageTag(tag: string): ContainerResource;
withLifetime(lifetime: ContainerLifetime): ContainerResource;
withVolume(
target: string,
name?: string,
isReadOnly?: boolean): ContainerResource;
}

Methods

Changes the resource to be published as a connection string reference in the manifest.
publishAsConnectionString(): ContainerResource
ContainerResource
methodpublishAsContainerbuilder
Changes the resource to be published as a container in the manifest.
publishAsContainer(): ContainerResource
ContainerResource
methodwithBindMountbuilder
Adds a bind mount to a container resource.
withBindMount(
source: string,
target: string,
isReadOnly?: boolean): ContainerResource
sourcestringThe source path of the mount. This is the path to the file or directory on the host, relative to the AppHost project directory.
targetstringThe target path where the file or directory is mounted in the container.
isReadOnlybooleanoptional= FalseA flag that indicates if this is a read-only mount.
ContainerResource
methodwithBuildArgbuilder
Adds a build argument when the container is built from a Dockerfile.
withBuildArg(
name: string,
value: string | ParameterResource): ContainerResource
namestringThe name of the build argument.
valuestring | ParameterResourceThe build argument value, either a string or a parameter resource.
ContainerResource
methodwithBuildSecretbuilder
Adds a secret build argument when the container is built from a Dockerfile.
withBuildSecret(
name: string,
value: ParameterResource): ContainerResource
namestringThe name of the secret build argument.
valueParameterResourceThe resource builder for a parameter resource.
ContainerResource
Adds container certificate path overrides used for certificate trust at run time.
withContainerCertificatePaths(
customCertificatesDestination?: string,
defaultCertificateBundlePaths?: string[],
defaultCertificateDirectoryPaths?: string[]): ContainerResource
customCertificatesDestinationstringoptionalThe destination path in the container where custom certificates will be copied.
defaultCertificateBundlePathsstring[]optionalDefault certificate bundle paths in the container that will be replaced.
defaultCertificateDirectoryPathsstring[]optionalDefault certificate directory paths in the container that may be appended.
ContainerResource
methodwithContainerFilesbuilder
Creates or updates files and folders in a container by copying them from a source path on the host.
withContainerFiles(
destinationPath: string,
sourcePath: string,
options?: ContainerFilesOptions): ContainerResource
destinationPathstringThe destination absolute path in the container.
sourcePathstringThe source path on the host to copy files from.
optionsContainerFilesOptionsoptionalOptions for the created or updated file system entries.
ContainerResource
Creates or updates files and/or folders at the destination path in the container using entries produced by a callback.
withContainerFilesCallback(destinationPath: string, callback: (arg1: ContainerFileSystemCallbackContext, arg2: cancellationToken) => Promise<ContainerFileSystemItem[]>, options?: ContainerFilesOptions): ContainerResource
destinationPathstringThe destination absolute path in the container.
callback(arg1: ContainerFileSystemCallbackContext, arg2: cancellationToken) => Promise<ContainerFileSystemItem[]>A callback that returns the file system entries to create or update. Use the factory methods on `ContainerFileSystemCallbackContext` (createFile, createDirectory, createCertificateFile) to build the entries.
optionsContainerFilesOptionsoptionalOptions for the created or updated file system entries.
ContainerResource
methodwithContainerNamebuilder
Overrides the default container name for this resource. By default Aspire generates a unique container name based on the resource name and a random postfix (or a postfix based on a hash of the AppHost project path for persistent container resources). This method allows you to override that behavior with a custom name, but could lead to naming conflicts if the specified name is not unique.
withContainerName(name: string): ContainerResource
namestringThe desired container name. Must be a valid container name or your runtime will report an error.
ContainerResource
Adds a network alias to container resource.
withContainerNetworkAlias(alias: string): ContainerResource
aliasstringThe network alias for the container.
ContainerResource
Adds a callback to be executed with a list of arguments to add to the container runtime run command when a container resource is started.
withContainerRuntimeArgs(args: string[]): ContainerResource
argsstring[]The arguments to be passed to the container runtime run command when the container resource is started.
ContainerResource
methodwithDockerfilebuilder
Causes Aspire to build the specified container image from a Dockerfile.
withDockerfile(
contextPath: string,
dockerfilePath?: string,
stage?: string): ContainerResource
contextPathstringPath to be used as the context for the container image build.
dockerfilePathstringoptionalPath to the Dockerfile relative to the `contextPath`. Defaults to "Dockerfile" if not specified.
stagestringoptionalThe stage representing the image to be published in a multi-stage Dockerfile.
ContainerResource
Configures the resource to use a programmatically generated Dockerfile
withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise<void>, stage?: string): ContainerResource
contextPathstringPath to be used as the context for the container image build.
callback(arg: DockerfileBuilderCallbackContext) => Promise<void>A callback that uses the `DockerfileBuilder` API to construct the Dockerfile.
stagestringoptionalThe stage representing the image to be published in a multi-stage Dockerfile.
ContainerResource
Builds the specified container image from a Dockerfile generated by an asynchronous factory function.
withDockerfileFactory(contextPath: string, dockerfileFactory: (arg: DockerfileFactoryContext) => Promise<string>, stage?: string): ContainerResource
contextPathstringPath to be used as the context for the container image build.
dockerfileFactory(arg: DockerfileFactoryContext) => Promise<string>An asynchronous function that returns the Dockerfile content as a string.
stagestringoptionalThe stage representing the image to be published in a multi-stage Dockerfile.
ContainerResource
methodwithEntrypointbuilder
Sets the Entrypoint for the container.
withEntrypoint(entrypoint: string): ContainerResource
entrypointstringThe new entrypoint for the container.
ContainerResource
methodwithImagebuilder
Allows overriding the image on a container.
withImage(
image: string,
tag?: string): ContainerResource
imagestringImage value.
tagstringoptionalTag value.
ContainerResource
methodwithImagePullPolicybuilder
Sets the pull policy for the container resource.
withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResource
pullPolicyImagePullPolicyThe pull policy behavior for the container resource.
ContainerResource
methodwithImageRegistrybuilder
Allows overriding the image registry on a container.
withImageRegistry(registry: string): ContainerResource
registrystringRegistry value.
ContainerResource
methodwithImageSHA256builder
Allows setting the image to a specific sha256 on a container.
withImageSHA256(sha256: string): ContainerResource
sha256stringRegistry value.
ContainerResource
methodwithImageTagbuilder
Allows overriding the image tag on a container.
withImageTag(tag: string): ContainerResource
tagstringTag value.
ContainerResource
methodwithLifetimebuilder
Sets the lifetime behavior of the container resource.
withLifetime(lifetime: ContainerLifetime): ContainerResource
lifetimeContainerLifetimeThe lifetime behavior of the container resource. The default behavior is `Session`.
ContainerResource
methodwithVolumebuilder
Adds a volume to a container resource.
withVolume(
target: string,
name?: string,
isReadOnly?: boolean): ContainerResource
targetstringThe mount path inside the container.
namestringoptionalThe volume name. If null, an anonymous volume is created.
isReadOnlybooleanoptional= FalseWhether the volume is read-only.
ContainerResource