Class: Dory::Proxy

Inherits:
Object
  • Object
show all
Extended by:
DockerService
Defined in:
lib/dory/proxy.rb

Class Method Summary collapse

Methods included from DockerService

container_exists?, delete, docker_installed?, handle_error, has_docker_client?, ps, run_preconditions, running?, start, start_cmd, stop

Class Method Details

.certs_argObject



23
24
25
26
27
28
29
# File 'lib/dory/proxy.rb', line 23

def self.certs_arg
  if certs_dir && !certs_dir.empty?
    "-v #{certs_dir}:/etc/nginx/certs"
  else
    ''
  end
end

.certs_dirObject



19
20
21
# File 'lib/dory/proxy.rb', line 19

def self.certs_dir
  Dory::Config.settings[:dory][:nginx_proxy][:ssl_certs_dir]
end

.container_nameObject



15
16
17
# File 'lib/dory/proxy.rb', line 15

def self.container_name
  Dory::Config.settings[:dory][:nginx_proxy][:container_name]
end

.dory_http_proxy_image_nameObject



7
8
9
10
11
12
13
# File 'lib/dory/proxy.rb', line 7

def self.dory_http_proxy_image_name
  setting = Dory::Config.settings[:dory][:nginx_proxy][:image]
  return setting if setting
  certs_dir && !certs_dir.empty? \
    ? 'codekitchen/dinghy-http-proxy:2.5.3' \
    : 'freedomben/dory-http-proxy:2.2.0.1'
end

.run_commandObject



41
42
43
44
45
46
47
# File 'lib/dory/proxy.rb', line 41

def self.run_command
  "docker run -d -p 80:80 #{self.tls_arg} #{self.certs_arg} "\
    "-v /var/run/docker.sock:/tmp/docker.sock -e " \
    "'CONTAINER_NAME=#{Shellwords.escape(self.container_name)}' --name " \
    "'#{Shellwords.escape(self.container_name)}' " \
    "#{Shellwords.escape(dory_http_proxy_image_name)}"
end

.start_cmdObject



49
50
51
# File 'lib/dory/proxy.rb', line 49

def self.start_cmd
  "docker start #{Shellwords.escape(self.container_name)}"
end

.tls_argObject



31
32
33
34
35
36
37
38
39
# File 'lib/dory/proxy.rb', line 31

def self.tls_arg
  if [:tls_enabled, :ssl_enabled, :https_enabled].any? { |s|
      Dory::Config.settings[:dory][:nginx_proxy][s]
    }
    "-p 443:443"
  else
    ''
  end
end