浏览代码

tool para manejar instalaciones

Luciano Andrade 8 年之前
父节点
当前提交
4d35aa5725

+ 15 - 0
tools/cmd.php

@@ -0,0 +1,15 @@
+#!/usr/bin/env php
+<?php
+
+require __DIR__.'/vendor/autoload.php';
+
+use Symfony\Component\Console\Application;
+
+$app = new Application();
+
+$app->add(new FD3\Release());
+$app->add(new FD3\GetSource());
+$app->add(new FD3\MergeHostsFile());
+$app->add(new FD3\DockerInventory());
+
+$app->run();

+ 19 - 0
tools/composer.json

@@ -0,0 +1,19 @@
+{
+    "require": {
+        "lucciano/php-docker-lib": "dev-master",
+        "kzykhys/git": "^0.1.2",
+        "docker-php/docker-php": "^1.24",
+	"symfony/console": "^3.3",
+        "magicalex/write-ini-file": "^1.2",
+        "rlanvin/php-ip": "1.*"
+    },
+    "autoload": {
+        "psr-4": {"FD3\\": "src/"}
+    },
+    "repositories": [
+        {
+            "type": "vcs",
+            "url":  "https://github.com/lucciano/php-docker-lib.git"
+        }
+    ]
+}

文件差异内容过多而无法显示
+ 1927 - 0
tools/composer.lock


二进制
tools/src/.GetSource.php.swp


二进制
tools/src/.MergeHostsFile.php.swp


二进制
tools/src/.Release.php.swn


二进制
tools/src/.Release.php.swo


二进制
tools/src/.Release.php.swp


+ 65 - 0
tools/src/DevOps/FileSystem.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace FD3\DevOps;
+
+use \FilesystemIterator;
+
+class FileSystem {
+
+	protected $path;
+
+	function __construct ($path =  "."){
+		$this->path = $path;
+	}
+	
+	function dirExists($mode = 0777, $recursive = true ){
+		if(!is_dir($this->path)){
+			mkdir($this->path, $mode, $recursive);
+		}
+		return $this;
+	}
+
+	function realPath(){
+		return new FileSystem(realpath($this->path));
+	}
+
+	function file($name){
+		$newpath = $this->path . "/". $name;
+		return new FileObject(basename($newpath), new FileSystem(dirname($newpath)));
+	}
+
+	function getPath(){ return $this->path; }
+}
+
+use WriteiniFile\WriteiniFile;
+
+class FileObject{
+	protected $fileName;
+	protected $context;
+
+	function __construct($fileName, FileSystem $fs = null){
+		$this->fileName = $fileName;
+		if(!$fs){
+			$fs = new FileSystem(getcwd());
+		}
+
+		$this->context = $fs;
+	}
+
+	function getPath(){
+		return $this->context->dirExists()->realpath()->getPath() . "/".$this->fileName;
+	}
+
+	function content($content){
+		$full_path = $this->getPath();
+		file_put_contents($full_path, $content);
+		return $this;
+	}
+
+	function writeIniConfig($config){
+		$f = new WriteiniFile($this->getPath());
+		$f->create($config);
+		$f->write();
+		return $this;
+	}
+}

+ 68 - 0
tools/src/DockerInventory.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace FD3;
+
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+use Docker\Docker;
+
+use FD3\DevOps\FileSystem;
+
+class DockerInventory extends Command{
+    protected function configure()
+    {
+        $this 
+        ->setName('docker:inventory')
+
+        ->setDescription('Get a ansible inventory based on the running container and the docker .')
+
+        ->setHelp('...')
+
+	 ->addArgument('dir', InputArgument::REQUIRED, 'The dir where the docker-composer.yml files is located.')
+	// ->addOption('source-name', null, InputOption::VALUE_REQUIRED, 'Rename the source to this name.', "upstream")
+    ;
+    }
+
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+	$dir = $input->getArgument("dir");
+	$projname = basename(realpath($dir));
+	$docker = new Docker();
+	$containerManager = $docker->getContainerManager();
+	$containers = $containerManager->findAll();
+
+	$groups = array();
+	foreach($containers as $container){
+		$labels = $container->getLabels();
+		if(strcmp($labels["com.docker.compose.project"], $projname)===0){
+			if(!isset($groups[$labels["com.docker.compose.service"]])){
+				$groups[$labels["com.docker.compose.service"]] = array();
+			}
+			foreach($container->getNames() as $names){
+				if(strpos($names, "/") === 0){
+					$name = substr($names,1);
+				}
+				$groups[$labels["com.docker.compose.service"]][] = $name;
+			}
+		}
+	}
+
+	$contAll = "";
+	$cont = "";
+	foreach($groups as $name => $group){
+		
+		$cont .= "\n[".$name."]\n";
+		foreach($group as $host){
+			$cont .= $host."\n";
+			$contAll .= $host."\n";
+		}
+	}
+
+	$dirObj = new FileSystem($dir);
+	$dirObj->file("inventory.ini")->content($cont . "\n[all]\n".$contAll);
+    }
+}

+ 63 - 0
tools/src/GetSource.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace FD3;
+
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+use PHPGit\Git;
+use PHPGit\Exception\GitException;
+
+class GetSource extends Command
+{
+    protected function configure()
+    {
+        $this 
+        ->setName('get:source')
+
+        ->setDescription('Get the source using a ini file.')
+
+        ->setHelp('This command allows you to fetch code based on the git.ini file configuration...')
+
+	 ->addArgument('ini_file', InputArgument::REQUIRED, 'The ini file from where to get the source code config.')
+	 ->addOption('source-name', null, InputOption::VALUE_REQUIRED, 'Rename the source to this name.', "upstream")
+    ;
+    }
+
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+	$file = $input->getArgument("ini_file");
+	
+	$realpath = realpath($file);
+	$dirname = dirname($realpath);
+	if(!chdir($dirname)){
+		throw new \Exception("Can't change working directory to ".$dirname);
+	}
+	
+	$content = parse_ini_file($realpath, true);
+	foreach($content as $sec => $conf){
+		$git = new Git();
+		$git_path = $dirname.'/'.$sec;
+
+		try{
+			$git->clone($conf["url"], $git_path);
+		}catch (GitException $e){
+			$output->write("repo $sec exists \n");
+		}
+		$git->setRepository($git_path);
+
+		try{
+			$git->remote->rm($input->getOption("source-name"));
+		}catch (GitException $e){
+			
+		}
+		$git->remote->add($input->getOption("source-name"), $conf["url"]);
+
+		$git->checkout($conf["branch"]);
+	}
+	
+    }
+}

+ 69 - 0
tools/src/MergeHostsFile.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace FD3;
+
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class MergeHostsFile extends Command
+{
+    protected function configure()
+    {
+        $this 
+        ->setName('merge:hostsfile')
+
+        ->setDescription('Merge (or remove) two hostfiles to /etc/hosts.')
+
+        ->setHelp('This command allows you to a new installation...')
+
+	 ->addArgument('file', InputArgument::REQUIRED, 'The file to use.')
+	 ->addOption('dest',null, InputOption::VALUE_REQUIRED, 'The /etc/hosts file where to write', "/etc/hosts")
+	 ->addOption('ref', null, InputOption::VALUE_REQUIRED, 'The reference to add as a comment to simplify the remove', "handled by fd3")
+	 ->addOption('del', 'd', InputOption::VALUE_NONE, 'Remove the merged values based on the ref parameter')
+    ;
+    }
+
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+        $file = $input->getArgument('file');
+	$dest = $input->getOption("dest");
+	$id   = $input->getOption("ref");
+	$del = $input->getOption("del");
+	$dest_content = explode("\n",file_get_contents($dest));
+	$orig_content = explode("\n",file_get_contents($file));
+
+	foreach($dest_content as $k => $spect){
+		if(strpos($spect, $id) !== false){
+			unset($dest_content[$k]);
+		}
+	}
+	foreach($orig_content as $k => $spect){
+		$spect = trim($spect);
+		preg_match("|[^\s]*|", $spect, $match);
+		if(isset($match[0])){
+			try{
+				$ip= \IP::create($match[0]);
+				$orig_content[$k] = $spect . "\t#$id";
+			}catch(\InvalidArgumentException $e){
+			}
+		}
+	}
+	$content = "";
+	foreach($dest_content as $line){
+		$content .= $line . "\n";
+	}
+	if(!$del){	
+
+		foreach($orig_content as $line){
+			$content .= $line . "\n";
+		}
+	}
+
+	file_put_contents($dest, $content);
+	
+	
+    }
+}

+ 355 - 0
tools/src/Release.php

@@ -0,0 +1,355 @@
+<?php
+
+namespace FD3;
+
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+use Docker\Composer\FileFormat2;
+
+use Symfony\Component\Yaml\Yaml;
+
+class Release extends Command
+{
+    protected function configure()
+    {
+        $this 
+        ->setName('make:install')
+
+        ->setDescription('Create a new install.')
+
+        ->setHelp('This command allows you to create a new installation...')
+
+	 ->addArgument('dir', InputArgument::REQUIRED, 'The directory where to create the installation.')
+	 ->addOption('base-repo',null, InputOption::VALUE_REQUIRED, 'Git clone Url fot the app Base', "git@bitbucket.org:ikflowdat/base.git")
+	 ->addOption('base-ref', null, InputOption::VALUE_REQUIRED, 'Git reference (branch or tag) to clone the Base app', "master")
+
+	 ->addOption('ftth-repo',null, InputOption::VALUE_REQUIRED, 'Git clone Url fot the app Base', "git@bitbucket.org:ikflowdat/ftth.git")
+	 ->addOption('ftth-ref', null, InputOption::VALUE_REQUIRED, 'Git reference (branch or tag) to clone the Ftth appFtth', "master")
+
+	 ->addOption('mapas-repo',null, InputOption::VALUE_REQUIRED, 'Git clone Url fot the app Base', "git@bitbucket.org:ikflowdat/mapas.git")
+	 ->addOption('mapas-ref', null, InputOption::VALUE_REQUIRED, 'Git reference (branch or tag) to clone the Mapas app', "master")
+
+	 ->addOption('stats-repo',null, InputOption::VALUE_REQUIRED, 'Git clone Url fot the app Base', "git@bitbucket.org:ikflowdat/stats.git")
+	 ->addOption('stats-ref', null, InputOption::VALUE_REQUIRED, 'Git reference (branch or tag) to clone the Stats app', "master")
+
+	 ->addOption('extra-repo',null, InputOption::VALUE_REQUIRED, 'Git clone Url fot the app Base', "git@bitbucket.org:ikflowdat/extra.git")
+	 ->addOption('extra-ref', null, InputOption::VALUE_REQUIRED, 'Git reference (branch or tag) to clone the Extra files and apps', "master")
+
+	 ->addOption('host-ip', null, InputOption::VALUE_REQUIRED, 'Ip of the runnning host to be added to the /etc/hosts file, eventually', "127.0.1.1")
+
+	 ->addOption('domain', null, InputOption::VALUE_REQUIRED, 'Domain where the flowdat will be installed', "fd3.flowdat.com")
+
+    ;
+    }
+
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+        $dir = $input->getArgument('dir');
+	$domain = $input->getOption("domain");
+	$dObj = new DevOps\FileSystem($dir);
+	$dObj->dirExists()->realpath();
+
+	$install_config = array(
+		"base" => array(
+			'url' => $input->getOption("base-repo"),
+			'branch' => $input->getOption("base-ref"),
+		),
+		"ftth" => array(
+			'url' => $input->getOption("ftth-repo"),
+			'branch' => $input->getOption("ftth-ref"),
+		),
+		"mapas" => array(
+			'url' => $input->getOption("mapas-repo"),
+			'branch' => $input->getOption("mapas-ref"),
+		),
+		"stats" => array(
+			'url' => $input->getOption("stats-repo"),
+			'branch' => $input->getOption("stats-ref"),
+		),
+		"extra" => array(
+			'url' => $input->getOption("extra-repo"),
+			'branch' => $input->getOption("extra-ref"),
+		),
+	);
+
+	$dObj->file("git.ini")->writeIniConfig($install_config);
+
+	$dObj->file("docker-compose.yml")->content(
+		$this->getDockerComposer( "dev",  "host.env", "docker.infra.flowdat.com/", $domain)
+	);
+
+	$config_ip = $input->getOption("host-ip");
+
+	$hostConfig = $this->getHostConfig($config_ip, $domain);
+	$hostfile_content = "";
+	foreach($hostConfig as $host => $ip){
+		$hostfile_content .= $ip . "\t". $host. "\n";
+	}
+	$dObj->file("hostsFile")->content($hostfile_content);
+	$hostEnvConfig = $this->getHostEnv($domain);
+	$env_content = "";
+	foreach($hostEnvConfig as $var => $val){
+		$env_content .= $var."=".$val."\n";
+	}
+
+	$dObj->file('host.env')->content($env_content);
+	$dObj->file('mapas.oauth.env')->content("");
+	$dObj->file('ftth.oauth.env')->content("");
+	$dObj->file('stats.oauth.env')->content("");
+
+	$dObj->file('install.yml')->content(
+		yaml::dump(array(
+			"install_dir" => realpath($dir),
+			'docker_apps' => array('base', 'stats', 'ftth', 'mapas'),
+                        'domain'      => $domain,
+			)
+		)
+	);
+
+	$dObj->file('ansible.cfg')->content(
+	"[defaults]
+inventory=inventory.ini
+        "
+	);
+
+	
+    }
+
+    function getHostEnv($fd_domain = "fd3.flowdat.com"){
+	return array(
+		"HOST_BASE" 	=> "base.". $fd_domain,
+		"HOST_FTTH"	=> "ftth.". $fd_domain,
+		"HOST_MAPAS" 	=> "mapas.".$fd_domain,
+		"HOST_STATS"	=> "stats.".$fd_domain,
+		"HOST_PMA"	=> "pma.".$fd_domain,
+	);
+    }
+
+    function getHostConfig($config_ip, $fd_domain = "fd3.flowdat.com"){
+	return array(
+		"base.". $fd_domain => $config_ip,
+		"ftth.". $fd_domain => $config_ip,
+		"mapas.". $fd_domain => $config_ip,
+		"stats.". $fd_domain => $config_ip,
+		"grafana.". $fd_domain => $config_ip,
+		"pma.". $fd_domain => $config_ip,
+	);
+
+    }
+
+    function getDockerComposer( $v = "dev", $host_env_file = "host.env", $registry = "docker.infra.flowdat.com/", $fd_domain = "fd3.flowdat.com")
+{
+
+$mysql_root_pass="235r2342gtfsw";
+$mysql_user="iksop";
+$mysq_pass="235r2342gtfsw";
+
+$oauth_client = "1_3323sq6urn8kwccg8s4ok848ggwwgkw4c08wsc4cwkc08osocc";
+$oauth_client_secret = "5w7gx6ptdoo4g8cwwo88o8gowosgco84sso08ssow0osg88g8k";
+
+	$composer = new FileFormat2("../");
+
+	$composer->addService("base")
+		->image($registry."fd3_base:" . $v)
+		->build("./base/")
+		->restart("always")
+		->addLinks("mysql")
+		->addLinks("amqp")
+		->addEnviroment("VIRTUAL_HOST", "base.".$fd_domain)
+		->addEnviroment("HOST_FTTH", 	"ftth.".$fd_domain)
+		->addEnviroment("HOST_STATS", 	"stats.".$fd_domain)
+		->addEnviroment("HOST_MAPAS", 	"mapas.".$fd_domain)
+		->addEnviroment("HOST_BASE", 	"base." .$fd_domain)
+		->addVolumes("./base/", "/opt/base")
+	;
+
+	$composer->addService("ftth")
+		->image($registry."fd3_ftth:" . $v)
+		->build("./ftth/")
+		->restart("always")
+		->addLinks("mysql")
+		->addLinks("base")
+		->addLinks("amqp")
+		->addLinks("nginx", "base.".$fd_domain)
+
+		->addEnv_file("ftth.oauth.env")
+		->addEnviroment("VIRTUAL_HOST", "ftth.".$fd_domain)
+		->addEnviroment("HOST_FTTH",	"ftth.".$fd_domain)
+		->addEnviroment("HOST_STATS", 	"stats.".$fd_domain)
+		->addEnviroment("HOST_MAPAS", 	"mapas.".$fd_domain)
+		->addEnviroment("HOST_BASE", 	"base.".$fd_domain)
+		//->addEnviroment("OAUTH_CLIENT_ID", $oauth_client)
+		//->addEnviroment("OAUTH_CLIENT_SECRET", $oauth_client_secret)
+		//->addEnviroment("HTTPS_METHOD", 	"nohttps")
+
+		->addVolumes("./ftth/", "/opt/ftth")
+	;
+
+	$composer->addService("mapas")
+		->image($registry."fd3_mapas:" . $v)
+		->build("./mapas/")
+		->addLinks("mysql")
+		->addLinks("base")
+		->addLinks("amqp")
+		->addLinks("nginx", "base.".$fd_domain)
+		->addEnv_file("mapas.oauth.env")
+
+		->addEnviroment("VIRTUAL_HOST", "mapas.".$fd_domain)
+		->addEnviroment("HOST_FTTH",	"ftth.".$fd_domain)
+		->addEnviroment("HOST_STATS", 	"stats.".$fd_domain)
+		->addEnviroment("HOST_MAPAS", 	"mapas.".$fd_domain)
+		->addEnviroment("HOST_BASE", 	"base.".$fd_domain)
+		//->addEnviroment("OAUTH_CLIENT_ID", $oauth_client)
+		//->addEnviroment("OAUTH_CLIENT_SECRET", $oauth_client_secret)
+		//->addEnviroment("HTTPS_METHOD", 	"nohttps")
+
+		->addVolumes("./mapas/", "/opt/mapas")
+	;
+
+
+	$composer->addService("stats")
+		->image($registry."fd3_stats:" . $v)
+		->build("./stats/")
+		->addLinks("mysql")
+		->addLinks("base")
+		->addLinks("amqp")
+		->addLinks("nginx", "base.".$fd_domain)
+		->addVolumes("./stats/", "/opt/stats")
+		->addEnv_file("stats.oauth.env")
+
+		->addEnviroment("VIRTUAL_HOST", "stats.".$fd_domain)
+		->addEnviroment("HOST_FTTH",	"ftth.".$fd_domain)
+		->addEnviroment("HOST_STATS", 	"stats.".$fd_domain)
+		->addEnviroment("HOST_MAPAS", 	"mapas.".$fd_domain)
+		->addEnviroment("HOST_BASE", 	"base.".$fd_domain)
+		//->addEnviroment("OAUTH_CLIENT_ID", 	$oauth_client)
+		//->addEnviroment("OAUTH_CLIENT_SECRET",	$oauth_client_secret)
+		//->addEnviroment("HTTPS_METHOD", 	"nohttps")
+
+	;
+
+	/**************************************************************************************/
+	/* Servicios */
+	/**************************************************************************************/
+	$composer->addService("mysql")->image($registry."fd3_mysql:". $v)
+		->build("./extra/mysql")
+		->addVolumes("./mysql/", "/var/lib/mysql/")
+
+		->addEnviroment("MYSQL_ROOT_PASSWORD", $mysql_root_pass)
+		->addEnviroment("MYSQL_USER", $mysql_user)
+		->addEnviroment("MYSQL_PASSWORD", $mysq_pass)
+	;
+
+	$composer->addService("amqp")->image("rabbitmq:3-management")
+		->restart("always")
+		->addPorts(8072, 15672)
+	;
+
+
+	/**************************************************************************************/
+	/* Workers */
+	/**************************************************************************************/
+
+	$composer->addService("ftth_worker")->image($registry."fd3_ftth:" . $v)
+		->build("./ftth/")
+		->restart("always")
+		->addLinks("mysql")
+		->addLinks("base")
+		->addLinks("amqp")
+		->addLinks("nginx", "base.".$fd_domain)
+
+
+		->addEnviroment("VIRTUAL_HOST", "ftth.".$fd_domain)
+		->addEnviroment("HTTPS_METHOD", 	"nohttps")
+		->addEnviroment("HOST_FTTH",	"ftth.".$fd_domain)
+		->addEnviroment("HOST_STATS", 	"stats.".$fd_domain)
+		->addEnviroment("HOST_MAPAS", 	"mapas.".$fd_domain)
+		->addEnviroment("HOST_BASE", 	"base.".$fd_domain)
+		//->addEnviroment("OAUTH_CLIENT_ID", $oauth_client)
+		//->addEnviroment("OAUTH_CLIENT_SECRET", $oauth_client_secret)
+
+		->addVolumes("./ftth/", "/opt/ftth")
+	;
+
+
+	$composer->addService("phpmyadmin")->image("phpmyadmin/phpmyadmin")
+		->restart("always")
+		->addPorts(8080, 80)
+		->addLinks("mysql", "db")
+
+		->addEnviroment("MYSQL_ROOT_PASSWORD", $mysql_root_pass)
+		->addEnviroment("VIRTUAL_HOST", "pma.".$fd_domain)
+		->addEnviroment("HTTPS_METHOD", 	"nohttps")
+	;
+
+
+	$composer->addService("grafana")->image("grafana/grafana")
+
+		->addLinks("jsendpoint","endpoint")
+		->addLinks("mysql")
+		->restart("always")
+		->addEnviroment("VIRTUAL_HOST", "grafana.".$fd_domain)
+		->addEnviroment("HTTPS_METHOD", 	"nohttps")
+
+		->addEnviroment("./statsd/grafana/lib", "/var/lib/grafana")
+		->addEnviroment("GF_SECURITY_ADMIN_PASSWORD", "queRini6")
+		->addEnviroment("GF_INSTALL_PLUGINS", "grafana-simple-json-datasource")
+		->addEnviroment("GF_AUTH_ANONYMOUS_ORG_NAME", "Main Org.")
+		->addEnviroment("GF_AUTH_ANONYMOUS_ORG_ROLE", "Viewer")
+		->addEnviroment("GF_AUTH_ANONYMOUS_ENABLED", "true")
+		->addEnviroment("GF_DATABASE_URL", "mysql://root:".$mysql_root_pass."@mysql:3306/grafana")
+		->addEnviroment("GF_SERVER_ROOT_URL", "http://grafana.".$fd_domain."/")
+	;
+
+	$composer->addService("jsendpoint")
+		->image($registry."jsendpoint:$v")
+		->build("./extra/statsd/endpoint/mysql")
+		->addVolumes("./extra/statsd/endpoint/mysql", "/opt/datasource")
+		->addLinks("mysql")
+		->addPorts(9000, 8000)
+		->addEnviroment("MYSQL_ROOT_PASSWORD", $mysql_root_pass)
+		->restart("always")
+		;
+
+	$composer->addService("statsd")->build("./extra/statsd/statsd")
+		->image($registry."statsd:$v")
+		->addPorts("8125", "8125/udp")
+		->addLinks("mysql")
+		->restart("always")
+	;
+
+	$composer->addService("supervisord")->build("./extra/supervisord")
+		->image($registry."supervisord:$v")
+		->privileged(true)
+		->restart("always")
+		->addEnviroment("./extra/supervisord/", "/etc/supervisord/")
+		->addEnviroment("./extra/supervisord/var/", "/var/log/supervisor/")
+		->addEnviroment("./extra/supervisord/sshd_config", "/etc/ssh/sshd_config")
+		->addEnviroment("./extra/supervisord/bin/fiberhome", "/usr/bin/fiberhome")
+		->addEnviroment("./extra/supervisord/bin/fiberlink", "/usr/bin/fiberlink")
+	 
+	;
+
+	$composer->addService("nginx")->image($registry."fd3_nginx:".$v)
+		->build("extra/nginx/")
+		->addEnv_file($host_env_file)
+		->restart("always")
+		//->addLinks("base")
+		//->addLinks("ftth")
+		//->addLinks("mapas")
+		//->addLinks("stats")
+		->addPorts(80, 80)
+		->addPorts(443, 443)
+		->addVolumes("/var/run/docker.sock", "/tmp/docker.sock:ro")
+		->addVolumes("./extra/nginx/certs", "/etc/nginx/certs:ro")
+		->addVolumes("./extra/nginx/vhost.d", "/etc/nginx/vhost.d")
+		->addVolumes("./extra/nginx/share", "/usr/share/nginx/html")
+	;
+
+
+	return $composer->render();
+    }
+}