From 59fcb39f85e39e10eb2653ee027c194117801cef Mon Sep 17 00:00:00 2001 From: Ambroise Maupate Date: Tue, 5 Mar 2024 17:02:12 +0100 Subject: [PATCH] feat: Added *LiipMonitorBundle* for health-checking API docker container --- Dockerfile | 2 ++ composer.json | 1 + composer.json.dist | 1 + config/bundles.php | 1 + config/packages/monitor.yaml | 30 ++++++++++++++++++++++++++++++ docker/php-fpm-alpine/Dockerfile | 2 ++ 6 files changed, 37 insertions(+) create mode 100644 config/packages/monitor.yaml diff --git a/Dockerfile b/Dockerfile index 809ab38..44d9596 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,8 @@ ENV APP_FFMPEG_PATH=/usr/bin/ffmpeg ENV MYSQL_HOST=db ENV MYSQL_PORT=3306 +HEALTHCHECK --start-period=30s --interval=1m --timeout=6s CMD bin/console monitor:health -q + # Added ffmpeg to extract video files thumbnails RUN apk add --no-cache ffmpeg diff --git a/composer.json b/composer.json index 2dce9c0..778edd5 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "ext-ctype": "*", "ext-iconv": "*", "ext-json": "*", + "liip/monitor-bundle": "^2.22", "nelmio/cors-bundle": "^2.4", "roadiz/cms-pack": "dev-develop", "sentry/sentry-symfony": "^4.13", diff --git a/composer.json.dist b/composer.json.dist index 2dce9c0..778edd5 100644 --- a/composer.json.dist +++ b/composer.json.dist @@ -9,6 +9,7 @@ "ext-ctype": "*", "ext-iconv": "*", "ext-json": "*", + "liip/monitor-bundle": "^2.22", "nelmio/cors-bundle": "^2.4", "roadiz/cms-pack": "dev-develop", "sentry/sentry-symfony": "^4.13", diff --git a/config/bundles.php b/config/bundles.php index 421156e..cc0c6e1 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -26,4 +26,5 @@ Limenius\LiformBundle\LimeniusLiformBundle::class => ['all' => true], Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], Rollerworks\Bundle\PasswordCommonListBundle\RollerworksPasswordCommonListBundle::class => ['all' => true], + Liip\MonitorBundle\LiipMonitorBundle::class => ['all' => true], ]; diff --git a/config/packages/monitor.yaml b/config/packages/monitor.yaml new file mode 100644 index 0000000..24a7167 --- /dev/null +++ b/config/packages/monitor.yaml @@ -0,0 +1,30 @@ +liip_monitor: + # enabling the controller requires that `assets` are enabled in the framework bundle + enable_controller: false + checks: + groups: + default: + # Checks to see if the disk usage is below warning/critical percent thresholds + disk_usage: + warning: 70 + critical: 90 + path: '%kernel.cache_dir%' + + # Connection name or an array of connection names + doctrine_dbal: [default] + + # Checks to see if migrations from specified configuration file are applied + doctrine_migrations: + migrations: + connection: default + + # Validate that a Redis service is running +# redis: +# cache_service: +# dsn: '%env(string:REDIS_DSN)%' + + # Validate that a messenger transport does not contain more than warning/critical messages + # Transport must implement MessageCountAwareInterface + messenger_transports: + async: + critical_threshold: 10 # required diff --git a/docker/php-fpm-alpine/Dockerfile b/docker/php-fpm-alpine/Dockerfile index 3cd7de9..bb2d7ba 100755 --- a/docker/php-fpm-alpine/Dockerfile +++ b/docker/php-fpm-alpine/Dockerfile @@ -9,6 +9,8 @@ ENV APP_FFMPEG_PATH=/usr/bin/ffmpeg ENV MYSQL_HOST=db ENV MYSQL_PORT=3306 +HEALTHCHECK --start-period=30s --interval=1m --timeout=6s CMD bin/console monitor:health -q + RUN apk add --no-cache shadow make git ffmpeg \ && usermod -u ${USER_UID} www-data \ && groupmod -g ${USER_UID} www-data \