示例#1
0
 private function buildImageWithRequirements(Image $image, Docker $docker, $force = false)
 {
     foreach ($image->getRequiredImages() as $depImage) {
         $this->buildImageWithRequirements($depImage, $docker, $force);
     }
     if ($docker->isImageBuilt($image) && !$force) {
         $this->output->writeln(sprintf('Image %s already built', $image->getName()));
         return;
     }
     $this->output->writeln('Building image: ' . $image->getName());
     $docker->buildImage($image);
 }
示例#2
0
 /**
  * @param Image  $image
  * @param Docker $docker
  * @param bool   $restart
  *
  * @return \Crane\Docker\DockerContainer
  */
 private function startImagesWithRequirements(Image $image, Docker $docker, $restart = false)
 {
     if (false === $image->isRunnable()) {
         return null;
     }
     foreach ($image->getRequiredImages() as $dep) {
         $this->startImagesWithRequirements($dep, $docker, $restart);
     }
     $container = $docker->getDockerContainer($image);
     if (false === $container->exists()) {
         $this->output->writeln(sprintf('Starting new %s instance', $image->getName()));
         $container = $docker->startImage($image, $this->locator);
     } elseif (false === $container->isRunning() || $image->isMain() || $restart) {
         $this->output->writeln(sprintf('Restarting %s instance', $image->getName()));
         $docker->remove($container);
         $container = $docker->startImage($image, $this->locator);
     }
     return $container;
 }
示例#3
0
 /**
  * @param Image  $image
  * @param string $name
  *
  * @return string
  */
 public function getAssetPath(Image $image, $name)
 {
     return vsprintf('%s/images/%s/%s', [$this->getProjectDirectory($image->getProjectName(true)), $image->getName(), $name]);
 }
示例#4
0
 /**
  * @param Image  $image
  * @param string $volume
  *
  * @return string
  */
 private function getVolumePathOnTarget(Image $image, $volume)
 {
     return sprintf('%s/%s/volumes/%s', $this->getCranePathForUser(), $image->getProjectName(), $volume);
 }