|
@@ -0,0 +1,734 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace FD3;
|
|
|
+
|
|
|
+use Docker\Composer\ServiceNotFoundException;
|
|
|
+use League\Flysystem\File;
|
|
|
+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\Console\Exception\LogicException;
|
|
|
+use Symfony\Component\Console\Question\ConfirmationQuestion;
|
|
|
+use Symfony\Component\Yaml\Yaml;
|
|
|
+
|
|
|
+class ReleaseV2 extends Release
|
|
|
+{
|
|
|
+
|
|
|
+ protected function configure()
|
|
|
+ {
|
|
|
+ $this
|
|
|
+ ->setName('make:install:v2')
|
|
|
+ ->setDescription('Create a new install files.')
|
|
|
+ ->setHelp('This command allows you to create a new installation files...')
|
|
|
+ ->addArgument('dir', InputArgument::REQUIRED, 'The directory where to create the installation.')
|
|
|
+ ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client name, if is not provided uses, the dirname of the installation', false)
|
|
|
+ ->addOption('domain', null, InputOption::VALUE_REQUIRED, 'Domain where the flowdat will be installed', 'flowdat.net')
|
|
|
+ ->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('modules', null, InputOption::VALUE_REQUIRED, 'List of modules to install separated by coma.', 'all')
|
|
|
+ ->addOption('docker-tag', null, InputOption::VALUE_REQUIRED, 'Docker tag to be used. Ej. v0.1.1', 'latest')
|
|
|
+ ->addOption('add-nginx-links', null, InputOption::VALUE_NONE, 'Add NGINX links between dockers', null)
|
|
|
+ ;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param InputInterface $input
|
|
|
+ * @param OutputInterface $output
|
|
|
+ */
|
|
|
+ protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ // Módulos a instalar
|
|
|
+ $modules = explode(',', $input->getOption('modules'));
|
|
|
+ if ($modules[0] == 'all') {
|
|
|
+ $modules = [];
|
|
|
+ foreach ($this->_modules_all as $name => $value) {
|
|
|
+ if (isset($value['MODULE_INSTALL']) && $value['MODULE_INSTALL']) {
|
|
|
+ $modules[] = $name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->AddModules($modules);
|
|
|
+
|
|
|
+ // Agrego el repositorio de extra únicamente
|
|
|
+ $this->_modules['extra']['repo'] = 'git@bitbucket.org:ikflowdat/extra.git';
|
|
|
+ $this->_modules['extra']['ref'] = 'master';
|
|
|
+
|
|
|
+ $this->directory = $input->getArgument('dir');
|
|
|
+ if (!is_dir($this->directory)) {
|
|
|
+ mkdir($this->directory, 0777, true);
|
|
|
+ }
|
|
|
+ if (file_exists($this->directory . '/' . $this->_running_log)) {
|
|
|
+ $helper = $this->getHelper('question');
|
|
|
+ $question = new ConfirmationQuestion('The ' . realpath($this->directory) . '/' . $this->_running_log . ' file exist. Read file or take parameters? (Y/n)', true);
|
|
|
+ if ($helper->ask($input, $output, $question)) {
|
|
|
+ $this->setParametersFormFile($input);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->_domain = $input->getOption('domain');
|
|
|
+ $this->_client = $input->getOption('client') ?: basename(realpath($this->directory));
|
|
|
+ $docker_tag = $input->getOption('docker-tag');
|
|
|
+
|
|
|
+ $this->internal_user_id = 2;
|
|
|
+ $this->_ansible_vars = [
|
|
|
+ 'DOMAIN' => $this->_domain,
|
|
|
+ 'CLIENT' => $this->_client,
|
|
|
+ 'CMD_USERNAME' => $this->_user_system['users'][$this->internal_user_id]['user'],
|
|
|
+ 'CMD_PASSWORD' => $this->_user_system['users'][$this->internal_user_id]['password'],
|
|
|
+ 'ENV_LIST' => 'prod,dev,test',
|
|
|
+ 'API_CIDR' => '172.20.0.0/24',
|
|
|
+ 'MYSQL_ROOT_PASSWORD' => $this->_mysql_root_pass,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $this->_add_nginx_links = (boolean)$input->getOption('add-nginx-links');
|
|
|
+
|
|
|
+ $this->_dObj = new DevOps\FileSystem(realpath($this->directory));
|
|
|
+ $this->_dObj->dirExists()->realpath();
|
|
|
+
|
|
|
+ // agrego las opciones del input a la configuracion _modues
|
|
|
+ $this->addConfigOptions($input);
|
|
|
+ // creo el archivo de log de como se ejecuto
|
|
|
+ $this->createFileRunning($input, $output);
|
|
|
+ // cargo las fuentes a clonar
|
|
|
+ $this->createGitClone();
|
|
|
+ // creo el archivo docker-compose.yml
|
|
|
+ $this->getDockerCompose($docker_tag, "host.env", "docker.infra.flowdat.com/");
|
|
|
+ // escribo el archivo de host
|
|
|
+ $this->writeHostsFile($input->getOption("host-ip"));
|
|
|
+ // escribo el archivo con las variables de entorno
|
|
|
+ $this->writeHostEnv();
|
|
|
+ // escribo los archivo oauth
|
|
|
+ $this->writeOAUTH();
|
|
|
+ // escribo un archivo con variables para ansible
|
|
|
+ $this->writeEnvVariables();
|
|
|
+ // escribo un archivo con los usuarios del sistema
|
|
|
+ $this->writeUserSystem();
|
|
|
+
|
|
|
+ $this->_dObj->file('install.yml')->content(
|
|
|
+ yaml::dump(array(
|
|
|
+ "install_dir" => realpath($this->directory),
|
|
|
+ 'docker_apps' => "base," . implode(",", $this->_ansible_vars),
|
|
|
+ 'domain' => $this->_domain,
|
|
|
+ )
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ $this->_dObj->file('ansible.cfg')->content(
|
|
|
+ "[defaults]\n" .
|
|
|
+ "inventory=inventory.ini\n"
|
|
|
+ );
|
|
|
+
|
|
|
+ $path = $this->_dObj->dirExists()->realpath()->getPath();
|
|
|
+
|
|
|
+ // copio el playbook
|
|
|
+ copy(getcwd() . "/playbook_v2.yml", $path . "/playbook.yml");
|
|
|
+ // copio el script de base de datos inicial
|
|
|
+ copy(getcwd() . "/mysql_scripts.sql", $path . "/mysql_scripts.sql");
|
|
|
+ // copio el archivo que contiene los usuarios del sistema
|
|
|
+ copy(getcwd() . "/user_system.json", $path . "/user_system.json");
|
|
|
+ // copio script mysql schema freeradius
|
|
|
+ copy(getcwd() . "/mysql/freeradius/schema.sql", $path . "/freeradius_schema.sql");
|
|
|
+ // copio el docker-compose.service
|
|
|
+ copy(getcwd() . "/docker-compose.service", $path . "/docker-compose.service");
|
|
|
+ // copio el archivo con variables de entorno de grafana
|
|
|
+ copy(getcwd() . "/grafana.env", $path . "/grafana.env");
|
|
|
+ } catch (\Throwable $error) {
|
|
|
+ throw $error;
|
|
|
+ } finally {
|
|
|
+ $this->_dObj = null;
|
|
|
+ $this->_modules = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param string $version
|
|
|
+ * @param string $host_env_file
|
|
|
+ * @param string $registry
|
|
|
+ */
|
|
|
+ function getDockerCompose($version = "latest", $host_env_file = "host.env", $registry = "docker.infra.flowdat.com/")
|
|
|
+ {
|
|
|
+ $composer = new FileFormat2("../");
|
|
|
+
|
|
|
+ $volumes = [
|
|
|
+ 'pma', 'base', 'cablemodem', 'cablemodem_upload', 'dhcp', 'ftth',
|
|
|
+ 'mapas', 'mapas_upload', 'radius', 'stats', 'radius', 'stats', 'kea',
|
|
|
+ 'geoserver', 'grafana', 'mysql', 'mongodb',
|
|
|
+ ];
|
|
|
+ foreach ($volumes as $volume) {
|
|
|
+ $composer->getVolumes()->addVolumen("{$volume}_volumen", 'local');
|
|
|
+ }
|
|
|
+
|
|
|
+ $base_vars = array(
|
|
|
+ "version" => $version,
|
|
|
+ "host_env_file" => $host_env_file,
|
|
|
+ "registry" => $registry
|
|
|
+ );
|
|
|
+
|
|
|
+ $this->addNginx($composer, $base_vars);
|
|
|
+
|
|
|
+ /**************************************************************************************/
|
|
|
+ /* Apps / Web UI / Grafana / PMA */
|
|
|
+ /**************************************************************************************/
|
|
|
+ foreach ($this->_modules_all as $module => $env) {
|
|
|
+ $method = 'add' . ucfirst($module);
|
|
|
+ if (array_key_exists($module, $this->_modules) && method_exists($this, $method)) {
|
|
|
+ $this->$method($composer, $base_vars);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**************************************************************************************/
|
|
|
+ /* 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);
|
|
|
+
|
|
|
+ $this->addGenieACS($composer, $base_vars);
|
|
|
+
|
|
|
+ $this->addFreeradius($composer, $base_vars);
|
|
|
+
|
|
|
+ /**************************************************************************************/
|
|
|
+ /* Workers */
|
|
|
+ /**************************************************************************************/
|
|
|
+ $this->addSupervisord($composer, $base_vars);
|
|
|
+ $this->addCommandWorkers($composer, $base_vars);
|
|
|
+
|
|
|
+ $this->addTftp($composer, $base_vars);
|
|
|
+
|
|
|
+ // Geoserver
|
|
|
+ $this->addGeoserver($composer, $base_vars);
|
|
|
+
|
|
|
+ // Kea
|
|
|
+ $this->addKea($composer, $base_vars);
|
|
|
+
|
|
|
+ // Swagger
|
|
|
+ $this->addSwagger($composer, $base_vars);
|
|
|
+ $this->addApi($composer, $base_vars);
|
|
|
+
|
|
|
+ $this->_dObj->file("docker-compose.yml")->content($composer->render());
|
|
|
+
|
|
|
+ // escribo un archivo inventory.ini por defecto para no tener que lanzar los docker
|
|
|
+ $this->writeInventory($composer);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function aux1(FileFormat2 $composer, $module, $config = array())
|
|
|
+ {
|
|
|
+ $version = "latest";
|
|
|
+ $registry = "";
|
|
|
+ $host_env_file = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ return $composer
|
|
|
+ ->addService($module)
|
|
|
+ ->image("{$registry}fd3/{$module}:{$version}")
|
|
|
+ ->restart($this->_docker_restart_default)
|
|
|
+ ->addEnv_file($host_env_file);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function aux2(FileFormat2 $composer, $module, $config = array())
|
|
|
+ {
|
|
|
+ $version = "latest";
|
|
|
+ $host_env_file = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $service = $this->aux1($composer, $module, $config);
|
|
|
+
|
|
|
+ $service
|
|
|
+ ->addLinks("mysql:mysql")
|
|
|
+ ->addEnv_file("running.env")
|
|
|
+ ->addEnv_file("{$module}.{$host_env_file}")
|
|
|
+ ->addVolumes("{$module}_volumen", "/opt/{$module}")
|
|
|
+ ;
|
|
|
+
|
|
|
+ $this->addNginxLinks($module, $composer);
|
|
|
+
|
|
|
+ $this->writeVariablesEnviroment("{$module}.{$host_env_file}", $module);
|
|
|
+
|
|
|
+ return $service;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function aux3(FileFormat2 $composer, $module, $config = array())
|
|
|
+ {
|
|
|
+ $service = $this->aux2($composer, $module, $config);
|
|
|
+
|
|
|
+ return $service
|
|
|
+ ->addLinks("base")
|
|
|
+ ->addEnv_file("{$module}.oauth.env")
|
|
|
+ ;
|
|
|
+ }
|
|
|
+
|
|
|
+ function addNginx(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $composer = $this->aux1($composer, 'nginx', $config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addPorts(80, 80)
|
|
|
+ ->addPorts(443, 443)
|
|
|
+ ->addVolumes("base_volumen", "/opt/base")
|
|
|
+ ->addVolumes("ftth_volumen", "/opt/ftth")
|
|
|
+ ->addVolumes("mapas_volumen", "/opt/mapas")
|
|
|
+ ->addVolumes("radius_volumen", "/opt/radius")
|
|
|
+ ->addVolumes("stats_volumen", "/opt/stats")
|
|
|
+ ->addVolumes("cablemodem_volumen", "/opt/cablemodem")
|
|
|
+ ->addVolumes("dhcp_volumen", "/opt/dhcp")
|
|
|
+ ->addVolumes("grafana_volumen", "/opt/grafana")
|
|
|
+ ->addVolumes("pma_volumen", "/opt/pma")
|
|
|
+ ->addVolumes("/var/run/docker.sock", "/tmp/docker.sock:ro")
|
|
|
+ ->addVolumes('./extra/api/', '/opt/api')
|
|
|
+ ->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");
|
|
|
+ }
|
|
|
+
|
|
|
+ function addBase(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $this->aux2($composer, 'base', $config);
|
|
|
+ }
|
|
|
+
|
|
|
+ function addFtth(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $composer = $this->aux3($composer, 'ftth', $config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addVolumes("./extra/netmiko", "/opt/netmiko")
|
|
|
+ ->addVolumes("./extra/backups-config", "/opt/ftth/web/backups-config");
|
|
|
+ }
|
|
|
+
|
|
|
+ function addStats(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $composer = $this->aux3($composer, 'stats', $config);
|
|
|
+
|
|
|
+ $composer->addLinks("jsonep_mysql:jsonep_mysql");
|
|
|
+ }
|
|
|
+
|
|
|
+ function addMapas(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $module = 'mapas';
|
|
|
+
|
|
|
+ $composer = $this->aux3($composer, $module, $config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addVolumes("{$module}_upload_volumen", "/opt/{$module}/web/uploads");
|
|
|
+ }
|
|
|
+
|
|
|
+ function addCablemodem(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $module = 'cablemodem';
|
|
|
+
|
|
|
+ $composer = $this->aux3($composer, $module, $config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addVolumes("{$module}_upload_volumen", "/opt/{$module}/web/uploads");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * atftp, tod
|
|
|
+ *
|
|
|
+ * @param FileFormat2 $composer
|
|
|
+ * @param array $config
|
|
|
+ */
|
|
|
+ function addTftp(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $composer = $this->aux1($composer, 'tftp', $config);
|
|
|
+
|
|
|
+ $composer->addPorts(69, '69/udp');
|
|
|
+ }
|
|
|
+
|
|
|
+ function addRadius(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $composer = $this->aux3($composer, 'radius', $config);
|
|
|
+ }
|
|
|
+
|
|
|
+ function addDHCP(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $composer = $this->aux3($composer, 'dhcp', $config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ // ->addVolumes("./kea/conf", "/opt/dhcp/web/kea")
|
|
|
+ ->addVolumes("kea_volumen", "/opt/dhcp/web/kea");
|
|
|
+ }
|
|
|
+
|
|
|
+ function addApi(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $module = "api";
|
|
|
+ $host_env_file = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $service = $this->aux1($composer, $module, $config);
|
|
|
+
|
|
|
+ $service
|
|
|
+ ->addEnv_file("running.env")
|
|
|
+ ->addEnv_file("{$module}.{$host_env_file}")
|
|
|
+ ->addVolumes("./extra/{$module}/", "/opt/{$module}")
|
|
|
+ ;
|
|
|
+
|
|
|
+ $this->addNginxLinks($module, $composer);
|
|
|
+
|
|
|
+ $this->writeVariablesEnviroment("{$module}.{$host_env_file}", $module);
|
|
|
+ }
|
|
|
+
|
|
|
+ function addMongDb(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $mongdb_version = "3.4";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService("mongodb")
|
|
|
+ ->image("mongo:" . $mongdb_version)
|
|
|
+ ->addVolumes("mongodb_volumen", "/data/db")
|
|
|
+ // ->addVolumes("./mongodb", "/data/db")
|
|
|
+ ->mem_limit('10g');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param FileFormat2 $composer
|
|
|
+ * @param array $config
|
|
|
+ */
|
|
|
+ function addSupervisord(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $service = $this->aux1($composer, 'supervisord', $config);
|
|
|
+
|
|
|
+ $service
|
|
|
+ ->privileged(true)
|
|
|
+ ->addLinks("geoserver")
|
|
|
+ ->addLinks("nginx", $this->getDomain("geoserver"))
|
|
|
+ ->addVolumes("./extra/supervisord/", "/etc/supervisord/")
|
|
|
+ ->addVolumes("./extra/supervisord/var/", "/var/log/supervisor/")
|
|
|
+ ->addVolumes("./extra/supervisord/sshd_config", "/etc/ssh/sshd_config")
|
|
|
+ ->addVolumes("./extra/supervisord/bin/fiberhome", "/usr/bin/fiberhome")
|
|
|
+ ->addVolumes("./extra/supervisord/bin/fiberlink", "/usr/bin/fiberlink")
|
|
|
+ ->addVolumes("./extra/supervisord/bin/huawei", "/usr/bin/huawei")
|
|
|
+ ->addVolumes("./extra/supervisord/bin/zte", "/usr/bin/zte")
|
|
|
+ ->addVolumes("stats_volumen", "/opt/stats")
|
|
|
+ ->addVolumes("ftth_volumen", "/opt/ftth")
|
|
|
+ ->addEnv_file("running.env")
|
|
|
+ ->addEnv_file("stats.host.env")
|
|
|
+ ->addEnv_file("stats.oauth.env");
|
|
|
+ }
|
|
|
+
|
|
|
+ function addMySql(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $module = "mysql";
|
|
|
+ $host_env_file = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $service = $this->aux1($composer, $module, $config);
|
|
|
+
|
|
|
+ $service
|
|
|
+ // ->addVolumes("./mysql/", "/var/lib/mysql/")
|
|
|
+ ->addVolumes("mysql_volumen", "/var/lib/mysql/")
|
|
|
+ ->addVolumes("./extra/mysql/fd3.conf", "/etc/mysql/conf.d/fd3.conf");
|
|
|
+
|
|
|
+ $this->writeVariablesEnviroment("{$module}.{$host_env_file}", $module,
|
|
|
+ array(
|
|
|
+ "MYSQL_ROOT_PASSWORD" => $this->_mysql_root_pass,
|
|
|
+ "MYSQL_USER" => $this->_mysql_user,
|
|
|
+ "MYSQL_PASSWORD" => $this->_mysql_pass,
|
|
|
+ "MYSQL_MAX_CONNECTIONS" => $this->_mysql_max_connections,
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ function addRedis(FileFormat2 $composer, $config = array(), $flavor = "dev")
|
|
|
+ {
|
|
|
+ $composer
|
|
|
+ ->addService("redis")
|
|
|
+ ->image("redis:latest")
|
|
|
+ ->command("redis-server --appendonly yes")
|
|
|
+ ->restart($this->_docker_restart_default);
|
|
|
+ }
|
|
|
+
|
|
|
+ function addGenieACS(FileFormat2 $composer, $config = array(), $flavor = "dev")
|
|
|
+ {
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService("genieacs-cwmp")
|
|
|
+ ->image($registry . "fd3/genieacs-cwmp:" . $version)
|
|
|
+ ->addLinks("mongodb")
|
|
|
+ ->addLinks("redis")
|
|
|
+ ->addPorts("7547", "7547")
|
|
|
+ ->restart($this->_docker_restart_default);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService("genieacs-nbi")
|
|
|
+ ->image($registry . "fd3/genieacs-nbi:" . $version)
|
|
|
+ ->addLinks("mongodb")
|
|
|
+ ->addLinks("redis")
|
|
|
+ ->addPorts("7557", "7557")
|
|
|
+ ->restart($this->_docker_restart_default);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService("genieacs-fs")
|
|
|
+ ->image($registry . "fd3/genieacs-fs:" . $version)
|
|
|
+ ->addLinks("mongodb")
|
|
|
+ ->addLinks("redis")
|
|
|
+ ->addPorts("7567", "7567")
|
|
|
+ ->restart($this->_docker_restart_default);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService("genieacs-gui")
|
|
|
+ ->image($registry . "fd3/genieacs-gui:" . $version)
|
|
|
+ ->addLinks("genieacs-nbi")
|
|
|
+ ->addPorts("3001", "3000")
|
|
|
+ ->restart($this->_docker_restart_default);
|
|
|
+ }
|
|
|
+
|
|
|
+ function addFreeradius(FileFormat2 $composer, $config = array(), $flavor = "dev")
|
|
|
+ {
|
|
|
+ $module = "freeradius";
|
|
|
+ $host_env_file = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $service = $this->aux1($composer, $module, $config);
|
|
|
+
|
|
|
+ $service
|
|
|
+ ->addLinks("mysql")
|
|
|
+ ->addPorts("1812:1812/udp")
|
|
|
+ ->addPorts("1813:1813/udp")
|
|
|
+ ->addPorts("3799:3799/udp")
|
|
|
+ ->addEnv_file("mysql.{$host_env_file}")
|
|
|
+ ->addVolumes("./extra/freeradius/wsdl/code/", "/var/www/html/")
|
|
|
+ ->addVolumes("./extra/freeradius/etc/cron.d", "/etc/cron.d")
|
|
|
+ ->addVolumes("./extra/freeradius/etc/freeradius", "/etc/freeradius")
|
|
|
+ ->addVolumes("./extra/freeradius/etc/supervisor/conf.d", "/etc/supervisor/conf.d");
|
|
|
+
|
|
|
+ $this->writeVariablesEnviroment("{$module}.{$host_env_file}", $module,
|
|
|
+ array(
|
|
|
+ "MYSQL_HOST" => "mysql",
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ function addPma(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $module = "pma";
|
|
|
+ $host_env_file = "host.env";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService("pma")
|
|
|
+ ->image("phpmyadmin/phpmyadmin")
|
|
|
+ ->restart($this->_docker_restart_default)
|
|
|
+ ->addLinks("mysql", "mysql")
|
|
|
+ ->addEnv_file("host.env")
|
|
|
+ ->addEnv_file("mysql." . $host_env_file)
|
|
|
+ ->addEnv_file($module . "." . $host_env_file)
|
|
|
+ ->addVolumes("pma_volumen", "/www");
|
|
|
+
|
|
|
+ $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
+ }
|
|
|
+
|
|
|
+ function addGrafana(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $module = "grafana";
|
|
|
+ $host_env_file = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService($module)
|
|
|
+ ->image("grafana/grafana:5.0.4")
|
|
|
+ ->addLinks("mysql")
|
|
|
+ ->restart($this->_docker_restart_default)
|
|
|
+ ->addEnv_file("running.env")
|
|
|
+ ->addEnv_file("grafana.env")
|
|
|
+ ->addVolumes("./extra/statsd/grafana/lib", "/var/lib/grafana");
|
|
|
+
|
|
|
+ $this->addJsonEndPoints($composer, $config);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function addJsonEndPoints(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $version = "latest";
|
|
|
+ $registry = "";
|
|
|
+ $host_env_file = "";
|
|
|
+ extract($config);
|
|
|
+ $composer
|
|
|
+ ->addService("statsd")
|
|
|
+ ->image($registry . "fd3/statsd:$version")
|
|
|
+ ->addPorts("8125", "8125/udp")
|
|
|
+ ->addLinks("mysql")
|
|
|
+ ->addLinks("mongodb")
|
|
|
+ ->restart($this->_docker_restart_default)
|
|
|
+ ->addVolumes("./extra/statsd/statsd/statsd.config.js", "/opt/config/statsd.config.js");
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService("jsendpoint")
|
|
|
+ ->image($registry . "fd3/jsonep:$version")
|
|
|
+ ->addVolumes("./extra/statsd/endpoint/json", "/opt/datasource")
|
|
|
+ ->addLinks("jsonep_mysql")
|
|
|
+ ->addLinks("jsonep_mongo")
|
|
|
+ ->restart($this->_docker_restart_default);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService("jsonep_mysql")
|
|
|
+ ->image($registry . "fd3/jsonep_mysql:$version")
|
|
|
+ ->addVolumes("./extra/statsd/endpoint/mysql", "/opt/datasource")
|
|
|
+ ->addLinks("mysql")
|
|
|
+ ->addEnv_file("mysql." . $host_env_file)
|
|
|
+ ->restart($this->_docker_restart_default);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService("jsonep_mongo")
|
|
|
+ ->image($registry . "fd3/jsonep_mongo:$version")
|
|
|
+ ->addVolumes("./extra/statsd/endpoint/mongodb", "/opt/datasource")
|
|
|
+ ->addLinks("mongodb")
|
|
|
+ ->restart($this->_docker_restart_default);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function commandWorkerAux($worker, $module, $consumer, FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $version = "latest";
|
|
|
+ $registry = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ return $composer
|
|
|
+ ->addService($worker)
|
|
|
+ ->image("{$registry}fd3/{$module}:{$version}")
|
|
|
+ ->command("bin/console rabbitmq:consumer {$consumer}")
|
|
|
+
|
|
|
+ ->restart($this->_docker_restart_default)
|
|
|
+ ->addLinks("mysql")
|
|
|
+ ->addLinks("base")
|
|
|
+ ->addLinks("nginx", $this->getDomain("base"))
|
|
|
+ ->addEnv_file("running.env")
|
|
|
+ ->addEnv_file("host.env")
|
|
|
+
|
|
|
+ ->addEnv_file("{$module}.host.env")
|
|
|
+ ->addEnviroment("AMQP_KEY", $module)
|
|
|
+ ->addVolumes("{$module}_volumen", "/opt/{$module}")
|
|
|
+ ;
|
|
|
+ }
|
|
|
+
|
|
|
+ function addCommandWorkers(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $version = "latest";
|
|
|
+ $registry = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $service = $this->commandWorkerAux('base_log_worker', 'base', 'log_consumer', $composer, $config);
|
|
|
+
|
|
|
+ $service
|
|
|
+ ->addEnviroment("SYMFONY_ENV", "prod")
|
|
|
+ ;
|
|
|
+
|
|
|
+ $service = $this->commandWorkerAux('ftth_tasklogger_worker', 'ftth', 'flowdat_tasklogger', $composer, $config);
|
|
|
+
|
|
|
+ $service
|
|
|
+ ->addVolumes("./extra/netmiko", "/opt/netmiko")
|
|
|
+ ->addVolumes("./extra/backups-config", "/opt/ftth/web/backups-config");
|
|
|
+
|
|
|
+ $service = $this->commandWorkerAux('cablemodem_tasklogger_worker', 'cablemodem', 'flowdat_tasklogger', $composer, $config);
|
|
|
+
|
|
|
+ $service = $this->commandWorkerAux('dhcp_tasklogger_worker', 'dhcp', 'flowdat_tasklogger', $composer, $config);
|
|
|
+
|
|
|
+ $service = $this->commandWorkerAux('ftth_command_worker', 'ftth', 'command_consumer', $composer, $config);
|
|
|
+
|
|
|
+ $service = $this->commandWorkerAux('stats_command_worker', 'stats', 'command_consumer', $composer, $config);
|
|
|
+
|
|
|
+ $service
|
|
|
+ ->addLinks("geoserver")
|
|
|
+ ->addLinks("nginx", $this->getDomain("geoserver"))
|
|
|
+ // ->addVolumes("./geoserver/geoserver-shapes", "/var/www/shapes")
|
|
|
+ ->addVolumes("geoserver_volumen", "/var/www/shapes");
|
|
|
+
|
|
|
+ $service = $this->commandWorkerAux('cablemodem_command_worker', 'cablemodem', 'command_consumer', $composer, $config);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param FileFormat2 $composer
|
|
|
+ * @param array $config
|
|
|
+ */
|
|
|
+ public function addGeoserver(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $version = "latest";
|
|
|
+ $registry = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService("geoserver")
|
|
|
+ ->image($registry . "fd3/geoserver:" . $version)
|
|
|
+ ->restart($this->_docker_restart_default)
|
|
|
+ ->addLinks("nginx", $this->getDomain("geoserver"))
|
|
|
+ ->addEnv_file("running.env")
|
|
|
+ ->addEnv_file("host.env")
|
|
|
+ ->addVolumes("./extra/geoserver/geoserver-data/styles", "/opt/geoserver/data_dir/styles")
|
|
|
+ ->addVolumes("geoserver_volumen", "/var/www/shapes")
|
|
|
+ // ->addVolumes("./geoserver/geoserver-shapes", "/var/www/shapes")
|
|
|
+ ->addPorts(8081, 8080)
|
|
|
+ ->mem_limit('500m');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param FileFormat2 $composer
|
|
|
+ * @param array $config
|
|
|
+ */
|
|
|
+ public function addKea(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $version = "latest";
|
|
|
+ $registry = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $module = 'kea';
|
|
|
+ $composer
|
|
|
+ ->addService("kea")
|
|
|
+ ->image($registry . "fd3/kea-ik-1.4.0:" . $version)
|
|
|
+ ->restart($this->_docker_restart_default)
|
|
|
+ ->addPorts(8086, 8080)
|
|
|
+ ->addPorts(67, '67/udp')
|
|
|
+ ->addPorts(68, '68/udp')
|
|
|
+ ->addEnv_file("running.env")
|
|
|
+ ->addEnv_file("host.env")
|
|
|
+ ->addEnv_file($module . "." . $host_env_file)
|
|
|
+ ->addVolumes("kea_volumen", "/usr/local/etc/kea")
|
|
|
+ // ->addVolumes("kea_ctrl_agent_volumen", "/usr/local/etc/kea/kea-ctrl-agent.conf")
|
|
|
+ // ->addVolumes("kea_dhcp4_volumen", "/usr/local/etc/kea/kea-dhcp4.conf")
|
|
|
+ // ->addVolumes("kea_supervisord_volumen", "/etc/supervisord")
|
|
|
+ // ->addVolumes("kea_hooks_volumen", "/opt/hooks")
|
|
|
+ ->addVolumes("./kea/conf/kea-ctrl-agent.conf", "/usr/local/etc/kea/kea-ctrl-agent.conf")
|
|
|
+ ->addVolumes("./kea/conf/kea-dhcp4.conf", "/usr/local/etc/kea/kea-dhcp4.conf")
|
|
|
+ ->addVolumes("./kea/supervisord", "/etc/supervisord")
|
|
|
+ ->addVolumes("./kea/hooks", "/opt/hooks")
|
|
|
+ ;
|
|
|
+ $this->writeVariablesEnviroment($module . "." . $host_env_file, $module,
|
|
|
+ array(
|
|
|
+ "MYSQL_ROOT_PASSWORD" => $this->_mysql_root_pass,
|
|
|
+ "MYSQL_USER" => $this->_mysql_user,
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param FileFormat2 $composer
|
|
|
+ * @param array $config
|
|
|
+ */
|
|
|
+ public function addSwagger(FileFormat2 $composer, $config = array())
|
|
|
+ {
|
|
|
+ $version = "latest";
|
|
|
+ $registry = "";
|
|
|
+ extract($config);
|
|
|
+
|
|
|
+ $composer
|
|
|
+ ->addService("swagger-ui")
|
|
|
+ ->image($registry . "fd3/swagger-ui:" . $version)
|
|
|
+ ->restart($this->_docker_restart_default)
|
|
|
+ ->addEnviroment("SWAGGER_JSON", "/opt/api/api.v1.json")
|
|
|
+ ->addEnv_file("running.env")
|
|
|
+ ->addEnv_file("host.env")
|
|
|
+ ->addPorts(8090, 8080);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|