diff --git a/lib/mrsk/commands/traefik.rb b/lib/mrsk/commands/traefik.rb index b8ae8c28..b8cbe343 100644 --- a/lib/mrsk/commands/traefik.rb +++ b/lib/mrsk/commands/traefik.rb @@ -1,4 +1,6 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base + CONTAINER_PORT = 80 + def run docker :run, "--name traefik", "--detach", @@ -45,12 +47,16 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base docker :image, :prune, "--all", "--force", "--filter", "label=org.opencontainers.image.title=Traefik" end - def port - "#{config.raw_config.traefik.fetch("host_port", "80")}:80" + def port + "#{host_port}:#{CONTAINER_PORT}" end private def cmd_args (config.raw_config.dig(:traefik, "args") || { }).collect { |(key, value)| [ "--#{key}", value ] }.flatten end + + def host_port + config.raw_config.dig(:traefik, "host_port") || CONTAINER_PORT + end end diff --git a/test/commands/traefik_test.rb b/test/commands/traefik_test.rb index ae0d471e..54bc260a 100644 --- a/test/commands/traefik_test.rb +++ b/test/commands/traefik_test.rb @@ -19,6 +19,14 @@ class CommandsTraefikTest < ActiveSupport::TestCase new_command.run.join(" ") end + test "run without configuration" do + @config.delete(:traefik) + + assert_equal \ + "docker run --name traefik --detach --restart unless-stopped --log-opt max-size=10m --publish 80:80 --volume /var/run/docker.sock:/var/run/docker.sock traefik --providers.docker --log.level=DEBUG", + new_command.run.join(" ") + end + test "traefik start" do assert_equal \ "docker container start traefik",