Skip to content
v2.278.0

DockerImageSource Struct ​

Properties for how to produce a Docker image from a source.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { cloud_assembly_schema } from 'aws-cdk-lib';
const dockerImageSource: cloud_assembly_schema.DockerImageSource = {
  cacheDisabled: false,
  cacheFrom: [{
    type: 'type',

    // the properties below are optional
    params: {
      paramsKey: 'params',
    },
  }],
  cacheTo: {
    type: 'type',

    // the properties below are optional
    params: {
      paramsKey: 'params',
    },
  },
  directory: 'directory',
  dockerBuildArgs: {
    dockerBuildArgsKey: 'dockerBuildArgs',
  },
  dockerBuildContexts: {
    dockerBuildContextsKey: 'dockerBuildContexts',
  },
  dockerBuildSecrets: {
    dockerBuildSecretsKey: 'dockerBuildSecrets',
  },
  dockerBuildSsh: 'dockerBuildSsh',
  dockerBuildTarget: 'dockerBuildTarget',
  dockerFile: 'dockerFile',
  dockerOutputs: ['dockerOutputs'],
  executable: ['executable'],
  networkMode: 'networkMode',
  platform: 'platform',
};
python
from aws_cdk.cloud_assembly_schema import DockerImageSource, 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 cloud_assembly_schema

docker_image_source = DockerImageSource(
    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"
        }
    ),
    directory="directory",
    docker_build_args={
        "docker_build_args_key": "dockerBuildArgs"
    },
    docker_build_contexts={
        "docker_build_contexts_key": "dockerBuildContexts"
    },
    docker_build_secrets={
        "docker_build_secrets_key": "dockerBuildSecrets"
    },
    docker_build_ssh="dockerBuildSsh",
    docker_build_target="dockerBuildTarget",
    docker_file="dockerFile",
    docker_outputs=["dockerOutputs"],
    executable=["executable"],
    network_mode="networkMode",
    platform="platform"
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.cloud_assembly_schema.*;

DockerImageSource dockerImageSource = DockerImageSource.builder()
        .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())
        .directory("directory")
        .dockerBuildArgs(Map.of(
                "dockerBuildArgsKey", "dockerBuildArgs"))
        .dockerBuildContexts(Map.of(
                "dockerBuildContextsKey", "dockerBuildContexts"))
        .dockerBuildSecrets(Map.of(
                "dockerBuildSecretsKey", "dockerBuildSecrets"))
        .dockerBuildSsh("dockerBuildSsh")
        .dockerBuildTarget("dockerBuildTarget")
        .dockerFile("dockerFile")
        .dockerOutputs(List.of("dockerOutputs"))
        .executable(List.of("executable"))
        .networkMode("networkMode")
        .platform("platform")
        .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.Cloud_assembly_schema;

var dockerImageSource = new DockerImageSource {
    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" }
        }
    },
    Directory = "directory",
    DockerBuildArgs = new Dictionary<string, string> {
        { "dockerBuildArgsKey", "dockerBuildArgs" }
    },
    DockerBuildContexts = new Dictionary<string, string> {
        { "dockerBuildContextsKey", "dockerBuildContexts" }
    },
    DockerBuildSecrets = new Dictionary<string, string> {
        { "dockerBuildSecretsKey", "dockerBuildSecrets" }
    },
    DockerBuildSsh = "dockerBuildSsh",
    DockerBuildTarget = "dockerBuildTarget",
    DockerFile = "dockerFile",
    DockerOutputs = new [] { "dockerOutputs" },
    Executable = new [] { "executable" },
    NetworkMode = "networkMode",
    Platform = "platform"
};
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"

dockerImageSource := &DockerImageSource{
	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"),
		},
	},
	Directory: jsii.String("directory"),
	DockerBuildArgs: map[string]*string{
		"dockerBuildArgsKey": jsii.String("dockerBuildArgs"),
	},
	DockerBuildContexts: map[string]*string{
		"dockerBuildContextsKey": jsii.String("dockerBuildContexts"),
	},
	DockerBuildSecrets: map[string]*string{
		"dockerBuildSecretsKey": jsii.String("dockerBuildSecrets"),
	},
	DockerBuildSsh: jsii.String("dockerBuildSsh"),
	DockerBuildTarget: jsii.String("dockerBuildTarget"),
	DockerFile: jsii.String("dockerFile"),
	DockerOutputs: []*string{
		jsii.String("dockerOutputs"),
	},
	Executable: []*string{
		jsii.String("executable"),
	},
	NetworkMode: jsii.String("networkMode"),
	Platform: jsii.String("platform"),
}

Properties ​

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 options are passed to the build command

cacheTooptionalDockerCacheOptioncache_tooptionalDockerCacheOptioncacheTooptionalDockerCacheOptionCacheTooptionalDockerCacheOptionCacheTooptionalDockerCacheOption #
Cache to options to pass to the `docker build` command.

Default: no cache to options are passed to the build command

directoryoptionalstringdirectoryoptionalstrdirectoryoptionalStringDirectoryoptionalstringDirectoryoptional*string #
The directory containing the Docker image build instructions.

Default: Exactly one of directory and executable is required

This path is relative to the asset manifest location.

dockerBuildArgsoptional{ [key: string]: string }docker_build_argsoptionaltyping.Mapping[str, str]dockerBuildArgsoptionalMap<String, String>DockerBuildArgsoptionalIDictionary<string, string>DockerBuildArgsoptional*map[string]*string #
Additional build arguments.

Default: No additional build arguments

Only allowed when directory is set.

dockerBuildContextsoptional{ [key: string]: string }docker_build_contextsoptionaltyping.Mapping[str, str]dockerBuildContextsoptionalMap<String, String>DockerBuildContextsoptionalIDictionary<string, string>DockerBuildContextsoptional*map[string]*string #
Additional build contexts.

Default: No additional build contexts

Only allowed when directory is set.

dockerBuildSecretsoptional{ [key: string]: string }docker_build_secretsoptionaltyping.Mapping[str, str]dockerBuildSecretsoptionalMap<String, String>DockerBuildSecretsoptionalIDictionary<string, string>DockerBuildSecretsoptional*map[string]*string #
Additional build secrets.

Default: No additional build secrets

Only allowed when directory is set.

dockerBuildSshoptionalstringdocker_build_sshoptionalstrdockerBuildSshoptionalStringDockerBuildSshoptionalstringDockerBuildSshoptional*string #
SSH agent socket or keys.

Default: No ssh flag is set

Requires building with docker buildkit.

dockerBuildTargetoptionalstringdocker_build_targetoptionalstrdockerBuildTargetoptionalStringDockerBuildTargetoptionalstringDockerBuildTargetoptional*string #
Target build stage in a Dockerfile with multiple build stages.

Default: The last stage in the Dockerfile

Only allowed when directory is set.

dockerFileoptionalstringdocker_fileoptionalstrdockerFileoptionalStringDockerFileoptionalstringDockerFileoptional*string = "Dockerfile" #
The name of the file with build instructions.

Only allowed when directory is set.

dockerOutputsoptionalstring[]docker_outputsoptionaltyping.List[str]dockerOutputsoptionalList<String>DockerOutputsoptionalstring[]DockerOutputsoptional*[]*string #
Outputs.

Default: no outputs are passed to the build command (default outputs are used)

executableoptionalstring[]executableoptionaltyping.List[str]executableoptionalList<String>Executableoptionalstring[]Executableoptional*[]*string #
A command-line executable that returns the name of a local Docker image on stdout after being run.

Default: Exactly one of directory and executable is required

networkModeoptionalstringnetwork_modeoptionalstrnetworkModeoptionalStringNetworkModeoptionalstringNetworkModeoptional*string #
Networking mode for the RUN commands during build. _Requires Docker Engine API v1.25+_.

Default: no networking mode specified

Specify this property to build images on a specific networking mode.

platformoptionalstringplatformoptionalstrplatformoptionalStringPlatformoptionalstringPlatformoptional*string #
Platform to build for. _Requires Docker Buildx_.

Default: current machine platform

Specify this property to build images on a specific platform/architecture.