- Implements: aws-cdk-lib.aws_iam.IGrantable
Build a container image and push it to an ECR repository on deploy-time.
import { ContainerImageBuild } from 'deploy-time-build'
new ContainerImageBuild(scope: Construct, id: string, props: ContainerImageBuildProps)
Name | Type | Description |
---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
ContainerImageBuildProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: ContainerImageBuildProps
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
toEcsDockerImageCode |
Get the instance of {@link ContainerImage} for an ECS task definition. |
toLambdaDockerImageCode |
Get the instance of {@link DockerImageCode} for a Lambda function image. |
public toString(): string
Returns a string representation of this construct.
public toEcsDockerImageCode(): EcrImage
Get the instance of {@link ContainerImage} for an ECS task definition.
public toLambdaDockerImageCode(): DockerImageCode
Get the instance of {@link DockerImageCode} for a Lambda function image.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
import { ContainerImageBuild } from 'deploy-time-build'
ContainerImageBuild.isConstruct(x: any)
Checks if x
is a construct.
- Type: any
Any object.
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
grantPrincipal |
aws-cdk-lib.aws_iam.IPrincipal |
The principal to grant permissions to. |
imageTag |
string |
No description. |
repository |
aws-cdk-lib.aws_ecr.IRepository |
No description. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
public readonly grantPrincipal: IPrincipal;
- Type: aws-cdk-lib.aws_iam.IPrincipal
The principal to grant permissions to.
public readonly imageTag: string;
- Type: string
public readonly repository: IRepository;
- Type: aws-cdk-lib.aws_ecr.IRepository
- Implements: aws-cdk-lib.aws_iam.IGrantable
Build Node.js app and optionally publish the artifact to an S3 bucket.
import { NodejsBuild } from 'deploy-time-build'
new NodejsBuild(scope: Construct, id: string, props: NodejsBuildProps)
Name | Type | Description |
---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
NodejsBuildProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: NodejsBuildProps
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
public toString(): string
Returns a string representation of this construct.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
import { NodejsBuild } from 'deploy-time-build'
NodejsBuild.isConstruct(x: any)
Checks if x
is a construct.
- Type: any
Any object.
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
grantPrincipal |
aws-cdk-lib.aws_iam.IPrincipal |
The principal to grant permissions to. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
public readonly grantPrincipal: IPrincipal;
- Type: aws-cdk-lib.aws_iam.IPrincipal
The principal to grant permissions to.
Build and publish a SOCI index for a container image.
A SOCI index helps start Fargate tasks faster in some cases. Please read the following document for more details: https://docs.aws.amazon.com/AmazonECS/latest/userguide/container-considerations.html
import { SociIndexBuild } from 'deploy-time-build'
new SociIndexBuild(scope: Construct, id: string, props: SociIndexBuildProps)
Name | Type | Description |
---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
SociIndexBuildProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: SociIndexBuildProps
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
public toString(): string
Returns a string representation of this construct.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
fromDockerImageAsset |
A utility method to create a SociIndexBuild construct from a DockerImageAsset instance. |
import { SociIndexBuild } from 'deploy-time-build'
SociIndexBuild.isConstruct(x: any)
Checks if x
is a construct.
- Type: any
Any object.
import { SociIndexBuild } from 'deploy-time-build'
SociIndexBuild.fromDockerImageAsset(scope: Construct, id: string, imageAsset: DockerImageAsset)
A utility method to create a SociIndexBuild construct from a DockerImageAsset instance.
- Type: constructs.Construct
- Type: string
- Type: aws-cdk-lib.aws_ecr_assets.DockerImageAsset
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
import { AssetConfig } from 'deploy-time-build'
const assetConfig: AssetConfig = { ... }
Name | Type | Description |
---|---|---|
assetHash |
string |
Specify a custom hash for this asset. |
assetHashType |
aws-cdk-lib.AssetHashType |
Specifies the type of hash to calculate for this asset. |
bundling |
aws-cdk-lib.BundlingOptions |
Bundle the asset by executing a command in a Docker container or a custom bundling provider. |
exclude |
string[] |
File paths matching the patterns will be excluded. |
followSymlinks |
aws-cdk-lib.SymlinkFollowMode |
A strategy for how to handle symlinks. |
ignoreMode |
aws-cdk-lib.IgnoreMode |
The ignore behavior to use for exclude patterns. |
readers |
aws-cdk-lib.aws_iam.IGrantable[] |
A list of principals that should be able to read this asset from S3. |
path |
string |
The disk location of the asset. |
commands |
string[] |
Shell commands executed right after the asset zip is extracted to the build environment. |
extractPath |
string |
Relative path from a build directory to the directory where the asset is extracted. |
public readonly assetHash: string;
- Type: string
- Default: based on
assetHashType
Specify a custom hash for this asset.
If assetHashType
is set it must
be set to AssetHashType.CUSTOM
. For consistency, this custom hash will
be SHA256 hashed and encoded as hex. The resulting hash will be the asset
hash.
NOTE: the hash is used in order to identify a specific revision of the asset, and used for optimizing and caching deployment activities related to this asset such as packaging, uploading to Amazon S3, etc. If you chose to customize the hash, you will need to make sure it is updated every time the asset changes, or otherwise it is possible that some deployments will not be invalidated.
public readonly assetHashType: AssetHashType;
- Type: aws-cdk-lib.AssetHashType
- Default: the default is
AssetHashType.SOURCE
, but ifassetHash
is explicitly specified this value defaults toAssetHashType.CUSTOM
.
Specifies the type of hash to calculate for this asset.
If assetHash
is configured, this option must be undefined
or
AssetHashType.CUSTOM
.
public readonly bundling: BundlingOptions;
- Type: aws-cdk-lib.BundlingOptions
- Default: uploaded as-is to S3 if the asset is a regular file or a .zip file, archived into a .zip file and uploaded to S3 otherwise
Bundle the asset by executing a command in a Docker container or a custom bundling provider.
The asset path will be mounted at /asset-input
. The Docker
container is responsible for putting content at /asset-output
.
The content at /asset-output
will be zipped and used as the
final asset.
public readonly exclude: string[];
- Type: string[]
- Default: nothing is excluded
File paths matching the patterns will be excluded.
See ignoreMode
to set the matching behavior.
Has no effect on Assets bundled using the bundling
property.
public readonly followSymlinks: SymlinkFollowMode;
- Type: aws-cdk-lib.SymlinkFollowMode
- Default: SymlinkFollowMode.NEVER
A strategy for how to handle symlinks.
public readonly ignoreMode: IgnoreMode;
- Type: aws-cdk-lib.IgnoreMode
- Default: IgnoreMode.GLOB
The ignore behavior to use for exclude
patterns.
public readonly readers: IGrantable[];
- Type: aws-cdk-lib.aws_iam.IGrantable[]
- Default: No principals that can read file asset.
A list of principals that should be able to read this asset from S3.
You can use asset.grantRead(principal)
to grant read permissions later.
public readonly path: string;
- Type: string
The disk location of the asset.
The path should refer to one of the following:
- A regular file or a .zip file, in which case the file will be uploaded as-is to S3.
- A directory, in which case it will be archived into a .zip file and uploaded to S3.
public readonly commands: string[];
- Type: string[]
- Default: No command is executed.
Shell commands executed right after the asset zip is extracted to the build environment.
public readonly extractPath: string;
- Type: string
- Default: basename of the asset path.
Relative path from a build directory to the directory where the asset is extracted.
import { ContainerImageBuildProps } from 'deploy-time-build'
const containerImageBuildProps: ContainerImageBuildProps = { ... }
Name | Type | Description |
---|---|---|
exclude |
string[] |
File paths matching the patterns will be excluded. |
followSymlinks |
aws-cdk-lib.SymlinkFollowMode |
A strategy for how to handle symlinks. |
ignoreMode |
aws-cdk-lib.IgnoreMode |
The ignore behavior to use for exclude patterns. |
extraHash |
string |
Extra information to encode into the fingerprint (e.g. build instructions and other inputs). |
buildArgs |
{[ key: string ]: string} |
Build args to pass to the docker build command. |
file |
string |
Path to the Dockerfile (relative to the directory). |
invalidation |
aws-cdk-lib.aws_ecr_assets.DockerImageAssetInvalidationOptions |
Options to control which parameters are used to invalidate the asset hash. |
networkMode |
aws-cdk-lib.aws_ecr_assets.NetworkMode |
Networking mode for the RUN commands during build. |
platform |
aws-cdk-lib.aws_ecr_assets.Platform |
Platform to build for. |
target |
string |
Docker target to build to. |
directory |
string |
The directory where the Dockerfile is stored. |
repository |
aws-cdk-lib.aws_ecr.IRepository |
The ECR repository to push the image. |
tag |
string |
The tag when to push the image. |
zstdCompression |
boolean |
Use zstd for compressing a container image. |
public readonly exclude: string[];
- Type: string[]
- Default: nothing is excluded
File paths matching the patterns will be excluded.
See ignoreMode
to set the matching behavior.
Has no effect on Assets bundled using the bundling
property.
public readonly followSymlinks: SymlinkFollowMode;
- Type: aws-cdk-lib.SymlinkFollowMode
- Default: SymlinkFollowMode.NEVER
A strategy for how to handle symlinks.
public readonly ignoreMode: IgnoreMode;
- Type: aws-cdk-lib.IgnoreMode
- Default: IgnoreMode.GLOB
The ignore behavior to use for exclude
patterns.
public readonly extraHash: string;
- Type: string
- Default: hash is only based on source content
Extra information to encode into the fingerprint (e.g. build instructions and other inputs).
public readonly buildArgs: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- 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
).
public readonly file: string;
- Type: string
- Default: 'Dockerfile'
Path to the Dockerfile (relative to the directory).
public readonly invalidation: DockerImageAssetInvalidationOptions;
- Type: aws-cdk-lib.aws_ecr_assets.DockerImageAssetInvalidationOptions
- Default: hash all parameters
Options to control which parameters are used to invalidate the asset hash.
public readonly networkMode: NetworkMode;
- Type: aws-cdk-lib.aws_ecr_assets.NetworkMode
- 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+.
public readonly platform: Platform;
- Type: aws-cdk-lib.aws_ecr_assets.Platform
- Default: no platform specified (the current machine architecture will be used)
Platform to build for.
Requires Docker Buildx.
public readonly target: string;
- Type: string
- Default: no target
Docker target to build to.
public readonly directory: string;
- 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
public readonly repository: IRepository;
- Type: aws-cdk-lib.aws_ecr.IRepository
- Default: create a new ECR repository
The ECR repository to push the image.
public readonly tag: string;
- Type: string
- Default: use assetHash as tag
The tag when to push the image.
public readonly zstdCompression: boolean;
- Type: boolean
- Default: false
Use zstd for compressing a container image.
import { NodejsBuildProps } from 'deploy-time-build'
const nodejsBuildProps: NodejsBuildProps = { ... }
Name | Type | Description |
---|---|---|
assets |
AssetConfig[] |
The AssetProps from which s3-assets are created and copied to the build environment. |
destinationBucket |
aws-cdk-lib.aws_s3.IBucket |
S3 Bucket to which your build artifacts are finally deployed. |
outputSourceDirectory |
string |
Relative path from the working directory to the directory where the build artifacts are output. |
buildCommands |
string[] |
Shell commands to build your project. |
buildEnvironment |
{[ key: string ]: string} |
Environment variables injected to the build environment. |
destinationKeyPrefix |
string |
Key prefix to deploy your build artifact. |
distribution |
aws-cdk-lib.aws_cloudfront.IDistribution |
The distribution you are using to publish you build artifact. |
excludeCommonFiles |
boolean |
If true, common unnecessary files/directories such as .DS_Store, .git, node_modules, etc are excluded from the assets by default. |
nodejsVersion |
number |
The version of Node.js to use in a build environment. Available versions: 12, 14, 16, 18, 20. |
outputEnvFile |
boolean |
If true, a .env file is uploaded to an S3 bucket with values of buildEnvironment property. You can copy it to your local machine by running the command in the stack output. |
workingDirectory |
string |
Relative path from the build directory to the directory where build commands run. |
public readonly assets: AssetConfig[];
- Type: AssetConfig[]
The AssetProps from which s3-assets are created and copied to the build environment.
public readonly destinationBucket: IBucket;
- Type: aws-cdk-lib.aws_s3.IBucket
S3 Bucket to which your build artifacts are finally deployed.
public readonly outputSourceDirectory: string;
- Type: string
Relative path from the working directory to the directory where the build artifacts are output.
public readonly buildCommands: string[];
- Type: string[]
- Default: ['npm run build']
Shell commands to build your project.
They are executed on the working directory you specified.
public readonly buildEnvironment: {[ key: string ]: string};
- Type: {[ key: string ]: string}
- Default: {}
Environment variables injected to the build environment.
You can use CDK deploy-time values as well as literals.
public readonly destinationKeyPrefix: string;
- Type: string
- Default: '/'
Key prefix to deploy your build artifact.
public readonly distribution: IDistribution;
- Type: aws-cdk-lib.aws_cloudfront.IDistribution
- Default: No distribution
The distribution you are using to publish you build artifact.
If any specified, the caches are invalidated on new artifact deployments.
public readonly excludeCommonFiles: boolean;
- Type: boolean
- Default: true
If true, common unnecessary files/directories such as .DS_Store, .git, node_modules, etc are excluded from the assets by default.
public readonly nodejsVersion: number;
- Type: number
- Default: 18
The version of Node.js to use in a build environment. Available versions: 12, 14, 16, 18, 20.
public readonly outputEnvFile: boolean;
- Type: boolean
- Default: false
If true, a .env file is uploaded to an S3 bucket with values of buildEnvironment
property. You can copy it to your local machine by running the command in the stack output.
public readonly workingDirectory: string;
- Type: string
- Default: assetProps[0].extractPath
Relative path from the build directory to the directory where build commands run.
import { SociIndexBuildProps } from 'deploy-time-build'
const sociIndexBuildProps: SociIndexBuildProps = { ... }
Name | Type | Description |
---|---|---|
imageTag |
string |
The tag of the container image you want to build index for. |
repository |
aws-cdk-lib.aws_ecr.IRepository |
The ECR repository your container image is stored. |
public readonly imageTag: string;
- Type: string
The tag of the container image you want to build index for.
public readonly repository: IRepository;
- Type: aws-cdk-lib.aws_ecr.IRepository
The ECR repository your container image is stored.
You can only specify a repository in the same environment (account/region). The index artifact will be uploaded to this repository.