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.



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
100
101
102
103
# File 'lib/brut/cli/apps/deploy.rb', line 69

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

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

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

Instance Attribute Details

#docker_config_filenameObject (readonly)

Returns the value of attribute docker_config_filename.



68
69
70
# File 'lib/brut/cli/apps/deploy.rb', line 68

def docker_config_filename
  @docker_config_filename
end

Instance Method Details

#each(&block) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/brut/cli/apps/deploy.rb', line 105

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.params.each do |(_,param)|
      if param == :name
        args[:name] = name
      else
        args[param] = .fetch(param)
      end
    end
    block.(**args)
  end
end