DockerBuildOptions Struct
Docker build options.
Example
ts
new lambda.Function(this, 'Function', {
code: lambda.Code.fromAsset('/path/to/handler', {
bundling: {
image: DockerImage.fromBuild('/path/to/dir/with/DockerFile', {
buildArgs: {
ARG1: 'value1',
},
}),
command: ['my', 'cool', 'command'],
},
}),
runtime: lambda.Runtime.PYTHON_3_9,
handler: 'index.handler',
});
python
from aws_cdk import BundlingOptions
lambda_.Function(self, "Function",
code=lambda_.Code.from_asset("/path/to/handler",
bundling=BundlingOptions(
image=DockerImage.from_build("/path/to/dir/with/DockerFile",
build_args={
"ARG1": "value1"
}
),
command=["my", "cool", "command"]
)
),
runtime=lambda_.Runtime.PYTHON_3_9,
handler="index.handler"
)
java
Function.Builder.create(this, "Function")
.code(Code.fromAsset("/path/to/handler", AssetOptions.builder()
.bundling(BundlingOptions.builder()
.image(DockerImage.fromBuild("/path/to/dir/with/DockerFile", DockerBuildOptions.builder()
.buildArgs(Map.of(
"ARG1", "value1"))
.build()))
.command(List.of("my", "cool", "command"))
.build())
.build()))
.runtime(Runtime.PYTHON_3_9)
.handler("index.handler")
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
new Function(this, "Function", new FunctionProps {
Code = Code.FromAsset("/path/to/handler", new AssetOptions {
Bundling = new BundlingOptions {
Image = DockerImage.FromBuild("/path/to/dir/with/DockerFile", new DockerBuildOptions {
BuildArgs = new Dictionary<string, string> {
{ "ARG1", "value1" }
}
}),
Command = new [] { "my", "cool", "command" }
}
}),
Runtime = Runtime.PYTHON_3_9,
Handler = "index.handler"
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
lambda.NewFunction(this, jsii.String("Function"), &FunctionProps{
Code: lambda.Code_FromAsset(jsii.String("/path/to/handler"), &AssetOptions{
Bundling: &BundlingOptions{
Image: awscdk.DockerImage_FromBuild(jsii.String("/path/to/dir/with/DockerFile"), &DockerBuildOptions{
BuildArgs: map[string]*string{
"ARG1": jsii.String("value1"),
},
}),
Command: []*string{
jsii.String("my"),
jsii.String("cool"),
jsii.String("command"),
},
},
}),
Runtime: lambda.Runtime_PYTHON_3_9(),
Handler: jsii.String("index.handler"),
})
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.
networkoptionalstringnetworkoptionalstrnetworkoptionalStringNetworkoptionalstringNetworkoptional*string#Docker [Networking options](https://docs.docker.com/reference/cli/docker/buildx/build/#network).
Default: no networking options
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