protected function validateNonNative() { // Check to see if Docker has been exported. if (!$this->envExported()) { $this->stdOut->writeln("<comment>Docker environment information not exported. Attempting from PLATFORM_DOCKER_MACHINE_NAME"); if (getenv('PLATFORM_DOCKER_MACHINE_NAME')) { // Attempt to boot the Docker VM if (!Machine::start(getenv('PLATFORM_DOCKER_MACHINE_NAME'))) { $this->stdOut->writeln("<error>Failed to start Docker machine</error>"); exit(1); } } else { $this->stdOut->writeln("<error>You need to start your Docker machine and export the environment information"); exit(1); } // Export the Docker VM info on behalf of the user $this->dockerParams = Machine::getEnv(getenv('PLATFORM_DOCKER_MACHINE_NAME')); foreach ($this->dockerParams as $key => $value) { putenv("{$key}={$value}"); } } // Give a Docker command a try. if (!Docker::available()) { $this->stdOut->writeln("<error>Unable to reach Docker service - try manually exporting environment variables.</error>"); exit(1); } }
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'); }
/** * {@inheritdoc} * * @see PlatformCommand::getCurrentEnvironment() */ protected function execute(InputInterface $input, OutputInterface $output) { $process = Docker::inspect(['--format="{{ .State.Running }}"', 'nginx-proxy'], true); $url = 'http://' . Platform::projectName() . '.platform'; if (trim($process->getOutput()) != 'true') { $port = Docker::getContainerPort(Compose::getContainerName(Platform::projectName(), 'nginx'), 80); $url .= ':' . $port; } $this->openUrl($url); }
protected function updateImage() { try { $this->stopProxy(); $this->stdOut->writeln("<comment>Removing nginx proxy container"); Docker::rm(['nginx-proxy']); } catch (\Exception $e) { } Docker::pull(['jwilder/nginx-proxy']); $this->createProxy(); }
/** * {@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); }
protected function createProxy() { $this->stdOut->writeln("<comment>Creating the nginx proxy container"); return Docker::run(['-d', '-p', '80:80', '-v', '/var/run/docker.sock:/tmp/docker.sock:ro', '--name', $this->containerName, 'jwilder/nginx-proxy']); }
protected function stopSeleniumContainer() { $this->stdOut->writeln("<comment>Stopping the Selenium container"); return Docker::stop([$this->containerName]); }
/** * {@inheritdoc} * * @see PlatformCommand::getCurrentEnvironment() */ protected function execute(InputInterface $input, OutputInterface $output) { $port = Docker::getContainerPort(Compose::getContainerName(Platform::projectName(), 'nginx'), 80); $url = 'http://' . Platform::projectName() . '.platform:' . trim($port); $this->openUrl($url); }
public function testAvailable() { $this->assertTrue(Docker::available()); }