Class: Aruba::DockerBuildCommandLineBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/aruba/tasks/docker_helpers.rb

Instance Method Summary collapse

Constructor Details

#initialize(run_instance, opts = {}) ⇒ DockerBuildCommandLineBuilder

Returns a new instance of DockerBuildCommandLineBuilder.


32
33
34
35
# File 'lib/aruba/tasks/docker_helpers.rb', line 32

def initialize(run_instance, opts = {})
  @run_instance = run_instance
  @opts = opts
end

Instance Method Details

#to_cliObject


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/aruba/tasks/docker_helpers.rb', line 37

def to_cli
  cache               = opts[:cache]
  application_version = opts[:version]
  docker_file         = run_instance.docker_file
  docker_image        = run_instance.image

  cmdline = []
  cmdline << 'docker'
  cmdline << 'build'
  cmdline << '--no-cache=true' if cache == 'false'

  %w(http_proxy https_proxy HTTP_PROXY HTTPS_PROXY).each do |var|
    next unless ENV.key? var

    proxy_uri = URI(ENV[var])
    proxy_uri.host = '172.17.0.1'
    cmdline << "--build-arg #{var}=#{proxy_uri}"
  end

  cmdline << "-t #{docker_image}:#{application_version}"
  cmdline << "-f #{docker_file}"
  cmdline << File.dirname(docker_file)

  cmdline.join(' ')
end