Class: Brut::CLI::Apps::Deploy::AppDockerImages

Inherits:
Object
  • Object
show all
Defined in:
lib/brut/cli/apps/deploy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(organization:, app_id:, project_root:, short_version:) ⇒ AppDockerImages

Returns a new instance of AppDockerImages.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/brut/cli/apps/deploy.rb', line 64

def initialize(organization:, app_id:, project_root:, short_version:)
  @docker_config_filename = project_root / "deploy" / "docker_config"
  require_relative @docker_config_filename
  if ! defined?(DockerConfig)
    raise "#{@docker_config_filename} did not define the constant `DockerConfig` - it must to provide the configuration values to this script"
  end

  docker_config = DockerConfig.new
  @platform = docker_config.platform

  additional_images = (docker_config.additional_images || {}).map { |name,config|
    cmd = config.fetch(:cmd)
    image_name = %{#{Brut.container.app_organization}/#{Brut.container.app_id}:#{short_version}-#{name}}
    [
      name,
      {
        cmd:,
        image_name:,
        dockerfile: "deploy/Dockerfile.#{name}",
      },
    ]
  }.to_h

  @images = {
    "web" => {
      cmd: "bin/run",
      image_name: %{#{Brut.container.app_organization}/#{app_id}:#{short_version}-web},
      dockerfile: "deploy/Dockerfile.web",
    },
    "release" => {
      cmd: "bin/release",
      image_name: %{#{Brut.container.app_organization}/#{app_id}:#{short_version}-release},
      dockerfile: "deploy/Dockerfile.release",
    },
  }.merge(additional_images)
end

Instance Attribute Details

#docker_config_filenameObject (readonly)

Returns the value of attribute docker_config_filename.



63
64
65
# File 'lib/brut/cli/apps/deploy.rb', line 63

def docker_config_filename
  @docker_config_filename
end

#platformObject (readonly)

Returns the value of attribute platform.



63
64
65
# File 'lib/brut/cli/apps/deploy.rb', line 63

def platform
  @platform
end

Instance Method Details

#each(&block) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/brut/cli/apps/deploy.rb', line 101

def each(&block)
  if block.parameters.any? { it[0] != :keyreq }
    raise "block for #{self.class}#each must only contain required keyword parameters"
  end
  @images.each do |name,|
    args = {}
    block.parameters.each do |(_,param)|
      if param == :name
        args[:name] = name
      else
        args[param] = .fetch(param)
      end
    end
    block.(**args)
  end
end