Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2242c4b93 | ||
|
|
463daf3a2d | ||
|
|
761f956826 | ||
|
|
01740ee9e4 | ||
|
|
ce1360c733 | ||
|
|
4697d956fa |
@@ -34,6 +34,9 @@ The following commands have been implemented:
|
||||
|
||||
- docker-compose up
|
||||
- docker-compose down
|
||||
- docker-compose start
|
||||
- docker-compose restart
|
||||
- docker-compose pause
|
||||
|
||||
I'll be adding the rests of the docker-compose commands shortly. Or if you want
|
||||
to create a PR with additional commands that would be much appreciated.
|
||||
|
||||
53
src/DockerServicesTrait.php
Executable file
53
src/DockerServicesTrait.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Droath\RoboDockerCompose;
|
||||
|
||||
/**
|
||||
* Define docker services trait.
|
||||
*/
|
||||
trait DockerServicesTrait
|
||||
{
|
||||
/**
|
||||
* Docker compose services.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $services = [];
|
||||
|
||||
/**
|
||||
* Add docker composer service.
|
||||
*
|
||||
* @param string $service
|
||||
* The docker services.
|
||||
*/
|
||||
public function setService($service)
|
||||
{
|
||||
$this->services[] = $service;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add docker composer services.
|
||||
*
|
||||
* @param array $services
|
||||
* An array of services.
|
||||
*/
|
||||
public function setServices(array $services)
|
||||
{
|
||||
foreach ($services as $service) {
|
||||
$this->setService($service);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getCommand()
|
||||
{
|
||||
// Append the services to the end of the command.
|
||||
return parent::getCommand() . ' ' . implode(' ', $this->services);
|
||||
}
|
||||
}
|
||||
18
src/Task/Pause.php
Executable file
18
src/Task/Pause.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Droath\RoboDockerCompose\Task;
|
||||
|
||||
use Droath\RoboDockerCompose\DockerServicesTrait;
|
||||
|
||||
/**
|
||||
* Define docker compose pause command.
|
||||
*/
|
||||
class Pause extends Base
|
||||
{
|
||||
use DockerServicesTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $action = 'pause';
|
||||
}
|
||||
33
src/Task/Restart.php
Executable file
33
src/Task/Restart.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Droath\RoboDockerCompose\Task;
|
||||
|
||||
use Droath\RoboDockerCompose\DockerServicesTrait;
|
||||
|
||||
/**
|
||||
* Define docker compose restart command.
|
||||
*/
|
||||
class Restart extends Base
|
||||
{
|
||||
use DockerServicesTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $action = 'restart';
|
||||
|
||||
/**
|
||||
* Specify a shutdown timeout in seconds.
|
||||
*
|
||||
* @param int $timeout
|
||||
* The timeout in seconds.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function timeout($timeout = 10)
|
||||
{
|
||||
$this->option('timeout', $timeout);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
18
src/Task/Start.php
Executable file
18
src/Task/Start.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Droath\RoboDockerCompose\Task;
|
||||
|
||||
use Droath\RoboDockerCompose\DockerServicesTrait;
|
||||
|
||||
/**
|
||||
* Define docker compose start command.
|
||||
*/
|
||||
class Start extends Base
|
||||
{
|
||||
use DockerServicesTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $action = 'start';
|
||||
}
|
||||
47
src/Task/Up.php
Normal file → Executable file
47
src/Task/Up.php
Normal file → Executable file
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Droath\RoboDockerCompose\Task;
|
||||
|
||||
use Droath\RoboDockerCompose\DockerServicesTrait;
|
||||
use Robo\Exception\TaskException;
|
||||
|
||||
/**
|
||||
@@ -9,18 +10,13 @@ use Robo\Exception\TaskException;
|
||||
*/
|
||||
class Up extends Base
|
||||
{
|
||||
use DockerServicesTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $action = 'up';
|
||||
|
||||
/**
|
||||
* Docker compose services.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $services = [];
|
||||
|
||||
/**
|
||||
* Command detached mode.
|
||||
*
|
||||
@@ -28,34 +24,6 @@ class Up extends Base
|
||||
*/
|
||||
protected $detachedMode = false;
|
||||
|
||||
/**
|
||||
* Add docker composer service.
|
||||
*
|
||||
* @param string $service
|
||||
* The docker services.
|
||||
*/
|
||||
public function setService($service)
|
||||
{
|
||||
$this->services[] = $service;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add docker composer services.
|
||||
*
|
||||
* @param array $services
|
||||
* An array of services.
|
||||
*/
|
||||
public function setServices(array $services)
|
||||
{
|
||||
foreach ($services as $service) {
|
||||
$this->setService($service);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run containers in the background.
|
||||
*/
|
||||
@@ -147,15 +115,6 @@ class Up extends Base
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getCommand()
|
||||
{
|
||||
// Append the services to the end of the command.
|
||||
return parent::getCommand() . ' ' . implode(' ', $this->services);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set command detached mode.
|
||||
*/
|
||||
|
||||
26
src/Task/loadTasks.php
Normal file → Executable file
26
src/Task/loadTasks.php
Normal file → Executable file
@@ -16,10 +16,34 @@ trait loadTasks
|
||||
}
|
||||
|
||||
/**
|
||||
* Docker compose up task.
|
||||
* Docker compose down task.
|
||||
*/
|
||||
protected function taskDockerComposeDown($pathToDockerCompose = null)
|
||||
{
|
||||
return $this->task(Down::class, $pathToDockerCompose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Docker compose pause task.
|
||||
*/
|
||||
protected function taskDockerComposePause($pathToDockerCompose = null)
|
||||
{
|
||||
return $this->task(Pause::class, $pathToDockerCompose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Docker compose start task.
|
||||
*/
|
||||
protected function taskDockerComposeStart($pathToDockerCompose = null)
|
||||
{
|
||||
return $this->task(Start::class, $pathToDockerCompose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Docker compose restart task.
|
||||
*/
|
||||
protected function taskDockerComposeRestart($pathToDockerCompose = null)
|
||||
{
|
||||
return $this->task(Restart::class, $pathToDockerCompose);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user