Skip to content
Snippets Groups Projects
Commit ed04901d authored by jurgenhaas's avatar jurgenhaas
Browse files

#4 Add support for portainer

parent e02a579b
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,11 @@ class Traefik {
*/
protected $key_filename;
/**
* @var bool
*/
protected $addon_portainer = FALSE;
/**
* Traefik constructor.
*
......@@ -70,6 +75,13 @@ class Traefik {
$this->key_filename = $key_filename;
}
/**
* @param bool $addon_portainer
*/
public function setAddonPortainer(bool $addon_portainer): void {
$this->addon_portainer = $addon_portainer;
}
/**
* Update the Traefik container.
*
......@@ -115,8 +127,8 @@ class Traefik {
* @return array
*/
private function defaultDockerCompose(): array {
return [
'version' => '3',
$config = [
'version' => '3.3',
'services' => [
'traefik' => [
'image' => 'traefik:v2.3',
......@@ -160,6 +172,33 @@ class Traefik {
],
],
];
if ($this->addon_portainer) {
$config['services']['portainer'] = [
'image' => 'portainer/portainer-ce:2.0.0',
'command' => '-H unix:///var/run/docker.sock',
'restart' => 'unless-stopped',
'networks' => [
'internal',
],
'labels' => [
'traefik.enable=true',
'traefik.network=internal',
'traefik.http.routers.frontend.rule=Host(`portainer.' . $this->domain . '`)',
'traefik.http.routers.frontend.entrypoints=websecure',
'traefik.http.services.frontend.loadbalancer.server.port=9000',
'traefik.http.routers.frontend.service=frontend',
'traefik.http.routers.edge.rule=Host(`edge.' . $this->domain . '`)',
'traefik.http.routers.edge.entrypoints=websecure',
'traefik.http.services.edge.loadbalancer.server.port=8000',
'traefik.http.routers.edge.service=edge',
],
'volumes' => [
'./portainerdata:/data',
'/var/run/docker.sock:/var/run/docker.sock:ro',
],
];
}
return $config;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment