diff --git a/src/Task/Build.php b/src/Task/Build.php new file mode 100755 index 0000000..945a9f9 --- /dev/null +++ b/src/Task/Build.php @@ -0,0 +1,62 @@ +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); + } +} diff --git a/src/Task/Execute.php b/src/Task/Execute.php index b1b496b..ca27594 100644 --- a/src/Task/Execute.php +++ b/src/Task/Execute.php @@ -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}"; } } diff --git a/src/Task/Run.php b/src/Task/Run.php new file mode 100644 index 0000000..44da9ae --- /dev/null +++ b/src/Task/Run.php @@ -0,0 +1,29 @@ +option('workdir', $workdir, '='); + + return $this; + } + +} diff --git a/src/Task/loadTasks.php b/src/Task/loadTasks.php index 87e3fcd..90fde72 100755 --- a/src/Task/loadTasks.php +++ b/src/Task/loadTasks.php @@ -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); + } }