Merge pull request #85 from clowder/traefik-host-port
Customizable Traefik host port
This commit is contained in:
@@ -358,6 +358,15 @@ traefik:
|
|||||||
|
|
||||||
This will start the traefik container with `--accesslog=true accesslog.format=json`.
|
This will start the traefik container with `--accesslog=true accesslog.format=json`.
|
||||||
|
|
||||||
|
### Traefik's host port binding
|
||||||
|
|
||||||
|
By default Traefik binds to port 80 of the host machine, it can be configured to use an alternative port:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
traefik:
|
||||||
|
host_port: 8080
|
||||||
|
```
|
||||||
|
|
||||||
### 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:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
|
|||||||
"--detach",
|
"--detach",
|
||||||
"--restart", "unless-stopped",
|
"--restart", "unless-stopped",
|
||||||
"--log-opt", "max-size=#{MAX_LOG_SIZE}",
|
"--log-opt", "max-size=#{MAX_LOG_SIZE}",
|
||||||
"--publish", "80:80",
|
"--publish", port,
|
||||||
"--volume", "/var/run/docker.sock:/var/run/docker.sock",
|
"--volume", "/var/run/docker.sock:/var/run/docker.sock",
|
||||||
"traefik",
|
"traefik",
|
||||||
"--providers.docker",
|
"--providers.docker",
|
||||||
@@ -45,6 +45,10 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
|
|||||||
docker :image, :prune, "--all", "--force", "--filter", "label=org.opencontainers.image.title=Traefik"
|
docker :image, :prune, "--all", "--force", "--filter", "label=org.opencontainers.image.title=Traefik"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def port
|
||||||
|
"#{config.raw_config.traefik.fetch("host_port", "80")}:80"
|
||||||
|
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
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ class CommandsTraefikTest < ActiveSupport::TestCase
|
|||||||
assert_equal \
|
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 --accesslog.format json --metrics.prometheus.buckets 0.1,0.3,1.2,5.0",
|
"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 --accesslog.format json --metrics.prometheus.buckets 0.1,0.3,1.2,5.0",
|
||||||
new_command.run.join(" ")
|
new_command.run.join(" ")
|
||||||
|
|
||||||
|
@config[:traefik]["host_port"] = "8080"
|
||||||
|
assert_equal \
|
||||||
|
"docker run --name traefik --detach --restart unless-stopped --log-opt max-size=10m --publish 8080:80 --volume /var/run/docker.sock:/var/run/docker.sock traefik --providers.docker --log.level=DEBUG --accesslog.format json --metrics.prometheus.buckets 0.1,0.3,1.2,5.0",
|
||||||
|
new_command.run.join(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
test "traefik start" do
|
test "traefik start" do
|
||||||
|
|||||||
Reference in New Issue
Block a user