Пример #1
0
 /**
  * @param string $command
  *
  * @return bool Did the command succeed?
  */
 protected function testCommand($command)
 {
     try {
         $this->processRunner->run($command);
     } catch (ProcessFailedException $e) {
         return false;
     }
     return true;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function findByName($name)
 {
     $rawOutput = $this->processRunner->run('docker-compose ps -q ' . $name)->getOutput();
     $ids = $this->parseOutput($rawOutput);
     if (count($ids) == 0) {
         throw new \RuntimeException(sprintf('No container named "%s" found', $name));
     }
     return current($ids);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if ($this->processRunner->run($this->getVersionCommand(), false)->isSuccessful()) {
         $this->userInteraction->write(sprintf('"%s" is already installed', $this->getName()));
     } else {
         $this->userInteraction->write(sprintf('Installing "%s"', $this->getName()));
         $this->processRunner->run($this->getInstallCommand());
         $this->userInteraction->write(sprintf('"%s" successfully installed', $this->getName()));
     }
 }
Пример #4
0
 private function changeDinghyDnsResolverNamespace()
 {
     $process = new Process('dinghy version');
     $this->processRunner->run($process);
     $dinghyVersionOutput = $process->getOutput();
     $dinghyVersion = substr(trim($dinghyVersionOutput), strlen('Dinghy '));
     $dnsMasqConfiguration = '/usr/local/Cellar/dinghy/' . $dinghyVersion . '/cli/dinghy/dnsmasq.rb';
     $process = new Process('sed -i \'\' \'s/docker/zzz-dinghy/\' ' . $dnsMasqConfiguration);
     $this->processRunner->run($process);
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->userInteraction->writeTitle("Pulling image aacebedo/dnsdock");
     $this->userInteraction->write("Check docker machine is running");
     if (!$this->machine->isRunning()) {
         $this->userInteraction->write("Starting machine");
         $this->machine->start();
     }
     $this->userInteraction->write("Setting environment variables");
     $this->processRunner->run($this->machine->getEnvironmentDeclaration());
     $this->userInteraction->write("Pulling image aacebedo/dnsdock, this could take a while when run for the first time");
     $this->processRunner->run('docker pull aacebedo/dnsdock:latest-amd64');
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('service') !== null) {
         $service = $input->getOption('service');
     } else {
         try {
             $service = $this->config->getCurrentService();
         } catch (NotWithinServiceException $e) {
             $service = $this->askForTheService($input, $output);
         }
     }
     $command = implode(' ', $input->getArgument('service_command'));
     $this->processRunner->run("docker-compose run {$service} {$command}");
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function create()
 {
     try {
         $this->processRunner->run('docker-machine create --driver virtualbox ' . $this->name);
     } catch (ProcessFailedException $e) {
         throw new MachineException($e->getMessage(), $e->getCode(), $e);
     }
 }
Пример #8
0
 /**
  * @param $package
  */
 protected function installHomebrewPackage($package)
 {
     // Check if the package is known
     if (!$this->hasHomebrewPackage($package)) {
         $this->userInteraction->write(sprintf('Package "%s" not found, tapping default PHP brews', $package));
         $this->processRunner->run('brew tap homebrew/dupes');
         $this->processRunner->run('brew tap homebrew/versions');
         $this->processRunner->run('brew tap homebrew/homebrew-php');
     }
     $this->processRunner->run('brew install ' . $package);
 }
Пример #9
0
 private function getDockerComposePath(ProcessRunner $processRunner)
 {
     $output = $processRunner->run(new Process('which docker-compose'))->getOutput();
     return trim($output);
 }
Пример #10
0
 /**
  * Resolve the network interface name for the given IP.
  *
  * @param string $machineIp
  *
  * @return string
  */
 private function resolveNetworkInterface($machineIp)
 {
     $process = $this->processRunner->run('ifconfig `route get ' . $machineIp . ' | grep "interface: " | sed "s/[^:]*: \\(.*\\)/\\1/"` | head -n 1 | sed "s/\\([^:]*\\): .*/\\1/"');
     $interface = $process->getOutput();
     return trim($interface);
 }
Пример #11
0
 private function hasDockerOptions()
 {
     return $this->processRunner->run('grep "^DOCKER_OPTS" /etc/default/docker', false)->isSuccessful();
 }
Пример #12
0
 /**
  * @param string $targetPath
  * @param string $fileContents
  */
 private function writeAsRoot($targetPath, $fileContents)
 {
     $temporaryFile = tempnam(sys_get_temp_dir(), 'hostFile');
     file_put_contents($temporaryFile, $fileContents);
     $this->processRunner->run(sprintf('sudo cp %s %s', $temporaryFile, $targetPath));
 }
Пример #13
0
 private function configureHostMachineResolution()
 {
     $this->processRunner->run('sudo mkdir -p /etc/resolver');
     $this->processRunner->run('echo "nameserver 172.17.42.1" | sudo tee /etc/resolver/docker');
 }
Пример #14
0
 /**
  * @param ProcessRunner $processRunner
  * @param string $package
  *
  * @return bool
  */
 private function hasHomebrewPackage(ProcessRunner $processRunner, $package)
 {
     return $processRunner->run(new Process('brew install --dry-run ' . $package), false)->isSuccessful();
 }
Пример #15
0
 private function isCurrentUserInDockerGroup()
 {
     return $this->processRunner->run('groups | grep docker', false)->isSuccessful();
 }
 /**
  * {@inheritdoc}
  */
 public function has(EnvironmentVariable $environmentVariable)
 {
     $process = $this->processRunner->run(new Process('grep DOCKER_HOST ' . $this->file), false);
     $result = $process->getOutput();
     return !empty($result);
 }
Пример #17
0
 /**
  * Get boot2docker version.
  *
  * @throws ProcessFailedException
  * @return string
  */
 public function getVersion()
 {
     $process = $this->processRunner->run(new Process('boot2docker version'));
     return $process->getOutput();
 }
Пример #18
0
 /**
  * @return bool
  */
 public function isRunning()
 {
     $process = $this->processRunner->run(new Process('dinghy status'));
     $output = $process->getOutput();
     return strpos($output, 'VM: running') !== false;
 }
Пример #19
0
 private function isUsingDnsDockDnsServer()
 {
     return $this->processRunner->run('grep "' . DnsDock::IP . '" /etc/resolv.conf', false)->isSuccessful();
 }
 /**
  * {@inheritdoc}
  */
 public function build(Project $project, array $containers = [])
 {
     $composePath = $this->composeExecutableFinder->find();
     $this->processRunner->run(implode(' ', [$composePath, 'build', implode(' ', $containers)]));
     $this->reset($project, $containers);
 }