Skip to content

Commit

Permalink
Fix traefik argument volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
stepri committed Aug 25, 2023
1 parent 9363b6a commit d5d7e94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions lib/kamal/commands/traefik.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def run
*env_args,
*config.logging_args,
*label_args,
*volume_args,
*docker_options_args,
image,
"--providers.docker",
Expand Down Expand Up @@ -72,6 +73,10 @@ def label_args
argumentize "--label", labels
end

def volume_args
argumentize "--volume", volumes
end

def env_args
env_config = config.traefik["env"] || {}

Expand All @@ -86,6 +91,10 @@ def labels
config.traefik["labels"] || []
end

def volumes
config.traefik["volumes"] || []
end

def image
config.traefik.fetch("image") { DEFAULT_IMAGE }
end
Expand Down
4 changes: 2 additions & 2 deletions test/commands/traefik_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CommandsTraefikTest < ActiveSupport::TestCase
"docker run --name traefik --detach --restart unless-stopped --publish 80:80 --volume /var/run/docker.sock:/var/run/docker.sock --log-opt max-size=\"10m\" #{@image} --providers.docker --log.level=\"DEBUG\" --accesslog.format=\"json\" --api.insecure --metrics.prometheus.buckets=\"0.1,0.3,1.2,5.0\"",
new_command.run.join(" ")

@config[:traefik]["options"] = {"volume" => %w[./letsencrypt/acme.json:/letsencrypt/acme.json] }
@config[:traefik]["options"] = {"volumes" => %w[./letsencrypt/acme.json:/letsencrypt/acme.json] }
assert_equal \
"docker run --name traefik --detach --restart unless-stopped --publish 80:80 --volume /var/run/docker.sock:/var/run/docker.sock --log-opt max-size=\"10m\" --volume \"./letsencrypt/acme.json:/letsencrypt/acme.json\" #{@image} --providers.docker --log.level=\"DEBUG\" --accesslog.format=\"json\" --api.insecure --metrics.prometheus.buckets=\"0.1,0.3,1.2,5.0\"",
new_command.run.join(" ")
Expand All @@ -59,7 +59,7 @@ class CommandsTraefikTest < ActiveSupport::TestCase
"docker run --name traefik --detach --restart unless-stopped --publish 80:80 --volume /var/run/docker.sock:/var/run/docker.sock --log-opt max-size=\"10m\" #{@image} --providers.docker --log.level=\"DEBUG\" --accesslog.format=\"json\" --api.insecure --metrics.prometheus.buckets=\"0.1,0.3,1.2,5.0\"",
new_command.run.join(" ")

@config[:traefik]["options"] = {"volume" => %w[./letsencrypt/acme.json:/letsencrypt/acme.json], "publish" => %w[8080:8080], "memory" => "512m"}
@config[:traefik]["options"] = {"volumes" => %w[./letsencrypt/acme.json:/letsencrypt/acme.json], "publish" => %w[8080:8080], "memory" => "512m"}
assert_equal \
"docker run --name traefik --detach --restart unless-stopped --publish 80:80 --volume /var/run/docker.sock:/var/run/docker.sock --log-opt max-size=\"10m\" --volume \"./letsencrypt/acme.json:/letsencrypt/acme.json\" --publish \"8080:8080\" --memory \"512m\" #{@image} --providers.docker --log.level=\"DEBUG\" --accesslog.format=\"json\" --api.insecure --metrics.prometheus.buckets=\"0.1,0.3,1.2,5.0\"",
new_command.run.join(" ")
Expand Down

0 comments on commit d5d7e94

Please sign in to comment.