Class: Mrsk::Commands::Traefik

Inherits:
Base
  • Object
show all
Defined in:
lib/mrsk/commands/traefik.rb

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#initialize, #run_over_ssh

Constructor Details

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

Instance Method Details

#follow_logs(host:, grep: nil) ⇒ Object



34
35
36
37
38
39
# File 'lib/mrsk/commands/traefik.rb', line 34

def follow_logs(host:, grep: nil)
  run_over_ssh pipe(
    docker(:logs, "traefik", "-t", "-n", "10", "-f", "2>&1"),
    (%(grep "#{grep}") if grep)
  ).join(" "), host: host
end

#infoObject



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

def info
  docker :ps, "--filter", "name=traefik"
end

#logs(since: nil, lines: nil, grep: nil) ⇒ Object



28
29
30
31
32
# File 'lib/mrsk/commands/traefik.rb', line 28

def logs(since: nil, lines: nil, grep: nil)
  pipe \
    docker(:logs, "traefik", (" --since #{since}" if since), (" -n #{lines}" if lines), "-t", "2>&1"),
    ("grep '#{grep}'" if grep)
end

#remove_containerObject



41
42
43
# File 'lib/mrsk/commands/traefik.rb', line 41

def remove_container
  docker :container, :prune, "-f", "--filter", "label=org.opencontainers.image.title=Traefik"
end

#remove_imageObject



45
46
47
# File 'lib/mrsk/commands/traefik.rb', line 45

def remove_image
  docker :image, :prune, "-a", "-f", "--filter", "label=org.opencontainers.image.title=Traefik"
end

#runObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/mrsk/commands/traefik.rb', line 4

def run
  docker :run, "--name traefik",
    "-d",
    "--restart unless-stopped",
    "-p 80:80",
    "-v /var/run/docker.sock:/var/run/docker.sock",
    "traefik",
    "--providers.docker",
    "--log.level=DEBUG",
    *cmd_args
end

#startObject



16
17
18
# File 'lib/mrsk/commands/traefik.rb', line 16

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

#stopObject



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

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