Class: AWSCDK::DockerBuildOptions

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

Overview

Docker build options.

Direct Known Subclasses

Lambda::DockerBuildAssetOptions

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(build_args: nil, build_contexts: nil, cache_disabled: nil, cache_from: nil, cache_to: nil, file: nil, network: nil, platform: nil, target_stage: nil) ⇒ DockerBuildOptions

Returns a new instance of DockerBuildOptions.

Parameters:

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

    Build args.

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

    Build contexts to pass to the docker build command.

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

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

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

    Cache from options to pass to the docker build command.

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

    Cache to options to pass to the docker build command.

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

    Name of the Dockerfile, must relative to the docker build path.

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

    Set platform if server is multi-platform capable. Requires Docker Engine API v1.38+.

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

    Set build target for multi-stage container builds. Any stage defined afterwards will be ignored.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'docker_build_options.rb', line 16

def initialize(build_args: nil, build_contexts: nil, cache_disabled: nil, cache_from: nil, cache_to: nil, file: nil, network: nil, platform: nil, target_stage: nil)
  @build_args = build_args
  Jsii::Type.check_type(@build_args, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "buildArgs") unless @build_args.nil?
  @build_contexts = build_contexts
  Jsii::Type.check_type(@build_contexts, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "buildContexts") unless @build_contexts.nil?
  @cache_disabled = cache_disabled
  Jsii::Type.check_type(@cache_disabled, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "cacheDisabled") unless @cache_disabled.nil?
  @cache_from = cache_from.is_a?(Array) ? cache_from.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::DockerCacheOption.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : cache_from
  Jsii::Type.check_type(@cache_from, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLkRvY2tlckNhY2hlT3B0aW9uIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "cacheFrom") unless @cache_from.nil?
  @cache_to = cache_to.is_a?(Hash) ? ::AWSCDK::DockerCacheOption.new(**cache_to.transform_keys(&:to_sym)) : cache_to
  Jsii::Type.check_type(@cache_to, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Eb2NrZXJDYWNoZU9wdGlvbiJ9")), "cacheTo") unless @cache_to.nil?
  @file = file
  Jsii::Type.check_type(@file, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "file") unless @file.nil?
  @network = network
  Jsii::Type.check_type(@network, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "network") unless @network.nil?
  @platform = platform
  Jsii::Type.check_type(@platform, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "platform") unless @platform.nil?
  @target_stage = target_stage
  Jsii::Type.check_type(@target_stage, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "targetStage") unless @target_stage.nil?
end

Instance Attribute Details

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

Note:

Default: - no build args

Build args.

Returns:

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


41
42
43
# File 'docker_build_options.rb', line 41

def build_args
  @build_args
end

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

Returns:

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

See Also:



51
52
53
# File 'docker_build_options.rb', line 51

def build_contexts
  @build_contexts
end

#cache_disabledBoolean? (readonly)

Note:

Default: - cache is used

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

Returns:

  • (Boolean, nil)


56
57
58
# File 'docker_build_options.rb', line 56

def cache_disabled
  @cache_disabled
end

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

Note:

Default: - no cache from args are passed

Cache from options to pass to the docker build command.

Returns:



61
62
63
# File 'docker_build_options.rb', line 61

def cache_from
  @cache_from
end

#cache_toAWSCDK::DockerCacheOption? (readonly)

Note:

Default: - no cache to args are passed

Cache to options to pass to the docker build command.

Returns:



66
67
68
# File 'docker_build_options.rb', line 66

def cache_to
  @cache_to
end

#fileString? (readonly)

Note:

Default: Dockerfile

Name of the Dockerfile, must relative to the docker build path.

Returns:

  • (String, nil)


71
72
73
# File 'docker_build_options.rb', line 71

def file
  @file
end

#networkString? (readonly)

Note:

Default: - no networking options

Docker Networking options.

Returns:

  • (String, nil)


76
77
78
# File 'docker_build_options.rb', line 76

def network
  @network
end

#platformString? (readonly)

Note:

Default: - no platform specified

Set platform if server is multi-platform capable. Requires Docker Engine API v1.38+.

Example value: linux/amd64

Returns:

  • (String, nil)


83
84
85
# File 'docker_build_options.rb', line 83

def platform
  @platform
end

#target_stageString? (readonly)

Note:

Default: - Build all stages defined in the Dockerfile

Set build target for multi-stage container builds. Any stage defined afterwards will be ignored.

Example value: build-env

Returns:

  • (String, nil)


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

def target_stage
  @target_stage
end

Class Method Details

.jsii_propertiesObject



92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'docker_build_options.rb', line 92

def self.jsii_properties
  {
    :build_args => "buildArgs",
    :build_contexts => "buildContexts",
    :cache_disabled => "cacheDisabled",
    :cache_from => "cacheFrom",
    :cache_to => "cacheTo",
    :file => "file",
    :network => "network",
    :platform => "platform",
    :target_stage => "targetStage",
  }
end

Instance Method Details

#to_jsiiObject



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'docker_build_options.rb', line 106

def to_jsii
  result = {}
  result.merge!({
    "buildArgs" => @build_args,
    "buildContexts" => @build_contexts,
    "cacheDisabled" => @cache_disabled,
    "cacheFrom" => @cache_from,
    "cacheTo" => @cache_to,
    "file" => @file,
    "network" => @network,
    "platform" => @platform,
    "targetStage" => @target_stage,
  })
  result.compact
end