Class: AWSCDK::DockerImage

Inherits:
Jsii::Object
  • Object
show all
Defined in:
docker_image.rb

Overview

A Docker image.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image, _image_hash = nil) ⇒ DockerImage

Returns a new instance of DockerImage.

Parameters:

  • image (String)

    The Docker image.

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


10
11
12
13
14
# File 'docker_image.rb', line 10

def initialize(image, _image_hash = nil)
  Jsii::Type.check_type(image, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "image")
  Jsii::Type.check_type(_image_hash, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "_imageHash") unless _image_hash.nil?
  Jsii::Object.instance_method(:initialize).bind(self).call(image, _image_hash)
end

Class Method Details

.from_build(path, options = nil) ⇒ AWSCDK::DockerImage

Builds a Docker image.

Parameters:

  • path (String)

    The path to the directory containing the Docker file.

  • options (AWSCDK::DockerBuildOptions, nil) (defaults to: nil)

    Docker build options.

Returns:

  • (AWSCDK::DockerImage)


30
31
32
33
34
35
# File 'docker_image.rb', line 30

def self.from_build(path, options = nil)
  Jsii::Type.check_type(path, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "path")
  options = options.is_a?(Hash) ? ::AWSCDK::DockerBuildOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Eb2NrZXJCdWlsZE9wdGlvbnMifQ==")), "options") unless options.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.DockerImage", "fromBuild", [path, options])
end

.from_registry(image) ⇒ AWSCDK::DockerImage

Reference an image on DockerHub or another online registry.

Parameters:

  • image (String)

    the image name.

Returns:

  • (AWSCDK::DockerImage)


41
42
43
44
# File 'docker_image.rb', line 41

def self.from_registry(image)
  Jsii::Type.check_type(image, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "image")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.DockerImage", "fromRegistry", [image])
end

.jsii_overridable_methodsObject



16
17
18
19
20
21
22
23
# File 'docker_image.rb', line 16

def self.jsii_overridable_methods
  {
    :image => { kind: :property, name: "image", is_optional: false },
    :cp => { kind: :method, name: "cp", is_optional: false },
    :run => { kind: :method, name: "run", is_optional: false },
    :to_json => { kind: :method, name: "toJSON", is_optional: false },
  }
end

Instance Method Details

#cp(image_path, output_path = nil) ⇒ String

Copies a file or directory out of the Docker image to the local filesystem.

If output_path is omitted the destination path is a temporary directory.

Parameters:

  • image_path (String)

    the path in the Docker image.

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

    the destination path for the copy operation.

Returns:

  • (String)

    the destination path



60
61
62
63
64
# File 'docker_image.rb', line 60

def cp(image_path, output_path = nil)
  Jsii::Type.check_type(image_path, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "imagePath")
  Jsii::Type.check_type(output_path, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "outputPath") unless output_path.nil?
  jsii_call_method("cp", [image_path, output_path])
end

#imageString

The Docker image.

Returns:

  • (String)


49
50
51
# File 'docker_image.rb', line 49

def image()
  jsii_get_property("image")
end

#run(options = nil) ⇒ void

This method returns an undefined value.

Runs a Docker image.

Parameters:



70
71
72
73
74
# File 'docker_image.rb', line 70

def run(options = nil)
  options = options.is_a?(Hash) ? ::AWSCDK::DockerRunOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Eb2NrZXJSdW5PcHRpb25zIn0=")), "options") unless options.nil?
  jsii_call_method("run", [options])
end

#to_jsonString

Provides a stable representation of this image for JSON serialization.

Returns:

  • (String)

    The overridden image name if set or image hash name in that order



79
80
81
# File 'docker_image.rb', line 79

def to_json()
  jsii_call_method("toJSON", [])
end