Custom cmd args for Traefik
This commit is contained in:
12
README.md
12
README.md
@@ -235,6 +235,18 @@ RUN --mount=type=secret,id=GITHUB_TOKEN \
|
|||||||
bundle install
|
bundle install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Using command arguments for Traefik
|
||||||
|
|
||||||
|
You can customize the traefik command line:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
traefik:
|
||||||
|
accesslog: true
|
||||||
|
accesslog.format: json
|
||||||
|
metrics.prometheus: true
|
||||||
|
metrics.prometheus.buckets: 0.1,0.3,1.2,5.0
|
||||||
|
```
|
||||||
|
|
||||||
### Configuring build args for new images
|
### Configuring build args for new images
|
||||||
|
|
||||||
Build arguments that aren't secret can also be configured:
|
Build arguments that aren't secret can also be configured:
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
|
|||||||
"-v /var/run/docker.sock:/var/run/docker.sock",
|
"-v /var/run/docker.sock:/var/run/docker.sock",
|
||||||
"traefik",
|
"traefik",
|
||||||
"--providers.docker",
|
"--providers.docker",
|
||||||
"--log.level=DEBUG"
|
"--log.level=DEBUG",
|
||||||
|
*cmd_args
|
||||||
end
|
end
|
||||||
|
|
||||||
def start
|
def start
|
||||||
@@ -44,4 +45,9 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
|
|||||||
def remove_image
|
def remove_image
|
||||||
docker :image, :prune, "-a", "-f", "--filter", "label=org.opencontainers.image.title=Traefik"
|
docker :image, :prune, "-a", "-f", "--filter", "label=org.opencontainers.image.title=Traefik"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def cmd_args
|
||||||
|
(config.raw_config.dig(:traefik, "args") || { }).collect { |(key, value)| [ "--#{key}", value ] }.flatten
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
23
test/commands/traefik_test.rb
Normal file
23
test/commands/traefik_test.rb
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
require "test_helper"
|
||||||
|
require "mrsk/configuration"
|
||||||
|
require "mrsk/commands/traefik"
|
||||||
|
|
||||||
|
class CommandsTraefikTest < ActiveSupport::TestCase
|
||||||
|
setup do
|
||||||
|
@config = {
|
||||||
|
service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ],
|
||||||
|
traefik: { "args" => { "accesslog.format" => "json", "metrics.prometheus.buckets" => "0.1,0.3,1.2,5.0" } }
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
test "run" do
|
||||||
|
assert_equal \
|
||||||
|
[:docker, :run, "--name traefik", "-d", "--restart unless-stopped", "-p 80:80", "-v /var/run/docker.sock:/var/run/docker.sock", "traefik", "--providers.docker", "--accesslog.format", "json", "--metrics.prometheus.buckets", "0.1,0.3,1.2,5.0"],
|
||||||
|
new_command.run
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def new_command
|
||||||
|
Mrsk::Commands::Traefik.new(Mrsk::Configuration.new(@config, version: "123"))
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user