fix: run boot console commands as runtime user
This commit is contained in:
parent
5b86d89be2
commit
3b322c9ee0
2 changed files with 25 additions and 2 deletions
|
|
@ -5,8 +5,8 @@ mkdir -p /app/var/data /app/var/bootstrap-cache
|
|||
chown -R www-data:www-data /app/var
|
||||
|
||||
if [ "${APP_ENV:-prod}" != "test" ]; then
|
||||
php /app/bin/console cache:clear --no-warmup --no-interaction
|
||||
php /app/bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration
|
||||
su -m www-data -s /bin/sh -c 'cd /app && php /app/bin/console cache:clear --no-warmup --no-interaction'
|
||||
su -m www-data -s /bin/sh -c 'cd /app && php /app/bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration'
|
||||
fi
|
||||
|
||||
if [ "${APP_ENV:-prod}" = "prod" ] && [ "${1:-}" = "php-fpm" ]; then
|
||||
|
|
|
|||
23
tests/Docker/EntrypointTest.php
Normal file
23
tests/Docker/EntrypointTest.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests\Docker;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class EntrypointTest extends TestCase
|
||||
{
|
||||
public function testBootConsoleCommandsRunAsRuntimeUser(): void
|
||||
{
|
||||
$entrypoint = file_get_contents(__DIR__.'/../../docker/entrypoint.sh');
|
||||
|
||||
self::assertIsString($entrypoint);
|
||||
self::assertStringContainsString(
|
||||
"su -m www-data -s /bin/sh -c 'cd /app && php /app/bin/console cache:clear --no-warmup --no-interaction'",
|
||||
$entrypoint
|
||||
);
|
||||
self::assertStringContainsString(
|
||||
"su -m www-data -s /bin/sh -c 'cd /app && php /app/bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration'",
|
||||
$entrypoint
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue