Class: Kamal::Configuration::Proxy::Run
- Inherits:
-
Object
- Object
- Kamal::Configuration::Proxy::Run
- Defined in:
- lib/kamal/configuration/proxy/run.rb
Constant Summary collapse
- MINIMUM_VERSION =
"v0.9.0"- DEFAULT_HTTP_PORT =
80- DEFAULT_HTTPS_PORT =
443- DEFAULT_LOG_MAX_SIZE =
"10m"
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#run_config ⇒ Object
readonly
Returns the value of attribute run_config.
Instance Method Summary collapse
- #app_container_directory ⇒ Object
- #app_directory ⇒ Object
- #apps_container_directory ⇒ Object
- #apps_directory ⇒ Object
- #apps_volume ⇒ Object
- #apps_volume_args ⇒ Object
- #bind_ips ⇒ Object
- #container_name ⇒ Object
- #debug? ⇒ Boolean
- #docker_options_args ⇒ Object
- #host_directory ⇒ Object
- #http_port ⇒ Object
- #https_port ⇒ Object
- #image ⇒ Object
-
#initialize(config, run_config:, context: "proxy/run") ⇒ Run
constructor
A new instance of Run.
- #log_max_size ⇒ Object
- #logging_args ⇒ Object
- #metrics_port ⇒ Object
- #options_args ⇒ Object
- #publish? ⇒ Boolean
- #publish_args ⇒ Object
- #registry ⇒ Object
- #repository ⇒ Object
- #run_command ⇒ Object
- #run_command_options ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(config, run_config:, context: "proxy/run") ⇒ Run
Returns a new instance of Run.
10 11 12 13 14 |
# File 'lib/kamal/configuration/proxy/run.rb', line 10 def initialize(config, run_config:, context: "proxy/run") @config = config @run_config = run_config @context = context end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/kamal/configuration/proxy/run.rb', line 7 def config @config end |
#run_config ⇒ Object (readonly)
Returns the value of attribute run_config.
7 8 9 |
# File 'lib/kamal/configuration/proxy/run.rb', line 7 def run_config @run_config end |
Instance Method Details
#app_container_directory ⇒ Object
130 131 132 |
# File 'lib/kamal/configuration/proxy/run.rb', line 130 def app_container_directory File.join apps_container_directory, config.service_and_destination end |
#app_directory ⇒ Object
126 127 128 |
# File 'lib/kamal/configuration/proxy/run.rb', line 126 def app_directory File.join apps_directory, config.service_and_destination end |
#apps_container_directory ⇒ Object
112 113 114 |
# File 'lib/kamal/configuration/proxy/run.rb', line 112 def apps_container_directory "/home/kamal-proxy/.apps-config" end |
#apps_directory ⇒ Object
108 109 110 |
# File 'lib/kamal/configuration/proxy/run.rb', line 108 def apps_directory File.join host_directory, "apps-config" end |
#apps_volume ⇒ Object
116 117 118 119 120 |
# File 'lib/kamal/configuration/proxy/run.rb', line 116 def apps_volume Kamal::Configuration::Volume.new \ host_path: apps_directory, container_path: apps_container_directory end |
#apps_volume_args ⇒ Object
122 123 124 |
# File 'lib/kamal/configuration/proxy/run.rb', line 122 def apps_volume_args [ apps_volume.docker_args ] end |
#bind_ips ⇒ Object
32 33 34 |
# File 'lib/kamal/configuration/proxy/run.rb', line 32 def bind_ips run_config.fetch("bind_ips", nil) end |
#container_name ⇒ Object
72 73 74 |
# File 'lib/kamal/configuration/proxy/run.rb', line 72 def container_name "kamal-proxy" end |
#debug? ⇒ Boolean
16 17 18 |
# File 'lib/kamal/configuration/proxy/run.rb', line 16 def debug? run_config.fetch("debug", nil) end |
#docker_options_args ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/kamal/configuration/proxy/run.rb', line 94 def [ *apps_volume_args, *publish_args, *logging_args, *("--expose=#{metrics_port}" if metrics_port.present?), * ].compact end |
#host_directory ⇒ Object
104 105 106 |
# File 'lib/kamal/configuration/proxy/run.rb', line 104 def host_directory File.join config.run_directory, "proxy" end |
#http_port ⇒ Object
24 25 26 |
# File 'lib/kamal/configuration/proxy/run.rb', line 24 def http_port run_config.fetch("http_port", DEFAULT_HTTP_PORT) end |
#https_port ⇒ Object
28 29 30 |
# File 'lib/kamal/configuration/proxy/run.rb', line 28 def https_port run_config.fetch("https_port", DEFAULT_HTTPS_PORT) end |
#image ⇒ Object
68 69 70 |
# File 'lib/kamal/configuration/proxy/run.rb', line 68 def image "#{[ registry, repository ].compact.join("/")}:#{version}" end |
#log_max_size ⇒ Object
48 49 50 |
# File 'lib/kamal/configuration/proxy/run.rb', line 48 def log_max_size run_config.fetch("log_max_size", DEFAULT_LOG_MAX_SIZE) end |
#logging_args ⇒ Object
52 53 54 |
# File 'lib/kamal/configuration/proxy/run.rb', line 52 def logging_args argumentize "--log-opt", "max-size=#{log_max_size}" if log_max_size.present? end |
#metrics_port ⇒ Object
86 87 88 |
# File 'lib/kamal/configuration/proxy/run.rb', line 86 def metrics_port run_config["metrics_port"] end |
#options_args ⇒ Object
76 77 78 79 80 |
# File 'lib/kamal/configuration/proxy/run.rb', line 76 def if args = run_config["options"] optionize args end end |
#publish? ⇒ Boolean
20 21 22 |
# File 'lib/kamal/configuration/proxy/run.rb', line 20 def publish? run_config.fetch("publish", true) end |
#publish_args ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/kamal/configuration/proxy/run.rb', line 36 def publish_args if publish? (bind_ips || [ nil ]).map do |bind_ip| bind_ip = format_bind_ip(bind_ip) publish_http = [ bind_ip, http_port, DEFAULT_HTTP_PORT ].compact.join(":") publish_https = [ bind_ip, https_port, DEFAULT_HTTPS_PORT ].compact.join(":") argumentize "--publish", [ publish_http, publish_https ] end.join(" ") end end |
#registry ⇒ Object
60 61 62 |
# File 'lib/kamal/configuration/proxy/run.rb', line 60 def registry run_config.fetch("registry", nil) end |
#repository ⇒ Object
64 65 66 |
# File 'lib/kamal/configuration/proxy/run.rb', line 64 def repository run_config.fetch("repository", "basecamp/kamal-proxy") end |
#run_command ⇒ Object
82 83 84 |
# File 'lib/kamal/configuration/proxy/run.rb', line 82 def run_command [ "kamal-proxy", "run", *optionize() ].join(" ") end |
#run_command_options ⇒ Object
90 91 92 |
# File 'lib/kamal/configuration/proxy/run.rb', line 90 def { debug: debug? || nil, "metrics-port": metrics_port }.compact end |
#version ⇒ Object
56 57 58 |
# File 'lib/kamal/configuration/proxy/run.rb', line 56 def version run_config.fetch("version", MINIMUM_VERSION) end |