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

#2 Move Traefik tasks out into its own library

parent abe0036a
No related branches found
Tags v0.3.0
No related merge requests found
Pipeline #
......@@ -26,6 +26,7 @@
"require": {
"php": ">=5.4.5",
"composer-plugin-api": "^1.0.0",
"lakedrops/docker-traefik": "^0.1.1",
"twig/twig": "^1.23.1"
},
"autoload": {
......
......@@ -11,6 +11,7 @@ use Composer\Package\PackageInterface;
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Script\Event as ScriptEvent;
use LakeDrops\DockerTraefik\Traefik;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Yaml;
......@@ -154,47 +155,8 @@ class Handler {
// We're ignoring this for now
}
// Update host wider traefik container
$traefikPath = $_SERVER['HOME'] . '/.traefik';
$traefikFile = $traefikPath . '/docker-compose.yml';
if ($fs->exists($traefikFile)) {
$traefik = Yaml::parse(file_get_contents($traefikFile));
}
else {
$fs->mkdir($traefikPath);
$traefik = [
'version' => '2',
'services' => [
'traefik' => [
'image' => 'traefik',
'restart' => 'unless-stopped',
'command' => '-c /dev/null --web --docker --logLevel=DEBUG',
'networks' => [],
'ports' => [
'8000:80',
'8080:8080',
],
'volumes' => [
'/var/run/docker.sock:/var/run/docker.sock',
],
],
],
'networks' => [],
];
}
if (!in_array($options['projectname'], $traefik['services']['traefik']['networks'])) {
$traefik['services']['traefik']['networks'][] = $options['projectname'];
$traefik['networks'][$options['projectname']] = [
'external' => [
'name' => $options['projectname'] . '_default',
],
];
file_put_contents($traefikFile, Yaml::dump($traefik, 9, 2));
exec('docker network create ' . $options['projectname'] . '_default');
exec('docker-compose -f ' . $traefikFile . ' --project-name traefik stop');
exec('docker-compose -f ' . $traefikFile . ' --project-name traefik up -d');
}
$traefik = new Traefik($options['projectname']);
$traefik->update();
}
protected function getFiles($projectRoot, $webRoot, $settingsPath) {
......
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