Joli\JoliCi\Executor::create PHP Method

create() public method

Create a build
public create ( Joli\JoliCi\Job $job ) : Docker\API\Model\Image | boolean
$job Joli\JoliCi\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;
        }
    }

Usage Example

Beispiel #1
0
 public function testBuildNoQuiet()
 {
     $executor = new Executor($this->logger, $this->docker, "", false, false);
     $this->logger->expects($this->once())->method('getBuildCallback')->will($this->returnValue(function () {
     }));
     $this->docker->expects($this->once())->method('build')->with($this->isInstanceOf('\\Docker\\Context\\Context'), $this->stringContains('test'), $this->isType('callable'), $this->isFalse(), $this->isFalse());
     $this->docker->expects($this->once())->method('getImageManager')->will($this->returnValue($this->imageManager));
     $this->imageManager->expects($this->once())->method('find');
     $executor->create(new Job("/test", "test", "", ""));
 }