Browse Source

Merged in nginx-links (pull request #37)

Nginx links + volumen FTTH en en supervisord

Approved-by: Guillermo Espinoza <guillermo@interlink.com.ar>
Maximiliano Schvindt 6 years ago
parent
commit
3c3f8230db
2 changed files with 55 additions and 9 deletions
  1. 3 3
      tools/readme.md
  2. 52 6
      tools/src/Release.php

+ 3 - 3
tools/readme.md

@@ -59,7 +59,7 @@
 
 ####. Crear los archivos necesarios para la instalación. Dentro del directorio actual se crea un nuevo directorio con el nombre de la empresa.
 
-####.Poner el nombre del cliente, de lo contrario no va a funcionar correctamente!!!
+####. Poner el nombre del cliente, de lo contrario no va a funcionar correctamente!!!
 ####. Cambiar --client=$CLIENT por alguno de los ejemplos
 
 ####.--client=fd3
@@ -75,8 +75,8 @@
     # dind: es el nombre que le pusimos anteriormente al contenedor.
     # make:install: es el comando que se ejecuta dentro del docker para crear los archivos.
     # $CLIENT: nombre de la empresa que estoy instalando.
-    # --domain=DOMINIO-INSTALACION: es el nombre del dominio que se utilizará. El dominio final quedaría base.DOMINIO-INSTALACION.flowdat.com, 
-    # ftth.DOMINIO-INSTALACION.flowdat.com, etc.
+    # --add-nginx-links: permite crear links nginx en los servicios de los módulos web de FD3, sirve para instalaciones en modo desarrollo. Si no se agrega, por defecto no los crea.
+    # --domain=DOMINIO-INSTALACION: es el nombre del dominio que se utilizará. El dominio final quedaría base.DOMINIO-INSTALACION.flowdat.com, ftth.DOMINIO-INSTALACION.flowdat.com, etc.
     # para mas informacion ejecutar "docker run -it -v $(pwd):$(pwd) -v /var/run/docker.sock:/tmp/docker.sock dind make:install --help"
 
 ####. Una vez dentro del docker entramos al directorio de instalación.

+ 52 - 6
tools/src/Release.php

@@ -77,9 +77,14 @@ class Release extends Command
     private $_user_system;
 
     /**
-     * @var string $directory Directorio de instalacin
+     * @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.
@@ -210,6 +215,7 @@ class Release extends Command
                 'MODULE_INSTALL' => true
             ),
         );
+        $this->_add_nginx_links = false;
     }
 
     protected function configure()
@@ -253,7 +259,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 +320,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 +426,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 +457,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 +487,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 +516,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 +546,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 +598,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 +628,8 @@ 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);
@@ -648,7 +672,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 +703,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")
@@ -996,7 +1022,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');
     }
 
     /**
@@ -1338,4 +1365,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"));
+        }
+    }
 }