/** * {@inheritdoc} */ public function prepareJob(Job $job) { $origin = $job->getParameters()['origin']; $target = $this->buildPath . DIRECTORY_SEPARATOR . $job->getDirectory(); $build = $job->getParameters()['build']; // First mirroring target $this->filesystem->mirror($origin, $target, null, array('delete' => true, 'override' => true)); // Second override target with build dir $this->filesystem->mirror($build, $target, null, array('delete' => false, 'override' => true)); }
/** * Create a build * * @param Job $build Build used to create image * * @return Image|boolean Return the image created if sucessful or false otherwise */ public function create(Job $build) { $context = new Context($this->buildPath . DIRECTORY_SEPARATOR . $build->getDirectory()); $this->docker->build($context, $build->getName(), $this->logger->getBuildCallback(), $this->quietBuild, $this->usecache, true); $this->logger->clearStatic(); try { return $this->docker->getImageManager()->find($build->getRepository(), $build->getTag()); } catch (ImageNotFoundException $e) { return false; } }
/** * {@inheritdoc} */ public function prepareJob(Job $job) { $parameters = $job->getParameters(); $origin = $parameters['origin']; $target = $this->buildPath . DIRECTORY_SEPARATOR . $job->getDirectory(); // First mirroring target $this->filesystem->mirror($origin, $target, null, array('delete' => true, 'override' => true)); // Create dockerfile $this->builder->setTemplateName(sprintf("%s/Dockerfile-%s.twig", $parameters['language'], $parameters['version'])); $this->builder->setVariables($parameters); $this->builder->setOutputName('Dockerfile'); $this->builder->writeOnDisk($target); }
/** * Create a build * * @param Job $job Build used to create image * * @return \Docker\API\Model\Image|boolean Return the image created if successful or false otherwise */ public function create(Job $job) { $context = new Context($this->buildPath . DIRECTORY_SEPARATOR . $job->getDirectory()); $buildStream = $this->docker->getImageManager()->build($context->toStream(), ['t' => $job->getName(), 'q' => $this->quietBuild, 'nocache' => !$this->usecache], ImageManager::FETCH_STREAM); $buildStream->onFrame($this->logger->getBuildCallback()); $buildStream->wait(); try { return $this->docker->getImageManager()->find($job->getName()); } catch (ClientErrorException $e) { if ($e->getResponse()->getStatusCode() == 404) { return false; } throw $e; } }