Add healthcheck logic for waiting that php service is ready (#448)

This commit is contained in:
Lorenzo Dessimoni 2023-09-14 00:41:39 +02:00 committed by GitHub
parent 3df8a96ab9
commit 70f90033db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 10 deletions

View File

@ -48,7 +48,7 @@ RUN mkdir -p /var/run/php
COPY --link --chmod=755 docker/php/docker-healthcheck.sh /usr/local/bin/docker-healthcheck
HEALTHCHECK --interval=10s --timeout=3s --retries=3 CMD ["docker-healthcheck"]
HEALTHCHECK --interval=10s --timeout=3s --retries=3 --start-period=40s CMD ["docker-healthcheck"]
COPY --link --chmod=755 docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint

View File

@ -6,11 +6,6 @@ services:
restart: unless-stopped
volumes:
- php_socket:/var/run/php
healthcheck:
interval: 10s
timeout: 3s
retries: 3
start_period: 30s
environment:
TRUSTED_PROXIES: ${TRUSTED_PROXIES:-127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16}
TRUSTED_HOSTS: ^${SERVER_NAME:-example\.com|localhost}|caddy$$
@ -27,7 +22,9 @@ services:
caddy:
image: ${IMAGES_PREFIX:-}app-caddy
depends_on:
- php
php:
condition: service_healthy
restart: true
environment:
SERVER_NAME: ${SERVER_NAME:-localhost}, caddy:80
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}

View File

@ -14,13 +14,13 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
composer create-project "symfony/skeleton $SYMFONY_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction --no-install
cd tmp
composer require "php:>=$PHP_VERSION"
composer config --json extra.symfony.docker 'true'
cp -Rp . ..
cd -
rm -Rf tmp/
composer require "php:>=$PHP_VERSION"
composer config --json extra.symfony.docker 'true'
if grep -q ^DATABASE_URL= .env; then
echo "To finish the installation please press Ctrl+C to stop Docker Compose and run: docker compose up --build --wait"
sleep infinity