Class: AWSCDK::DockerImageAssetSource

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
docker_image_asset_source.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_hash:, asset_name: nil, directory_name: nil, display_name: nil, docker_build_args: nil, docker_build_contexts: nil, docker_build_secrets: nil, docker_build_ssh: nil, docker_build_target: nil, docker_cache_disabled: nil, docker_cache_from: nil, docker_cache_to: nil, docker_file: nil, docker_outputs: nil, executable: nil, network_mode: nil, platform: nil) ⇒ DockerImageAssetSource

Returns a new instance of DockerImageAssetSource.

Parameters:

  • source_hash (String)

    The hash of the contents of the docker build context.

  • asset_name (String, nil) (defaults to: nil)

    Unique identifier of the docker image asset and its potential revisions.

  • directory_name (String, nil) (defaults to: nil)

    The directory where the Dockerfile is stored, must be relative to the cloud assembly root.

  • display_name (String, nil) (defaults to: nil)

    A display name for this asset.

  • docker_build_args (Hash{String => String}, nil) (defaults to: nil)

    Build args to pass to the docker build command.

  • docker_build_contexts (Hash{String => String}, nil) (defaults to: nil)

    Build contexts to pass to the docker build command.

  • docker_build_secrets (Hash{String => String}, nil) (defaults to: nil)

    Build secrets to pass to the docker build command.

  • docker_build_ssh (String, nil) (defaults to: nil)

    SSH agent socket or keys to pass to the docker buildx command.

  • docker_build_target (String, nil) (defaults to: nil)

    Docker target to build to.

  • docker_cache_disabled (Boolean, nil) (defaults to: nil)

    Disable the cache and pass --no-cache to the docker build command.

  • docker_cache_from (Array<AWSCDK::DockerCacheOption>, nil) (defaults to: nil)

    Cache from options to pass to the docker build command.

  • docker_cache_to (AWSCDK::DockerCacheOption, nil) (defaults to: nil)

    Cache to options to pass to the docker build command.

  • docker_file (String, nil) (defaults to: nil)

    Path to the Dockerfile (relative to the directory).

  • docker_outputs (Array<String>, nil) (defaults to: nil)

    Outputs to pass to the docker build command.

  • executable (Array<String>, nil) (defaults to: nil)

    An external command that will produce the packaged asset.

  • network_mode (String, nil) (defaults to: nil)

    Networking mode for the RUN commands during build. Requires Docker Engine API v1.25+.

  • platform (String, nil) (defaults to: nil)

    Platform to build for. Requires Docker Buildx.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'docker_image_asset_source.rb', line 23

def initialize(source_hash:, asset_name: nil, directory_name: nil, display_name: nil, docker_build_args: nil, docker_build_contexts: nil, docker_build_secrets: nil, docker_build_ssh: nil, docker_build_target: nil, docker_cache_disabled: nil, docker_cache_from: nil, docker_cache_to: nil, docker_file: nil, docker_outputs: nil, executable: nil, network_mode: nil, platform: nil)
  @source_hash = source_hash
  Jsii::Type.check_type(@source_hash, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "sourceHash")
  @asset_name = asset_name
  Jsii::Type.check_type(@asset_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "assetName") unless @asset_name.nil?
  @directory_name = directory_name
  Jsii::Type.check_type(@directory_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "directoryName") unless @directory_name.nil?
  @display_name = display_name
  Jsii::Type.check_type(@display_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "displayName") unless @display_name.nil?
  @docker_build_args = docker_build_args
  Jsii::Type.check_type(@docker_build_args, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "dockerBuildArgs") unless @docker_build_args.nil?
  @docker_build_contexts = docker_build_contexts
  Jsii::Type.check_type(@docker_build_contexts, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "dockerBuildContexts") unless @docker_build_contexts.nil?
  @docker_build_secrets = docker_build_secrets
  Jsii::Type.check_type(@docker_build_secrets, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "dockerBuildSecrets") unless @docker_build_secrets.nil?
  @docker_build_ssh = docker_build_ssh
  Jsii::Type.check_type(@docker_build_ssh, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "dockerBuildSsh") unless @docker_build_ssh.nil?
  @docker_build_target = docker_build_target
  Jsii::Type.check_type(@docker_build_target, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "dockerBuildTarget") unless @docker_build_target.nil?
  @docker_cache_disabled = docker_cache_disabled
  Jsii::Type.check_type(@docker_cache_disabled, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "dockerCacheDisabled") unless @docker_cache_disabled.nil?
  @docker_cache_from = docker_cache_from.is_a?(Array) ? docker_cache_from.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::DockerCacheOption.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : docker_cache_from
  Jsii::Type.check_type(@docker_cache_from, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLkRvY2tlckNhY2hlT3B0aW9uIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "dockerCacheFrom") unless @docker_cache_from.nil?
  @docker_cache_to = docker_cache_to.is_a?(Hash) ? ::AWSCDK::DockerCacheOption.new(**docker_cache_to.transform_keys(&:to_sym)) : docker_cache_to
  Jsii::Type.check_type(@docker_cache_to, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Eb2NrZXJDYWNoZU9wdGlvbiJ9")), "dockerCacheTo") unless @docker_cache_to.nil?
  @docker_file = docker_file
  Jsii::Type.check_type(@docker_file, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "dockerFile") unless @docker_file.nil?
  @docker_outputs = docker_outputs
  Jsii::Type.check_type(@docker_outputs, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "dockerOutputs") unless @docker_outputs.nil?
  @executable = executable
  Jsii::Type.check_type(@executable, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "executable") unless @executable.nil?
  @network_mode = network_mode
  Jsii::Type.check_type(@network_mode, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "networkMode") unless @network_mode.nil?
  @platform = platform
  Jsii::Type.check_type(@platform, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "platform") unless @platform.nil?
end

Instance Attribute Details

#asset_nameString? (readonly)

Note:

Default: - no asset name

Unique identifier of the docker image asset and its potential revisions.

Required if using AppScopedStagingSynthesizer.

Returns:

  • (String, nil)


77
78
79
# File 'docker_image_asset_source.rb', line 77

def asset_name
  @asset_name
end

#directory_nameString? (readonly)

Note:

Default: - Exactly one of directoryName and executable is required

The directory where the Dockerfile is stored, must be relative to the cloud assembly root.

Returns:

  • (String, nil)


82
83
84
# File 'docker_image_asset_source.rb', line 82

def directory_name
  @directory_name
end

#display_nameString? (readonly)

Note:

Default: - The asset hash is used to display the asset

A display name for this asset.

If supplied, the display name will be used in locations where the asset identifier is printed, like in the CLI progress information.

Returns:

  • (String, nil)


90
91
92
# File 'docker_image_asset_source.rb', line 90

def display_name
  @display_name
end

#docker_build_argsHash{String => String}? (readonly)

Note:

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).

Only allowed when directory_name is specified.

Returns:

  • (Hash{String => String}, nil)


101
102
103
# File 'docker_image_asset_source.rb', line 101

def docker_build_args
  @docker_build_args
end

#docker_build_contextsHash{String => String}? (readonly)

Note:

Default: - no additional build contexts

Build contexts to pass to the docker build command.

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).

Only allowed when directory_name is specified.

Returns:

  • (Hash{String => String}, nil)

See Also:



113
114
115
# File 'docker_image_asset_source.rb', line 113

def docker_build_contexts
  @docker_build_contexts
end

#docker_build_secretsHash{String => String}? (readonly)

Note:

Default: - no build secrets are passed

Build secrets to pass to the docker build command.

Since Docker build secrets are resolved before deployment, keys and values cannot refer to unresolved tokens (such as lambda.functionArn or queue.queueUrl).

Only allowed when directory_name is specified.

Returns:

  • (Hash{String => String}, nil)


124
125
126
# File 'docker_image_asset_source.rb', line 124

def docker_build_secrets
  @docker_build_secrets
end

#docker_build_sshString? (readonly)

Note:

Default: - no ssh arg is passed

SSH agent socket or keys to pass to the docker buildx command.

Returns:

  • (String, nil)


129
130
131
# File 'docker_image_asset_source.rb', line 129

def docker_build_ssh
  @docker_build_ssh
end

#docker_build_targetString? (readonly)

Note:

Default: - no target

Docker target to build to.

Only allowed when directory_name is specified.

Returns:

  • (String, nil)


136
137
138
# File 'docker_image_asset_source.rb', line 136

def docker_build_target
  @docker_build_target
end

#docker_cache_disabledBoolean? (readonly)

Note:

Default: - cache is used

Disable the cache and pass --no-cache to the docker build command.

Returns:

  • (Boolean, nil)


141
142
143
# File 'docker_image_asset_source.rb', line 141

def docker_cache_disabled
  @docker_cache_disabled
end

#docker_cache_fromArray<AWSCDK::DockerCacheOption>? (readonly)

Note:

Default: - no cache from args are passed

Cache from options to pass to the docker build command.

Returns:



146
147
148
# File 'docker_image_asset_source.rb', line 146

def docker_cache_from
  @docker_cache_from
end

#docker_cache_toAWSCDK::DockerCacheOption? (readonly)

Note:

Default: - no cache to args are passed

Cache to options to pass to the docker build command.

Returns:



151
152
153
# File 'docker_image_asset_source.rb', line 151

def docker_cache_to
  @docker_cache_to
end

#docker_fileString? (readonly)

Note:

Default: - no file

Path to the Dockerfile (relative to the directory).

Only allowed when directory_name is specified.

Returns:

  • (String, nil)


158
159
160
# File 'docker_image_asset_source.rb', line 158

def docker_file
  @docker_file
end

#docker_outputsArray<String>? (readonly)

Note:

Default: - no build args are passed

Outputs to pass to the docker build command.

Returns:

  • (Array<String>, nil)


163
164
165
# File 'docker_image_asset_source.rb', line 163

def docker_outputs
  @docker_outputs
end

#executableArray<String>? (readonly)

Note:

Default: - Exactly one of directoryName and executable is required

An external command that will produce the packaged asset.

The command should produce the name of a local Docker image on stdout.

Returns:

  • (Array<String>, nil)


170
171
172
# File 'docker_image_asset_source.rb', line 170

def executable
  @executable
end

#network_modeString? (readonly)

Note:

Default: - no networking mode specified

Networking mode for the RUN commands during build. Requires Docker Engine API v1.25+.

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

Returns:

  • (String, nil)


177
178
179
# File 'docker_image_asset_source.rb', line 177

def network_mode
  @network_mode
end

#platformString? (readonly)

Note:

Default: - no platform specified (the current machine architecture will be used)

Platform to build for. Requires Docker Buildx.

Specify this property to build images on a specific platform.

Returns:

  • (String, nil)


184
185
186
# File 'docker_image_asset_source.rb', line 184

def platform
  @platform
end

#source_hashString (readonly)

The hash of the contents of the docker build context.

This hash is used throughout the system to identify this image and avoid duplicate work in case the source did not change.

NOTE: this means that if you wish to update your docker image, you must make a modification to the source (e.g. add some metadata to your Dockerfile).

Returns:

  • (String)


70
71
72
# File 'docker_image_asset_source.rb', line 70

def source_hash
  @source_hash
end

Class Method Details

.jsii_propertiesObject



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'docker_image_asset_source.rb', line 186

def self.jsii_properties
  {
    :source_hash => "sourceHash",
    :asset_name => "assetName",
    :directory_name => "directoryName",
    :display_name => "displayName",
    :docker_build_args => "dockerBuildArgs",
    :docker_build_contexts => "dockerBuildContexts",
    :docker_build_secrets => "dockerBuildSecrets",
    :docker_build_ssh => "dockerBuildSsh",
    :docker_build_target => "dockerBuildTarget",
    :docker_cache_disabled => "dockerCacheDisabled",
    :docker_cache_from => "dockerCacheFrom",
    :docker_cache_to => "dockerCacheTo",
    :docker_file => "dockerFile",
    :docker_outputs => "dockerOutputs",
    :executable => "executable",
    :network_mode => "networkMode",
    :platform => "platform",
  }
end

Instance Method Details

#to_jsiiObject



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'docker_image_asset_source.rb', line 208

def to_jsii
  result = {}
  result.merge!({
    "sourceHash" => @source_hash,
    "assetName" => @asset_name,
    "directoryName" => @directory_name,
    "displayName" => @display_name,
    "dockerBuildArgs" => @docker_build_args,
    "dockerBuildContexts" => @docker_build_contexts,
    "dockerBuildSecrets" => @docker_build_secrets,
    "dockerBuildSsh" => @docker_build_ssh,
    "dockerBuildTarget" => @docker_build_target,
    "dockerCacheDisabled" => @docker_cache_disabled,
    "dockerCacheFrom" => @docker_cache_from,
    "dockerCacheTo" => @docker_cache_to,
    "dockerFile" => @docker_file,
    "dockerOutputs" => @docker_outputs,
    "executable" => @executable,
    "networkMode" => @network_mode,
    "platform" => @platform,
  })
  result.compact
end