Compare commits
No commits in common. "645d8af22d5c144be6b3d4183b3da3648009715d" and "5b86d89be284f3948d0414b790b873b948b4e5b3" have entirely different histories.
645d8af22d
...
5b86d89be2
4 changed files with 3 additions and 84 deletions
15
compose.yaml
15
compose.yaml
|
|
@ -13,12 +13,6 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- app-data:/app/var/data
|
- app-data:/app/var/data
|
||||||
- app-cache:/app/var/bootstrap-cache
|
- app-cache:/app/var/bootstrap-cache
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "php -r 'exit(@fsockopen(\"127.0.0.1\", 9000) ? 0 : 1);'"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 3s
|
|
||||||
retries: 3
|
|
||||||
start_period: 20s
|
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
build:
|
build:
|
||||||
|
|
@ -26,16 +20,9 @@ services:
|
||||||
dockerfile: docker/Dockerfile
|
dockerfile: docker/Dockerfile
|
||||||
target: web
|
target: web
|
||||||
depends_on:
|
depends_on:
|
||||||
app:
|
- app
|
||||||
condition: service_healthy
|
|
||||||
ports:
|
ports:
|
||||||
- "${HTTP_PORT:-8080}:80"
|
- "${HTTP_PORT:-8080}:80"
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "wget -q --spider http://127.0.0.1/ || exit 1"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 3s
|
|
||||||
retries: 3
|
|
||||||
start_period: 20s
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
app-data:
|
app-data:
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ mkdir -p /app/var/data /app/var/bootstrap-cache
|
||||||
chown -R www-data:www-data /app/var
|
chown -R www-data:www-data /app/var
|
||||||
|
|
||||||
if [ "${APP_ENV:-prod}" != "test" ]; then
|
if [ "${APP_ENV:-prod}" != "test" ]; then
|
||||||
su -m www-data -s /bin/sh -c 'cd /app && php /app/bin/console cache:clear --no-warmup --no-interaction'
|
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'
|
php /app/bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${APP_ENV:-prod}" = "prod" ] && [ "${1:-}" = "php-fpm" ]; then
|
if [ "${APP_ENV:-prod}" = "prod" ] && [ "${1:-}" = "php-fpm" ]; then
|
||||||
|
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Tests\Docker;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Yaml\Yaml;
|
|
||||||
|
|
||||||
final class ComposeHealthcheckTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testServicesDeclareHealthchecks(): void
|
|
||||||
{
|
|
||||||
$compose = Yaml::parseFile(__DIR__.'/../../compose.yaml');
|
|
||||||
|
|
||||||
self::assertSame(
|
|
||||||
[
|
|
||||||
'CMD-SHELL',
|
|
||||||
'php -r \'exit(@fsockopen("127.0.0.1", 9000) ? 0 : 1);\'',
|
|
||||||
],
|
|
||||||
$compose['services']['app']['healthcheck']['test'] ?? null
|
|
||||||
);
|
|
||||||
self::assertSame('10s', $compose['services']['app']['healthcheck']['interval'] ?? null);
|
|
||||||
self::assertSame('3s', $compose['services']['app']['healthcheck']['timeout'] ?? null);
|
|
||||||
self::assertSame(3, $compose['services']['app']['healthcheck']['retries'] ?? null);
|
|
||||||
self::assertSame('20s', $compose['services']['app']['healthcheck']['start_period'] ?? null);
|
|
||||||
|
|
||||||
self::assertSame(
|
|
||||||
['CMD-SHELL', 'wget -q --spider http://127.0.0.1/ || exit 1'],
|
|
||||||
$compose['services']['nginx']['healthcheck']['test'] ?? null
|
|
||||||
);
|
|
||||||
self::assertSame('10s', $compose['services']['nginx']['healthcheck']['interval'] ?? null);
|
|
||||||
self::assertSame('3s', $compose['services']['nginx']['healthcheck']['timeout'] ?? null);
|
|
||||||
self::assertSame(3, $compose['services']['nginx']['healthcheck']['retries'] ?? null);
|
|
||||||
self::assertSame('20s', $compose['services']['nginx']['healthcheck']['start_period'] ?? null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNginxWaitsForHealthyApp(): void
|
|
||||||
{
|
|
||||||
$compose = Yaml::parseFile(__DIR__.'/../../compose.yaml');
|
|
||||||
|
|
||||||
self::assertSame(
|
|
||||||
['app' => ['condition' => 'service_healthy']],
|
|
||||||
$compose['services']['nginx']['depends_on'] ?? null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
<?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