Skip to content

Commit

Permalink
Add ability to run docker-compose with defined projects (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
dungahk authored and greg-1-anderson committed Mar 24, 2019
1 parent 1f6a8d5 commit 3a47cf9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Transport/DockerComposeTransport.php
Expand Up @@ -35,7 +35,7 @@ public function configure(SiteProcess $process)
*/
public function wrap($args)
{
$transport = ['docker-compose', 'exec'];
$transport = $this->getTransport();
$transportOptions = $this->getTransportOptions();
$commandToExecute = $this->getCommandToExecute($args);

Expand All @@ -55,6 +55,19 @@ public function addChdir($cd, $args)
return $args;
}

/**
* getTransport returns the transport along with the docker-compose
* project in case it is defined.
*/
protected function getTransport()
{
$transport = ['docker-compose'];
if ($project = $this->siteAlias->get('docker.project', '')) {
$transport = array_merge($transport, ['-p', $project]);
}
return array_merge($transport, ['exec']);
}

/**
* getTransportOptions returns the transport options for the tranport
* mechanism itself
Expand Down
11 changes: 11 additions & 0 deletions tests/SiteProcessTest.php
Expand Up @@ -125,6 +125,17 @@ public function siteProcessTestValues()
NULL,
],

[
"docker-compose -p project exec --workdir src --user root drupal ls -al /path1 /path2",
'src',
true,
['docker' => ['service' => 'drupal', 'project' => 'project', 'exec' => ['options' => '--user root']]],
['ls', '-al', '/path1', '/path2'],
[],
[],
NULL,
],

[
"drush status '--fields=root,uri'",
false,
Expand Down

0 comments on commit 3a47cf9

Please sign in to comment.