DockerBuildAssetOptions Struct
Options when creating an asset from a Docker build.
Example
ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_lambda as lambda } from 'aws-cdk-lib';
const dockerBuildAssetOptions: lambda.DockerBuildAssetOptions = {
buildArgs: {
buildArgsKey: 'buildArgs',
},
buildContexts: {
buildContextsKey: 'buildContexts',
},
cacheDisabled: false,
cacheFrom: [{
type: 'type',
// the properties below are optional
params: {
paramsKey: 'params',
},
}],
cacheTo: {
type: 'type',
// the properties below are optional
params: {
paramsKey: 'params',
},
},
file: 'file',
imagePath: 'imagePath',
network: 'network',
outputPath: 'outputPath',
platform: 'platform',
targetStage: 'targetStage',
};
python
from aws_cdk import DockerCacheOption, DockerCacheOption
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_lambda as lambda_
docker_build_asset_options = lambda.DockerBuildAssetOptions(
build_args={
"build_args_key": "buildArgs"
},
build_contexts={
"build_contexts_key": "buildContexts"
},
cache_disabled=False,
cache_from=[DockerCacheOption(
type="type",
# the properties below are optional
params={
"params_key": "params"
}
)],
cache_to=DockerCacheOption(
type="type",
# the properties below are optional
params={
"params_key": "params"
}
),
file="file",
image_path="imagePath",
network="network",
output_path="outputPath",
platform="platform",
target_stage="targetStage"
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.lambda.*;
DockerBuildAssetOptions dockerBuildAssetOptions = DockerBuildAssetOptions.builder()
.buildArgs(Map.of(
"buildArgsKey", "buildArgs"))
.buildContexts(Map.of(
"buildContextsKey", "buildContexts"))
.cacheDisabled(false)
.cacheFrom(List.of(DockerCacheOption.builder()
.type("type")
// the properties below are optional
.params(Map.of(
"paramsKey", "params"))
.build()))
.cacheTo(DockerCacheOption.builder()
.type("type")
// the properties below are optional
.params(Map.of(
"paramsKey", "params"))
.build())
.file("file")
.imagePath("imagePath")
.network("network")
.outputPath("outputPath")
.platform("platform")
.targetStage("targetStage")
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Lambda;
var dockerBuildAssetOptions = new DockerBuildAssetOptions {
BuildArgs = new Dictionary<string, string> {
{ "buildArgsKey", "buildArgs" }
},
BuildContexts = new Dictionary<string, string> {
{ "buildContextsKey", "buildContexts" }
},
CacheDisabled = false,
CacheFrom = new [] { new DockerCacheOption {
Type = "type",
// the properties below are optional
Params = new Dictionary<string, string> {
{ "paramsKey", "params" }
}
} },
CacheTo = new DockerCacheOption {
Type = "type",
// the properties below are optional
Params = new Dictionary<string, string> {
{ "paramsKey", "params" }
}
},
File = "file",
ImagePath = "imagePath",
Network = "network",
OutputPath = "outputPath",
Platform = "platform",
TargetStage = "targetStage"
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
dockerBuildAssetOptions := &DockerBuildAssetOptions{
BuildArgs: map[string]*string{
"buildArgsKey": jsii.String("buildArgs"),
},
BuildContexts: map[string]*string{
"buildContextsKey": jsii.String("buildContexts"),
},
CacheDisabled: jsii.Boolean(false),
CacheFrom: []DockerCacheOption{
&DockerCacheOption{
Type: jsii.String("type"),
// the properties below are optional
Params: map[string]*string{
"paramsKey": jsii.String("params"),
},
},
},
CacheTo: &DockerCacheOption{
Type: jsii.String("type"),
// the properties below are optional
Params: map[string]*string{
"paramsKey": jsii.String("params"),
},
},
File: jsii.String("file"),
ImagePath: jsii.String("imagePath"),
Network: jsii.String("network"),
OutputPath: jsii.String("outputPath"),
Platform: jsii.String("platform"),
TargetStage: jsii.String("targetStage"),
}
Properties
buildArgsoptional{ [key: string]: string }build_argsoptionaltyping.Mapping[str, str]buildArgsoptionalMap<String, String>BuildArgsoptionalIDictionary<string, string>BuildArgsoptional*map[string]*string#Build args.
Default: no build args
buildContextsoptional{ [key: string]: string }build_contextsoptionaltyping.Mapping[str, str]buildContextsoptionalMap<String, String>BuildContextsoptionalIDictionary<string, string>BuildContextsoptional*map[string]*string#Build contexts to pass to the `docker build` command.
Default: no additional build contexts
Build contexts can be used to specify additional directories or images to use during the build. Each entry specifies a named build context and its source (a directory path, a URL, or a docker image).
cacheDisabledoptionalbooleancache_disabledoptionalboolcacheDisabledoptionalBooleanCacheDisabledoptionalboolCacheDisabledoptional*bool#Disable the cache and pass `--no-cache` to the `docker build` command.
Default: cache is used
cacheFromoptionalDockerCacheOption[]cache_fromoptionaltyping.List[DockerCacheOption]cacheFromoptionalList<DockerCacheOption>CacheFromoptionalDockerCacheOption[]CacheFromoptional*[]DockerCacheOption#Cache from options to pass to the `docker build` command.
Default: no cache from args are passed
cacheTooptionalDockerCacheOptioncache_tooptionalDockerCacheOptioncacheTooptionalDockerCacheOptionCacheTooptionalDockerCacheOptionCacheTooptionalDockerCacheOption#Cache to options to pass to the `docker build` command.
Default: no cache to args are passed
fileoptionalstringfileoptionalstrfileoptionalStringFileoptionalstringFileoptional*string= `Dockerfile`#Name of the Dockerfile, must relative to the docker build path.
imagePathoptionalstringimage_pathoptionalstrimagePathoptionalStringImagePathoptionalstringImagePathoptional*string= /asset#The path in the Docker image where the asset is located after the build operation.
networkoptionalstringnetworkoptionalstrnetworkoptionalStringNetworkoptionalstringNetworkoptional*string#Docker [Networking options](https://docs.docker.com/reference/cli/docker/buildx/build/#network).
Default: no networking options
outputPathoptionalstringoutput_pathoptionalstroutputPathoptionalStringOutputPathoptionalstringOutputPathoptional*string#The path on the local filesystem where the asset will be copied using `docker cp`.
Default: a unique temporary directory in the system temp directory
platformoptionalstringplatformoptionalstrplatformoptionalStringPlatformoptionalstringPlatformoptional*string#Set platform if server is multi-platform capable. _Requires Docker Engine API v1.38+_.
Default: no platform specified
Example value: linux/amd64
targetStageoptionalstringtarget_stageoptionalstrtargetStageoptionalStringTargetStageoptionalstringTargetStageoptional*string#Set build target for multi-stage container builds. Any stage defined afterwards will be ignored.
Default: Build all stages defined in the Dockerfile
Example value: build-env