Class: Kamal::Commands::Traefik

Inherits:
Base
  • Object
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

Constructor Details

This class inherits a constructor from Kamal::Commands::Base

Instance Method Details

#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

#infoObject



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_directoryObject



57
58
59
# File 'lib/kamal/commands/traefik.rb', line 57

def make_env_directory
  make_directory(env.secrets_directory)
end

#remove_containerObject



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_fileObject



61
62
63
# File 'lib/kamal/commands/traefik.rb', line 61

def remove_env_file
  [ :rm, "-f", env.secrets_file ]
end

#remove_imageObject



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

#runObject



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

#startObject



20
21
22
# File 'lib/kamal/commands/traefik.rb', line 20

def start
  docker :container, :start, "traefik"
end

#start_or_runObject



28
29
30
# File 'lib/kamal/commands/traefik.rb', line 28

def start_or_run
  any start, run
end

#stopObject



24
25
26
# File 'lib/kamal/commands/traefik.rb', line 24

def stop
  docker :container, :stop, "traefik"
end