Merge pull request #92 from kjellberg/fix-traefik-host-port
fix: mrsk run command fails when traefik config is empty
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
class Mrsk::Commands::Traefik < Mrsk::Commands::Base
|
class Mrsk::Commands::Traefik < Mrsk::Commands::Base
|
||||||
|
CONTAINER_PORT = 80
|
||||||
|
|
||||||
def run
|
def run
|
||||||
docker :run, "--name traefik",
|
docker :run, "--name traefik",
|
||||||
"--detach",
|
"--detach",
|
||||||
@@ -46,11 +48,15 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def port
|
def port
|
||||||
"#{config.raw_config.traefik.fetch("host_port", "80")}:80"
|
"#{host_port}:#{CONTAINER_PORT}"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def cmd_args
|
def cmd_args
|
||||||
(config.raw_config.dig(:traefik, "args") || { }).collect { |(key, value)| [ "--#{key}", value ] }.flatten
|
(config.raw_config.dig(:traefik, "args") || { }).collect { |(key, value)| [ "--#{key}", value ] }.flatten
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def host_port
|
||||||
|
config.raw_config.dig(:traefik, "host_port") || CONTAINER_PORT
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,6 +19,14 @@ class CommandsTraefikTest < ActiveSupport::TestCase
|
|||||||
new_command.run.join(" ")
|
new_command.run.join(" ")
|
||||||
end
|
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
|
test "traefik start" do
|
||||||
assert_equal \
|
assert_equal \
|
||||||
"docker container start traefik",
|
"docker container start traefik",
|
||||||
|
|||||||
Reference in New Issue
Block a user