Skip to content

Commit 6cd58d9

Browse files
committed
Add passthrough functionality to Docker image entrypoint
1 parent 4a3b543 commit 6cd58d9

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

docker/entrypoint.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
set -e
44

5-
# If the first argument is `-init`, execute supervisor to run the
6-
# application, which is the default command, or pass the argument
7-
# to the Dirigent binary
5+
# If the first argument is `-init`, run the application. This is
6+
# also the default command.
87
if [ "$1" = "-init" ]; then
98
set -- /srv/init.sh
109
else
11-
set -- bin/dirigent "$@"
10+
# If the first argument is `--`, execute the remaining arguments as a
11+
# new command, otherwise pass the arguments to the Dirigent binary.
12+
if [ "$1" = "--" ]; then
13+
set -- ${@:2}
14+
else
15+
set -- bin/dirigent "$@"
16+
fi
1217
fi
1318

1419
exec "$@"

tests/Docker/Standalone/EntrypointTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,18 @@ public function testDirigent(): void
4141

4242
$this->assertStringStartsWith('Dirigent', $result, 'Running the container with any other command (than `-init`) must be passed to the Dirigent binary.');
4343
}
44+
45+
public function testPassthrough(): void
46+
{
47+
$container = (new GenericContainer('dirigent-standalone'))
48+
->withCommand(['--', 'bin/console', 'list'])
49+
->withWait(new WaitForLog('Symfony'))
50+
->start();
51+
52+
$result = $container->logs();
53+
54+
$container->stop();
55+
56+
$this->assertStringStartsWith(')Symfony', $result, 'Running the container with an `--` argument must have its remaining arguments be interpreted as a command.');
57+
}
4458
}

0 commit comments

Comments
 (0)