Class: Kamal::Commands::Proxy
- Inherits:
-
Base
- Object
- Base
- Kamal::Commands::Proxy
show all
- Defined in:
- lib/kamal/commands/proxy.rb
Constant Summary
Constants inherited
from Base
Base::DOCKER_HEALTH_STATUS_FORMAT
Instance Attribute Summary
Attributes inherited from Base
#config
Instance Method Summary
collapse
Methods inherited from Base
#container_id_for, #initialize, #make_directory, #make_directory_for, #remove_directory, #remove_file, #run_over_ssh
Instance Method Details
#cleanup_traefik ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'lib/kamal/commands/proxy.rb', line 58
def cleanup_traefik
chain \
docker(:container, :stop, "traefik"),
combine(
docker(:container, :prune, "--force", "--filter", "label=org.opencontainers.image.title=Traefik"),
docker(:image, :prune, "--all", "--force", "--filter", "label=org.opencontainers.image.title=Traefik")
)
end
|
#ensure_proxy_directory ⇒ Object
67
68
69
|
# File 'lib/kamal/commands/proxy.rb', line 67
def ensure_proxy_directory
make_directory config.proxy_directory
end
|
#follow_logs(host:, timestamps: true, grep: nil, grep_options: nil) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/kamal/commands/proxy.rb', line 43
def follow_logs(host:, timestamps: true, grep: nil, grep_options: nil)
run_over_ssh pipe(
docker(:logs, container_name, ("--timestamps" if timestamps), "--tail", "10", "--follow", "2>&1"),
(%(grep "#{grep}"#{" #{grep_options}" if grep_options}) if grep)
).join(" "), host: host
end
|
#get_boot_options ⇒ Object
75
76
77
|
# File 'lib/kamal/commands/proxy.rb', line 75
def get_boot_options
combine [ :cat, config.proxy_options_file ], [ :echo, "\"#{config.proxy_options_default.join(" ")}\"" ], by: "||"
end
|
#info ⇒ Object
27
28
29
|
# File 'lib/kamal/commands/proxy.rb', line 27
def info
docker :ps, "--filter", "name=^#{container_name}$"
end
|
#logs(timestamps: true, since: nil, lines: nil, grep: nil, grep_options: nil) ⇒ Object
37
38
39
40
41
|
# File 'lib/kamal/commands/proxy.rb', line 37
def logs(timestamps: true, since: nil, lines: nil, grep: nil, grep_options: nil)
pipe \
docker(:logs, container_name, ("--since #{since}" if since), ("--tail #{lines}" if lines), ("--timestamps" if timestamps), "2>&1"),
("grep '#{grep}'#{" #{grep_options}" if grep_options}" if grep)
end
|
#remove_container ⇒ Object
50
51
52
|
# File 'lib/kamal/commands/proxy.rb', line 50
def remove_container
docker :container, :prune, "--force", "--filter", "label=org.opencontainers.image.title=kamal-proxy"
end
|
#remove_image ⇒ Object
54
55
56
|
# File 'lib/kamal/commands/proxy.rb', line 54
def remove_image
docker :image, :prune, "--all", "--force", "--filter", "label=org.opencontainers.image.title=kamal-proxy"
end
|
#remove_proxy_directory ⇒ Object
71
72
73
|
# File 'lib/kamal/commands/proxy.rb', line 71
def remove_proxy_directory
remove_directory config.proxy_directory
end
|
#reset_boot_options ⇒ Object
79
80
81
|
# File 'lib/kamal/commands/proxy.rb', line 79
def reset_boot_options
remove_file config.proxy_options_file
end
|
#run ⇒ Object
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/kamal/commands/proxy.rb', line 4
def run
docker :run,
"--name", container_name,
"--network", "kamal",
"--detach",
"--restart", "unless-stopped",
"--volume", "kamal-proxy-config:/home/kamal-proxy/.config/kamal-proxy",
"\$\(#{get_boot_options.join(" ")}\)",
config.proxy_image
end
|
#start ⇒ Object
15
16
17
|
# File 'lib/kamal/commands/proxy.rb', line 15
def start
docker :container, :start, container_name
end
|
#start_or_run ⇒ Object
23
24
25
|
# File 'lib/kamal/commands/proxy.rb', line 23
def start_or_run
combine start, run, by: "||"
end
|
#stop(name: container_name) ⇒ Object
19
20
21
|
# File 'lib/kamal/commands/proxy.rb', line 19
def stop(name: container_name)
docker :container, :stop, name
end
|
#version ⇒ Object
31
32
33
34
35
|
# File 'lib/kamal/commands/proxy.rb', line 31
def version
pipe \
docker(:inspect, container_name, "--format '{{.Config.Image}}'"),
[ :cut, "-d:", "-f2" ]
end
|