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, delete_container_if_exists, docker_installed?, docker_installed?, execute_run_command, handle_error, ps, run_postconditions, 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.10' \
    : 'freedomben/dory-http-proxy:2.6.2.2'
end

.http_portObject



41
42
43
# File 'lib/dory/proxy.rb', line 41

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

.run_commandObject



45
46
47
48
49
50
51
# File 'lib/dory/proxy.rb', line 45

def self.run_command
  "docker run -d -p #{http_port}: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



53
54
55
# File 'lib/dory/proxy.rb', line 53

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 #{Dory::Config.settings[:dory][:nginx_proxy][:tls_port]}:443"
  else
    ''
  end
end