|
@@ -77,9 +77,14 @@ class Release extends Command
|
|
|
private $_user_system;
|
|
|
|
|
|
/**
|
|
|
- * @var string $directory Directorio de instalaci�n
|
|
|
+ * @var string $directory Directorio de instalacion
|
|
|
*/
|
|
|
private $directory;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @var boolean $_use_nginx_links Para indicar si se crean los links nginx entre los modulos
|
|
|
+ */
|
|
|
+ private $_use_nginx_links;
|
|
|
|
|
|
/**
|
|
|
* Constructor.
|
|
@@ -182,10 +187,21 @@ class Release extends Command
|
|
|
'OAUTH' => false,
|
|
|
'MODULE_INSTALL' => true
|
|
|
),
|
|
|
- "pma" => array(
|
|
|
+ "api" => array(
|
|
|
'HOST_ENV' => true,
|
|
|
"VAR_ENV" => array(
|
|
|
'VIRTUAL_HOST' => '',
|
|
|
+ 'HTTPS_METHOD' => 'nohttps',
|
|
|
+ ),
|
|
|
+ 'OAUTH' => false,
|
|
|
+ 'MODULE_INSTALL' => true
|
|
|
+ ),
|
|
|
+ "pma" => array(
|
|
|
+ 'HOST_ENV' => true,
|
|
|
+ "VAR_ENV" => array(
|
|
|
+ "PMA_HOST"=> "mysql",
|
|
|
+ "PMA_PORT"=> "3306",
|
|
|
+ "PMA_ABSOLUTE_URI"=> ""
|
|
|
),
|
|
|
'OAUTH' => false,
|
|
|
'MODULE_INSTALL' => false
|
|
@@ -210,6 +226,7 @@ class Release extends Command
|
|
|
'MODULE_INSTALL' => true
|
|
|
),
|
|
|
);
|
|
|
+ $this->_add_nginx_links = false;
|
|
|
}
|
|
|
|
|
|
protected function configure()
|
|
@@ -253,7 +270,8 @@ class Release extends Command
|
|
|
->addOption('inventory', null, InputOption::VALUE_REQUIRED, 'Write inventory.ini by default.', true)
|
|
|
->addOption('docker-tag', null, InputOption::VALUE_REQUIRED, 'Docker tag to be used. Ej. v0.1.1', "latest")
|
|
|
->addOption('all-ref', null, InputOption::VALUE_REQUIRED, 'Git reference (branch or tag) to clone all app. Ej. 0.1.1', "")
|
|
|
- ->addOption('general-version', null, InputOption::VALUE_REQUIRED, 'Set options all-ref and docker-tag with this value. Ej. 0.1.1', "");
|
|
|
+ ->addOption('general-version', null, InputOption::VALUE_REQUIRED, 'Set options all-ref and docker-tag with this value. Ej. 0.1.1', "")
|
|
|
+ ->addOption('add-nginx-links', null, InputOption::VALUE_NONE, 'Add NGINX links between dockers', null);
|
|
|
}
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
@@ -313,8 +331,10 @@ class Release extends Command
|
|
|
$this->_ansible_vars["CMD_USERNAME"] = $this->_user_system['users'][$this->internal_user_id]['user'];
|
|
|
$this->_ansible_vars["CMD_PASSWORD"] = $this->_user_system['users'][$this->internal_user_id]['password'];
|
|
|
$this->_ansible_vars["ENV_LIST"] = "prod,dev,test";
|
|
|
- $this->_ansible_vars["API_CIDR"] = "172.20.0.0/24";
|
|
|
- $this->_ansible_vars["MYSQL_ROOT_PASSWORD"] = $this->_mysql_root_pass;
|
|
|
+ $this->_ansible_vars["API_CIDR"] = "172.20.0.0/24";
|
|
|
+ $this->_ansible_vars["MYSQL_ROOT_PASSWORD"] = $this->_mysql_root_pass;
|
|
|
+
|
|
|
+ $this->_add_nginx_links = (boolean)$input->getOption('add-nginx-links');
|
|
|
|
|
|
$dObj = new DevOps\FileSystem(realpath($this->directory));
|
|
|
$dObj->dirExists()->realpath();
|
|
@@ -417,6 +437,8 @@ class Release extends Command
|
|
|
->addEnv_file($module . "." . $host_env_file)
|
|
|
->addVolumes("./$module/", "/opt/$module");
|
|
|
|
|
|
+ $this->addNginxLinks($module, $composer);
|
|
|
+
|
|
|
$this->addBuild($module, $composer);
|
|
|
|
|
|
$this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
@@ -446,6 +468,8 @@ class Release extends Command
|
|
|
->addVolumes("./extra/netmiko", "/opt/netmiko")
|
|
|
->addVolumes("./extra/backups-config", "/opt/ftth/web/backups-config");
|
|
|
|
|
|
+ $this->addNginxLinks($module, $composer);
|
|
|
+
|
|
|
$this->addBuild($module, $composer);
|
|
|
|
|
|
$this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
@@ -474,6 +498,8 @@ class Release extends Command
|
|
|
->addEnv_file($module . "." . $host_env_file)
|
|
|
->addEnv_file("$module.oauth.env");
|
|
|
|
|
|
+ $this->addNginxLinks($module, $composer);
|
|
|
+
|
|
|
$this->addBuild($module, $composer);
|
|
|
|
|
|
$this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
@@ -501,6 +527,9 @@ class Release extends Command
|
|
|
->addEnv_file("$module.oauth.env")
|
|
|
->addVolumes("./$module/", "/opt/$module")
|
|
|
->addVolumes("./$module/web/uploads", "/opt/$module/web/uploads");
|
|
|
+
|
|
|
+ $this->addNginxLinks($module, $composer);
|
|
|
+
|
|
|
$this->addBuild($module, $composer);
|
|
|
|
|
|
$this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
@@ -528,6 +557,8 @@ class Release extends Command
|
|
|
->addEnv_file("$module.oauth.env")
|
|
|
->addVolumes("./$module/", "/opt/$module")
|
|
|
->addVolumes("./$module/web/uploads", "/opt/$module/web/uploads");
|
|
|
+
|
|
|
+ $this->addNginxLinks($module, $composer);
|
|
|
|
|
|
$this->addBuild($module, $composer);
|
|
|
|
|
@@ -578,6 +609,8 @@ class Release extends Command
|
|
|
->addEnv_file("$module.oauth.env")
|
|
|
->addVolumes("./$module/", "/opt/$module");
|
|
|
|
|
|
+ $this->addNginxLinks($module, $composer);
|
|
|
+
|
|
|
$this->addBuild($module, $composer);
|
|
|
|
|
|
$this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
@@ -606,6 +639,34 @@ class Release extends Command
|
|
|
->addVolumes("./kea/conf", "/opt/dhcp/web/kea")
|
|
|
;
|
|
|
|
|
|
+ $this->addNginxLinks($module, $composer);
|
|
|
+
|
|
|
+ $this->addBuild($module, $composer);
|
|
|
+
|
|
|
+ $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
+ }
|
|
|
+
|
|
|
+ function addApi(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $module = "api";
|
|
|
+ $version = "latest";
|
|
|
+ $registry = "";
|
|
|
+ $host_env_file = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService($module)
|
|
|
+ ->image($registry . "fd3/$module:" . $version)
|
|
|
+ ->restart($this->_docker_restart_default)
|
|
|
+ ->build("./extra/" . $module)
|
|
|
+ ->addLinks('nginx:base.fd3.flowdat.com')
|
|
|
+ ->addLinks('nginx:cablemodem.fd3.flowdat.com')
|
|
|
+ ->addLinks('nginx:ftth.fd3.flowdat.com')
|
|
|
+ ->addLinks('nginx:radius.fd3.flowdat.com')
|
|
|
+ ->addEnv_file("running.env")
|
|
|
+ ->addEnv_file($host_env_file)
|
|
|
+ ->addEnv_file($module . "." . $host_env_file)
|
|
|
+ ->addVolumes("./extra/$module/", "/opt/$module");
|
|
|
$this->addBuild($module, $composer);
|
|
|
|
|
|
$this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
@@ -634,7 +695,9 @@ class Release extends Command
|
|
|
->addVolumes("./cablemodem/", "/opt/cablemodem")
|
|
|
->addVolumes("./dhcp/", "/opt/dhcp")
|
|
|
->addVolumes("./grafana/", "/opt/grafana")
|
|
|
+ ->addVolumes('./extra/api/', '/opt/api')
|
|
|
->addVolumes("/var/run/docker.sock", "/tmp/docker.sock:ro")
|
|
|
+ ->addVolumes("pma_volumen", "/opt/pma")
|
|
|
->addVolumes("./extra/nginx/certs", "/etc/nginx/certs:ro")
|
|
|
->addVolumes("./extra/nginx/conf.d", "/etc/nginx/conf.d")
|
|
|
->addVolumes("./extra/nginx/share", "/usr/share/nginx/html");
|
|
@@ -648,7 +711,8 @@ class Release extends Command
|
|
|
$composer
|
|
|
->addService("mongodb")
|
|
|
->image("mongo:" . $mongdb_version)
|
|
|
- ->addVolumes("./mongodb", "/data/db");
|
|
|
+ ->addVolumes("./mongodb", "/data/db")
|
|
|
+ ->mem_limit('10g');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -678,6 +742,7 @@ class Release extends Command
|
|
|
->addVolumes("./extra/supervisord/bin/huawei", "/usr/bin/huawei")
|
|
|
->addVolumes("./extra/supervisord/bin/zte", "/usr/bin/zte")
|
|
|
->addVolumes("./stats", "/opt/stats")
|
|
|
+ ->addVolumes("./ftth", "/opt/ftth")
|
|
|
->addEnv_file("running.env")
|
|
|
->addEnv_file($host_env_file)
|
|
|
->addEnv_file("stats.host.env")
|
|
@@ -781,17 +846,18 @@ class Release extends Command
|
|
|
function addPma(FileFormat2 $composer, $config = array())
|
|
|
{
|
|
|
$module = "pma";
|
|
|
- $host_env_file = "";
|
|
|
+ $host_env_file = "host.env";
|
|
|
extract($config);
|
|
|
|
|
|
$composer
|
|
|
- ->addService("phpmyadmin")
|
|
|
+ ->addService("pma")
|
|
|
->image("phpmyadmin/phpmyadmin")
|
|
|
->restart($this->_docker_restart_default)
|
|
|
- ->addPorts(8080, 80)
|
|
|
- ->addLinks("mysql", "db")
|
|
|
+ ->addLinks("mysql", "mysql")
|
|
|
+ ->addEnv_file("host.env")
|
|
|
->addEnv_file("mysql." . $host_env_file)
|
|
|
- ->addEnv_file($module . "." . $host_env_file);
|
|
|
+ ->addEnv_file($module . "." . $host_env_file)
|
|
|
+ ->addVolumes("pma_volumen", "/www");
|
|
|
|
|
|
$this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
}
|
|
@@ -996,7 +1062,8 @@ class Release extends Command
|
|
|
->addEnv_file("host.env")
|
|
|
->addVolumes("./extra/geoserver/geoserver-data/styles", "/opt/geoserver/data_dir/styles")
|
|
|
->addVolumes("./geoserver/geoserver-shapes", "/var/www/shapes")
|
|
|
- ->addPorts(8081, 8080);
|
|
|
+ ->addPorts(8081, 8080)
|
|
|
+ ->mem_limit('500m');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1012,7 +1079,7 @@ class Release extends Command
|
|
|
$module = 'kea';
|
|
|
$composer
|
|
|
->addService("kea")
|
|
|
- ->image($registry . "fd3/kea-1.4.0:" . $version)
|
|
|
+ ->image($registry . "fd3/kea-ik-1.4.0:" . $version)
|
|
|
// ->build("./extra/kea/")
|
|
|
->restart($this->_docker_restart_default)
|
|
|
->addPorts(8086, 8080)
|
|
@@ -1048,17 +1115,17 @@ class Release extends Command
|
|
|
->image($registry . "fd3/swagger-ui:" . $version)
|
|
|
->build("./extra/swagger/")
|
|
|
->restart($this->_docker_restart_default)
|
|
|
- ->addEnviroment("SWAGGER_JSON", "/foo/ftth.json")
|
|
|
+ ->addEnviroment("SWAGGER_JSON", "/opt/api/api.v1.json")
|
|
|
->addEnv_file("running.env")
|
|
|
->addEnv_file("host.env")
|
|
|
- ->addPorts(8085, 8080);
|
|
|
+ ->addPorts(8090, 8080);
|
|
|
}
|
|
|
|
|
|
|
|
|
function getDockerComposer($version = "latest", $host_env_file = "host.env", $registry = "docker.infra.flowdat.com/")
|
|
|
{
|
|
|
$composer = new FileFormat2("../");
|
|
|
-
|
|
|
+ $composer->getVolumes()->addVolumen('pma_volumen', 'local');
|
|
|
$base_vars = array(
|
|
|
"version" => $version,
|
|
|
"host_env_file" => $host_env_file,
|
|
@@ -1080,11 +1147,13 @@ class Release extends Command
|
|
|
/* Servicios */
|
|
|
/**************************************************************************************/
|
|
|
$this->addMySql($composer, $base_vars);
|
|
|
+ $this->addPma($composer, $base_vars);
|
|
|
$composer
|
|
|
->addService("amqp")
|
|
|
->build("./extra/amqp/")
|
|
|
->image("rabbitmq:3-management")
|
|
|
->addPorts(15674, 15674)
|
|
|
+ ->addPorts(15672, 15672)
|
|
|
->restart($this->_docker_restart_default);
|
|
|
$this->addMongDb($composer, $base_vars);
|
|
|
$this->addRedis($composer, $base_vars);
|
|
@@ -1107,6 +1176,7 @@ class Release extends Command
|
|
|
|
|
|
// Swagger
|
|
|
$this->addSwagger($composer, $base_vars);
|
|
|
+ $this->addApi($composer, $base_vars);
|
|
|
|
|
|
$this->_dObj->file("docker-compose.yml")->content($composer->render());
|
|
|
|
|
@@ -1181,7 +1251,9 @@ class Release extends Command
|
|
|
foreach ($app['VAR_ENV'] as $key => $value) {
|
|
|
if ($key == 'VIRTUAL_HOST') {
|
|
|
$env .= "VIRTUAL_HOST=" . $this->getDomain($module) . "\n";
|
|
|
- } else {
|
|
|
+ } else if($key == 'PMA_ABSOLUTE_URI') {
|
|
|
+ $env .= "PMA_ABSOLUTE_URI=" . $this->getDomain("pma") . "\n";
|
|
|
+ }else{
|
|
|
$env .= $key . "=" . $value . "\n";
|
|
|
}
|
|
|
}
|
|
@@ -1338,4 +1410,23 @@ class Release extends Command
|
|
|
|
|
|
$this->_dObj->file("inventory.ini")->content($tmp . $all);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Funcion que agrega links nginx a los modulos principales (para instalacion dev)
|
|
|
+ * @param string $module Contiene el nombre del modulo.
|
|
|
+ * @param FileFormat2 $composer Contiene el objeto FileFormat2.
|
|
|
+ */
|
|
|
+ private function addNginxLinks($module, FileFormat2 $composer)
|
|
|
+ {
|
|
|
+ if ($this->_add_nginx_links) {
|
|
|
+ $composer->service($module)
|
|
|
+ ->addLinks("nginx", $this->getDomain("base"))
|
|
|
+ ->addLinks("nginx", $this->getDomain("ftth"))
|
|
|
+ ->addLinks("nginx", $this->getDomain("cablemodem"))
|
|
|
+ ->addLinks("nginx", $this->getDomain("mapas"))
|
|
|
+ ->addLinks("nginx", $this->getDomain("stats"))
|
|
|
+ ->addLinks("nginx", $this->getDomain("dhcp"))
|
|
|
+ ->addLinks("nginx", $this->getDomain("radius"));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|