Skip to content

Commit

Permalink
Add traefik version choice (#10)
Browse files Browse the repository at this point in the history
* Add traefik version choice

* Update to set traefik 1.7 by default
  • Loading branch information
Lissandre authored and edyan committed Sep 21, 2019
1 parent 1f46d08 commit 7dd4f79
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion stakkr/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def start(self, container: str, pull: bool, recreate: bool, proxy: bool):
self._run_iptables_rules(cts)
if proxy is True:
conf = self.config['proxy']
Proxy(conf.get('http_port'), conf.get('https_port')).start(
Proxy(conf.get('http_port'), conf.get('https_port'), version=conf.get('version')).start(
docker.get_network_name(self.project_name))

def status(self):
Expand Down
7 changes: 4 additions & 3 deletions stakkr/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
class Proxy:
"""Main class that does actions asked by the cli."""

def __init__(self, http_port: int = 80, https_port: int = 443, ct_name: str = 'proxy_stakkr'):
def __init__(self, http_port: int = 80, https_port: int = 443, ct_name: str = 'proxy_stakkr', version: str = 'latest'):
"""Set the right values to start the proxy."""
self.ports = {'http': http_port, 'https': https_port}
self.ct_name = ct_name
self.docker_client = docker.get_client()
self.version = version

def start(self, stakkr_network: str = None):
"""Start stakkr proxy if stopped."""
Expand All @@ -39,9 +40,9 @@ def _start_container(self):
"""Start proxy."""
proxy_conf_dir = get_dir('static/proxy')
try:
self.docker_client.images.pull('traefik:latest')
self.docker_client.images.pull('traefik:{}'.format(self.version))
self.docker_client.containers.run(
'traefik:latest', remove=True, detach=True,
'traefik:{}'.format(self.version), remove=True, detach=True,
hostname=self.ct_name, name=self.ct_name,
volumes=[
'/var/run/docker.sock:/var/run/docker.sock',
Expand Down
1 change: 1 addition & 0 deletions stakkr/static/config_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ proxy:
domain: localhost
http_port: 80
https_port: 443
version: 1.7.0

project_name: ''

Expand Down
3 changes: 2 additions & 1 deletion stakkr/static/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ properties:
domain: { type: string }
http_port: { type: integer }
https_port: { type: integer }
required: [enabled, domain, http_port, https_port]
version: { type: [string, number] }
required: [enabled, domain, http_port, https_port, version]

project_name:
type: string
Expand Down

0 comments on commit 7dd4f79

Please sign in to comment.