Merge branch 'gheydon-master'
This commit is contained in:
62
src/Task/Build.php
Executable file
62
src/Task/Build.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Droath\RoboDockerCompose\Task;
|
||||
|
||||
use Droath\RoboDockerCompose\DockerServicesTrait;
|
||||
|
||||
/**
|
||||
* Define docker compose pause command.
|
||||
*/
|
||||
class Build extends Base
|
||||
{
|
||||
|
||||
use DockerServicesTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $action = 'build';
|
||||
|
||||
/**
|
||||
* Set the build-rm option
|
||||
*/
|
||||
public function buildRm()
|
||||
{
|
||||
$this->option('build-rm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set no-cache option
|
||||
*/
|
||||
public function noCache()
|
||||
{
|
||||
$this->option('no-cache');
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the pull option
|
||||
*/
|
||||
public function pull()
|
||||
{
|
||||
$this->option('pull');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a build arg.
|
||||
*
|
||||
* @param $var
|
||||
* @param $variable
|
||||
*/
|
||||
public function buildArg($var, $value)
|
||||
{
|
||||
$this->option('build-arg', "{$var}={$value}");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCommand()
|
||||
{
|
||||
return "{$this->executable} {$this->executableArgs} {$this->action} {$this->arguments} " . implode(' ', $this->services);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ class Execute extends Base
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
protected $commandWrapper;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -42,6 +44,11 @@ class Execute extends Base
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCommandWrapper($command) {
|
||||
$this->commandWrapper = $command;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set execute command.
|
||||
*
|
||||
@@ -148,6 +155,15 @@ class Execute extends Base
|
||||
*/
|
||||
public function getCommand()
|
||||
{
|
||||
return parent::getCommand() . "{$this->container} {$this->command}";
|
||||
$this->arg($this->container);
|
||||
|
||||
if (isset($this->commandWrapper)) {
|
||||
$command = $this->commandWrapper . ' ' . self::escape($this->command);
|
||||
}
|
||||
else {
|
||||
$command = $this->command;
|
||||
}
|
||||
|
||||
return parent::getCommand() . " {$command}";
|
||||
}
|
||||
}
|
||||
|
||||
29
src/Task/Run.php
Normal file
29
src/Task/Run.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Droath\RoboDockerCompose\Task;
|
||||
|
||||
/**
|
||||
* Docker compose execute command.
|
||||
*/
|
||||
class Run extends Execute
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $action = 'run';
|
||||
|
||||
/**
|
||||
* Set the workdir.
|
||||
*
|
||||
* @param $workdir
|
||||
* The directory which to run the command under.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setWorkDir($workdir) {
|
||||
$this->option('workdir', $workdir, '=');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,4 +78,20 @@ trait loadTasks
|
||||
{
|
||||
return $this->task(Execute::class, $pathToDockerCompose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Docker compose run task.
|
||||
*/
|
||||
protected function taskDockerComposeRun($pathToDockerCompose = null)
|
||||
{
|
||||
return $this->task(Run::class, $pathToDockerCompose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Docker compose build task.
|
||||
*/
|
||||
protected function taskDockerComposeBuild($pathToDockerCompose = null)
|
||||
{
|
||||
return $this->task(Build::class, $pathToDockerCompose);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user