Skip to content

Commit 6ec3296

Browse files
authored
Merge pull request #378 from jolicode/builder-command-proxy
Allow the builder task to proxy the command to the builder container
2 parents 791a5a6 + efa2bab commit 6ec3296

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

.castor/docker.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace docker;
44

55
use Castor\Attribute\AsOption;
6+
use Castor\Attribute\AsRawTokens;
67
use Castor\Attribute\AsTask;
78
use Castor\Context;
89
use Castor\Helper\PathHelper;
@@ -153,16 +154,21 @@ function stop(
153154
docker_compose($command, profiles: $profiles);
154155
}
155156

156-
#[AsTask(description: 'Opens a shell (bash) into a builder container', aliases: ['builder'])]
157-
function builder(): void
157+
/**
158+
* @param array<string> $params
159+
*/
160+
#[AsTask(description: 'Opens a shell (bash) or proxy any command to the builder container', aliases: ['builder'])]
161+
function builder(#[AsRawTokens] array $params = []): void
158162
{
163+
if (0 === \count($params)) {
164+
$params = ['bash'];
165+
}
166+
159167
$c = context()
160-
->withTimeout(null)
161-
->withTty()
168+
->toInteractive()
162169
->withEnvironment($_ENV + $_SERVER)
163-
->withAllowFailure()
164170
;
165-
docker_compose_run('bash', c: $c);
171+
docker_compose_run(implode(' ', $params), c: $c);
166172
}
167173

168174
/**

0 commit comments

Comments
 (0)