fix(docker): implement retry logic for package installation and optimize image usage in docker-compose
This commit is contained in:
+8
-3
@@ -33,10 +33,15 @@ FROM php:8.2-fpm-alpine AS runtime
|
|||||||
|
|
||||||
# System deps + PHP extensions.
|
# System deps + PHP extensions.
|
||||||
# pdo_mysql -> MariaDB, intl -> Symfony, opcache -> perf, redis -> Messenger/cache transport
|
# pdo_mysql -> MariaDB, intl -> Symfony, opcache -> perf, redis -> Messenger/cache transport
|
||||||
RUN apk add --no-cache nginx supervisor icu-libs \
|
# apk/pecl fetch over the network; on busy build hosts the mirror occasionally
|
||||||
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev \
|
# drops a connection. retry() wraps each network step so a transient failure
|
||||||
|
# doesn't abort the whole deploy.
|
||||||
|
RUN set -eu; \
|
||||||
|
retry() { for i in 1 2 3 4 5; do "$@" && return 0; echo "retry $i: $*"; sleep 5; done; return 1; }; \
|
||||||
|
retry apk add --no-cache nginx supervisor icu-libs \
|
||||||
|
&& retry apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev \
|
||||||
&& docker-php-ext-install pdo_mysql intl opcache \
|
&& docker-php-ext-install pdo_mysql intl opcache \
|
||||||
&& pecl install redis \
|
&& retry pecl install redis \
|
||||||
&& docker-php-ext-enable redis \
|
&& docker-php-ext-enable redis \
|
||||||
&& apk del .build-deps
|
&& apk del .build-deps
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -49,6 +49,10 @@ services:
|
|||||||
# CORS/payload allow-listing for those frontends is handled separately via
|
# CORS/payload allow-listing for those frontends is handled separately via
|
||||||
# CORS_ALLOW_ORIGIN / ALLOWED_FRONTEND_HOSTS (see docker/frontend-domains.json).
|
# CORS_ALLOW_ORIGIN / ALLOWED_FRONTEND_HOSTS (see docker/frontend-domains.json).
|
||||||
app:
|
app:
|
||||||
|
# Shared image tag — app builds it once; the two workers reuse the SAME image
|
||||||
|
# (image: below, no build:). Without this Coolify builds the Dockerfile 3×,
|
||||||
|
# tripling apk/pecl network fetches and intermittently failing on the host.
|
||||||
|
image: clinicpro-app:latest
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
@@ -65,11 +69,9 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
start_period: 60s
|
start_period: 60s
|
||||||
|
|
||||||
# SMS / async message consumer.
|
# SMS / async message consumer. Reuses the image built by `app` (no build:).
|
||||||
worker-async:
|
worker-async:
|
||||||
build:
|
image: clinicpro-app:latest
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command: php bin/console messenger:consume async --time-limit=3600 --memory-limit=128M -v
|
command: php bin/console messenger:consume async --time-limit=3600 --memory-limit=128M -v
|
||||||
environment:
|
environment:
|
||||||
@@ -78,11 +80,9 @@ services:
|
|||||||
volumes: *app-volumes
|
volumes: *app-volumes
|
||||||
depends_on: *app-depends
|
depends_on: *app-depends
|
||||||
|
|
||||||
# Scheduler consumer — expires unpaid appointments every minute.
|
# Scheduler consumer — expires unpaid appointments every minute. Reuses app's image.
|
||||||
worker-scheduler:
|
worker-scheduler:
|
||||||
build:
|
image: clinicpro-app:latest
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command: php bin/console messenger:consume scheduler_default --time-limit=3600 -v
|
command: php bin/console messenger:consume scheduler_default --time-limit=3600 -v
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
Reference in New Issue
Block a user