Class: Kamal::Commands::Traefik
- Inherits:
-
Base
- Object
- Base
- Kamal::Commands::Traefik
show all
- Defined in:
- lib/kamal/commands/traefik.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, #run_over_ssh
Instance Method Details
#cleanup_kamal_proxy ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'lib/kamal/commands/traefik.rb', line 65
def cleanup_kamal_proxy
chain \
docker(:container, :stop, "kamal-proxy"),
combine(
docker(:container, :prune, "--force", "--filter", "label=org.opencontainers.image.title=kamal-proxy"),
docker(:image, :prune, "--all", "--force", "--filter", "label=org.opencontainers.image.title=kamal-proxy")
)
end
|
#follow_logs(host:, grep: nil, grep_options: nil) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/kamal/commands/traefik.rb', line 42
def follow_logs(host:, grep: nil, grep_options: nil)
run_over_ssh pipe(
docker(:logs, "traefik", "--timestamps", "--tail", "10", "--follow", "2>&1"),
(%(grep "#{grep}"#{" #{grep_options}" if grep_options}) if grep)
).join(" "), host: host
end
|
#info ⇒ Object
32
33
34
|
# File 'lib/kamal/commands/traefik.rb', line 32
def info
docker :ps, "--filter", "name=^traefik$"
end
|
#logs(since: nil, lines: nil, grep: nil, grep_options: nil) ⇒ Object
36
37
38
39
40
|
# File 'lib/kamal/commands/traefik.rb', line 36
def logs(since: nil, lines: nil, grep: nil, grep_options: nil)
pipe \
docker(:logs, "traefik", (" --since #{since}" if since), (" --tail #{lines}" if lines), "--timestamps", "2>&1"),
("grep '#{grep}'#{" #{grep_options}" if grep_options}" if grep)
end
|
#make_env_directory ⇒ Object
57
58
59
|
# File 'lib/kamal/commands/traefik.rb', line 57
def make_env_directory
make_directory(env.secrets_directory)
end
|
#remove_container ⇒ Object
49
50
51
|
# File 'lib/kamal/commands/traefik.rb', line 49
def remove_container
docker :container, :prune, "--force", "--filter", "label=org.opencontainers.image.title=Traefik"
end
|
#remove_env_file ⇒ Object
61
62
63
|
# File 'lib/kamal/commands/traefik.rb', line 61
def remove_env_file
[ :rm, "-f", env.secrets_file ]
end
|
#remove_image ⇒ Object
53
54
55
|
# File 'lib/kamal/commands/traefik.rb', line 53
def remove_image
docker :image, :prune, "--all", "--force", "--filter", "label=org.opencontainers.image.title=Traefik"
end
|
#run ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/kamal/commands/traefik.rb', line 5
def run
docker :run, "--name traefik",
"--detach",
"--restart", "unless-stopped",
*publish_args,
"--volume", "/var/run/docker.sock:/var/run/docker.sock",
*env_args,
*config.logging_args,
*label_args,
*docker_options_args,
image,
"--providers.docker",
*cmd_option_args
end
|
#start ⇒ Object
20
21
22
|
# File 'lib/kamal/commands/traefik.rb', line 20
def start
docker :container, :start, "traefik"
end
|
#start_or_run ⇒ Object
28
29
30
|
# File 'lib/kamal/commands/traefik.rb', line 28
def start_or_run
any start, run
end
|
#stop ⇒ Object
24
25
26
|
# File 'lib/kamal/commands/traefik.rb', line 24
def stop
docker :container, :stop, "traefik"
end
|