class DockerImageAsset (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Ecr.Assets.DockerImageAsset |
Java | software.amazon.awscdk.services.ecr.assets.DockerImageAsset |
Python | aws_cdk.aws_ecr_assets.DockerImageAsset |
TypeScript (source) | @aws-cdk/aws-ecr-assets » DockerImageAsset |
Implements
IConstruct
, IConstruct
, IDependable
, IAsset
An asset that represents a Docker image.
The image will be created in build time and uploaded to an ECR repository.
Example
import { DockerImageAsset, NetworkMode } from '@aws-cdk/aws-ecr-assets';
const asset = new DockerImageAsset(this, 'MyBuildImage', {
directory: path.join(__dirname, 'my-image'),
networkMode: NetworkMode.HOST,
})
Initializer
new DockerImageAsset(scope: Construct, id: string, props: DockerImageAssetProps)
Parameters
- scope
Construct
- id
string
- props
Docker
Image Asset Props
Construct Props
Name | Type | Description |
---|---|---|
directory | string | The directory where the Dockerfile is stored. |
build | { [string]: string } | Build args to pass to the docker build command. |
exclude? | string[] | Glob patterns to exclude from the copy. |
extra | string | Extra information to encode into the fingerprint (e.g. build instructions and other inputs). |
file? | string | Path to the Dockerfile (relative to the directory). |
follow? | Follow | A strategy for how to handle symlinks. |
follow | Symlink | A strategy for how to handle symlinks. |
ignore | Ignore | The ignore behavior to use for exclude patterns. |
invalidation? | Docker | Options to control which parameters are used to invalidate the asset hash. |
network | Network | Networking mode for the RUN commands during build. |
platform? | Platform | Platform to build for. |
repository | string | ECR repository name. |
target? | string | Docker target to build to. |
directory
Type:
string
The directory where the Dockerfile is stored.
Any directory inside with a name that matches the CDK output folder (cdk.out by default) will be excluded from the asset
buildArgs?
Type:
{ [string]: string }
(optional, default: no build args are passed)
Build args to pass to the docker build
command.
Since Docker build arguments are resolved before deployment, keys and
values cannot refer to unresolved tokens (such as lambda.functionArn
or
queue.queueUrl
).
exclude?
Type:
string[]
(optional, default: nothing is excluded)
Glob patterns to exclude from the copy.
extraHash?
Type:
string
(optional, default: hash is only based on source content)
Extra information to encode into the fingerprint (e.g. build instructions and other inputs).
file?
Type:
string
(optional, default: 'Dockerfile')
Path to the Dockerfile (relative to the directory).
follow?
⚠️ Deprecated: use followSymlinks
instead
Type:
Follow
(optional, default: Never)
A strategy for how to handle symlinks.
followSymlinks?
Type:
Symlink
(optional, default: SymlinkFollowMode.NEVER)
A strategy for how to handle symlinks.
ignoreMode?
Type:
Ignore
(optional, default: IgnoreMode.GLOB)
The ignore behavior to use for exclude patterns.
invalidation?
Type:
Docker
(optional, default: hash all parameters)
Options to control which parameters are used to invalidate the asset hash.
networkMode?
Type:
Network
(optional, default: no networking mode specified (the default networking mode NetworkMode.DEFAULT
will be used))
Networking mode for the RUN commands during build.
Support docker API 1.25+.
platform?
Type:
Platform
(optional, default: no platform specified (the current machine architecture will be used))
Platform to build for.
Requires Docker Buildx.
repositoryName?
⚠️ Deprecated: to control the location of docker image assets, please override
Stack.addDockerImageAsset
. this feature will be removed in future
releases.
Type:
string
(optional, default: the default ECR repository for CDK assets)
ECR repository name.
Specify this property if you need to statically address the image, e.g. from a Kubernetes Pod. Note, this is only the repository name, without the registry and the tag parts.
target?
Type:
string
(optional, default: no target)
Docker target to build to.
Properties
Name | Type | Description |
---|---|---|
asset | string | A hash of this asset, which is available at construction time. |
image | string | The full URI of the image (including a tag). |
node | Construct | The construct tree node associated with this construct. |
repository | IRepository | Repository where the image is stored. |
source | string | A hash of the source of this asset, which is available at construction time. |
assetHash
Type:
string
A hash of this asset, which is available at construction time.
As this is a plain string, it can be used in construct IDs in order to enforce creation of a new resource when the content hash has changed.
imageUri
Type:
string
The full URI of the image (including a tag).
Use this reference to pull the asset.
node
Type:
Construct
The construct tree node associated with this construct.
repository
Type:
IRepository
Repository where the image is stored.
sourceHash
⚠️ Deprecated: use assetHash
Type:
string
A hash of the source of this asset, which is available at construction time.
As this is a plain string, it can be used in construct IDs in order to enforce creation of a new resource when the content hash has changed.
Methods
Name | Description |
---|---|
add | Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset. |
to | Returns a string representation of this construct. |
addResourceMetadata(resource, resourceProperty)
public addResourceMetadata(resource: CfnResource, resourceProperty: string): void
Parameters
- resource
Cfn
— The CloudFormation resource which is using this asset [disable-awslint:ref-via-interface].Resource - resourceProperty
string
— The property name where this asset is referenced.
Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset.
This can be used by tools such as SAM CLI to provide local experience such as local invocation and debugging of Lambda functions.
Asset metadata will only be included if the stack is synthesized with the "aws:cdk:enable-asset-metadata" context key defined, which is the default behavior when synthesizing via the CDK Toolkit.
See also: https://github.com/aws/aws-cdk/issues/1432
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.