Skip to content

Instantly share code, notes, and snippets.

@bka
Created May 13, 2017 10:50
Show Gist options
  • Save bka/02a555b5367692273539513b55a8e464 to your computer and use it in GitHub Desktop.
Save bka/02a555b5367692273539513b55a8e464 to your computer and use it in GitHub Desktop.
Build a Dockerfile with docker-php
$docker = new \Docker\Docker();
$imageManager = $docker->getImageManager();
$context = new \Docker\Context\Context('/path/to/docker/Dockerfile');
$inputStream = $context->toStream();
$buildStream = $imageManager->build($inputStream, [
't' => "meinimage",
'rm' => true,
'nocache' => false
], ImageManager::FETCH_STREAM);
$buildStream->onFrame(function (BuildInfo $buildInfo) {
$status = $buildInfo->getStream();
$progress = $buildInfo->getProgress();
if ($status != "") {
echo $status . "\n";
} elseif ($progress != "") {
echo $progress . "\n";
}
});
$buildStream->wait();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment