Exemplo n.º 1
0
 public function copyConfigs()
 {
     // Copy configs
     foreach ($this->configsToCopy() as $fileName) {
         $this->fs->copy($this->resourcesDir . '/conf/' . $fileName, $this->projectPath . '/docker/conf/' . $fileName);
     }
     // Change the default xdebug remote host on Mac, which uses a VM
     if (!Docker::native()) {
         $phpConfFile = $this->projectPath . '/docker/conf/php.ini';
         $phpConf = file_get_contents($phpConfFile);
         $phpConf = str_replace('172.17.42.1', '192.168.99.1', $phpConf);
         file_put_contents($phpConfFile, $phpConf);
     }
     // Quick fix to make nginx PHP_IDE_CONFIG dynamic for now.
     $nginxConfFile = $this->projectPath . '/docker/conf/nginx.conf';
     $nginxConf = file_get_contents($nginxConfFile);
     $nginxConf = str_replace('{{ platform }}', Platform::projectName() . '.' . Platform::projectTld(), $nginxConf);
     file_put_contents($nginxConfFile, $nginxConf);
     // stub in for Solr configs
     $finder = new Finder();
     $finder->in($this->resourcesDir . '/conf/solr')->files()->depth('< 1')->name('*');
     /** @var \SplFileInfo $file */
     foreach ($finder as $file) {
         $this->fs->copy($file->getPathname(), $this->projectPath . '/docker/conf/solr/' . $file->getFilename());
     }
     // copy ssl
     $this->fs->copy($this->resourcesDir . '/ssl/nginx.crt', $this->projectPath . '/docker/ssl/nginx.crt');
     $this->fs->copy($this->resourcesDir . '/ssl/nginx.key', $this->projectPath . '/docker/ssl/nginx.key');
 }
Exemplo n.º 2
0
 /**
  * Initiates basic variables.
  */
 public function __construct()
 {
     $this->fs = new Filesystem();
     $this->projectName = Platform::projectName();
     $this->projectTld = Platform::projectTld();
     $this->containerName = Compose::getContainerName(Platform::projectName(), 'mariadb');
 }
Exemplo n.º 3
0
 public function testProjectName()
 {
     $this->assertEquals('phpunit', Platform::projectName());
     // Change values
     file_put_contents(Platform::rootDir() . '/' . Config::PLATFORM_CONFIG, '');
     Config::reset();
     $this->assertNull(Platform::projectName());
 }
 public function testAddExtras()
 {
     $config = new ComposeContainers(Platform::rootDir(), Platform::projectName());
     $config->addRedis();
     $config_converted = Yaml::parse($config->yaml());
     $this->assertCount(4, $config_converted);
     $config->addSolr();
     $config_converted = Yaml::parse($config->yaml());
     $this->assertCount(5, $config_converted);
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $url = 'http://' . Platform::projectName() . '.' . Platform::projectTld();
     // See if the nginx-proxy is running.
     try {
         $process = Docker::inspect(['--format="{{ .State.Running }}"', 'nginx-proxy'], true);
         if (trim($process->getOutput()) != 'true') {
             $port = Docker::getContainerPort(Compose::getContainerName(Platform::projectName(), 'nginx'), 80);
             $url .= ':' . $port;
         }
     } catch (\Exception $e) {
     }
     $this->openUrl($url, $this->stdErr, $this->stdOut);
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $containerName = null;
     $type = $input->getArgument('service');
     $containerNameMap = ['http' => 'nginx', 'php' => 'phpfpm', 'db' => 'mariadb', 'redis' => 'redis', 'solr' => 'solr', 'memcache' => 'memcached', 'blackfire' => 'blackfire'];
     if (!isset($containerNameMap[$type])) {
         $this->stdOut->writeln("<error>Invalid service type</error>");
         return 1;
     } else {
         $containerName = $containerNameMap[$type];
     }
     $builder = ProcessBuilder::create(['docker', 'exec', '-it', Compose::getContainerName(Platform::projectName(), $containerName), 'bash']);
     $process = $builder->getProcess();
     // Need to set tty true, ProccessHelper doesn't allow this setting.
     $process->setTty(true);
     try {
         $process->mustRun(null);
     } catch (ProcessFailedException $e) {
         $message = "The command failed with the exit code: " . $process->getExitCode();
         $message .= "\n\nFull command: " . $process->getCommandLine();
         throw new \Exception($message);
     }
     return $process->isSuccessful();
 }
Exemplo n.º 7
0
 /**
  * {@inheritdoc}
  *
  * @see PlatformCommand::getCurrentEnvironment()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $processBuilder = ProcessBuilder::create(['drush', $input->getArgument('cmd'), '--root=' . Platform::webDir(), '--uri=' . Platform::projectName() . '.' . Platform::projectTld()]);
     passthru($processBuilder->getProcess()->getCommandLine());
 }