Allow setting service(s) on the docker-compose up command.
This commit is contained in:
@@ -14,6 +14,13 @@ class Up extends Base
|
||||
*/
|
||||
protected $action = 'up';
|
||||
|
||||
/**
|
||||
* Docker compose services.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $services = [];
|
||||
|
||||
/**
|
||||
* Command detached mode.
|
||||
*
|
||||
@@ -21,6 +28,34 @@ 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.
|
||||
*/
|
||||
@@ -123,6 +158,15 @@ class Up extends Base
|
||||
return $this->executeCommand($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getCommand()
|
||||
{
|
||||
// Append the services to the end of the command.
|
||||
return parent::getCommand() . ' ' . implode(' ', $this->services);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set command detached mode.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user