Files
AFC-Demo/Dockerfile
T

80 lines
2.9 KiB
Docker
Raw Normal View History

2025-10-23 08:10:45 +02:00
# ---------- 1) Build Composer deps (no scripts; avoids artisan during build) ----------
2025-10-23 07:58:06 +02:00
FROM composer:2 AS vendor
ARG COMPOSER_NO_DEV=1
WORKDIR /app
COPY composer.json composer.lock ./
RUN if [ "$COMPOSER_NO_DEV" = "1" ]; then \
composer install --no-dev --prefer-dist --no-progress --no-interaction --classmap-authoritative --no-scripts; \
else \
composer install --prefer-dist --no-progress --no-interaction --no-scripts; \
fi
2025-10-23 08:10:45 +02:00
# ---------- 2) Bring in app sources ----------
2025-10-23 07:58:06 +02:00
FROM alpine:3.20 AS app_src
WORKDIR /app
COPY . ./
2025-10-23 08:10:45 +02:00
# ---------- 3) Final image: Nginx + PHP-FPM + PGSQL ----------
2025-10-23 07:58:06 +02:00
FROM php:8.4-fpm-alpine
2025-10-23 08:10:45 +02:00
# System deps (build + runtime)
2025-10-23 07:58:06 +02:00
RUN set -eux; \
2025-10-23 08:10:45 +02:00
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS icu-dev libzip-dev postgresql-dev \
freetype-dev libjpeg-turbo-dev libpng-dev \
oniguruma-dev pkgconf \
&& apk add --no-cache \
icu-libs libzip libpq tzdata bash git curl \
nginx supervisor \
oniguruma \
freetype libjpeg-turbo libpng \
# PHP extensions
&& docker-php-ext-configure intl \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j"$(nproc)" \
intl opcache zip bcmath mbstring gd pdo pdo_pgsql pgsql \
# Cleanup
&& apk del .build-deps \
&& rm -rf /var/cache/apk/* /tmp/*
2025-10-23 07:58:06 +02:00
2025-10-23 08:10:45 +02:00
# PHP runtime tuning
2025-10-23 07:58:06 +02:00
RUN set -eux; \
{ \
echo "memory_limit=512M"; \
echo "upload_max_filesize=64M"; \
echo "post_max_size=64M"; \
echo "max_execution_time=60"; \
echo "date.timezone=UTC"; \
echo "opcache.enable=1"; \
echo "opcache.enable_cli=0"; \
echo "opcache.validate_timestamps=0"; \
echo "opcache.jit=tracing"; \
echo "opcache.jit_buffer_size=128M"; \
echo "opcache.interned_strings_buffer=16"; \
echo "opcache.max_accelerated_files=20000"; \
} > /usr/local/etc/php/conf.d/laravel.ini
2025-10-23 08:10:45 +02:00
# Prepare dirs
RUN mkdir -p /run/php /run/nginx /var/log/supervisor /var/www/html /etc/nginx/http.d
2025-10-23 07:58:06 +02:00
2025-10-23 08:10:45 +02:00
# Copy app and vendor
2025-10-23 07:58:06 +02:00
COPY --from=app_src /app /var/www/html
COPY --from=vendor /app/vendor /var/www/html/vendor
2025-10-23 08:10:45 +02:00
# Copy configs
COPY deploy/nginx/default.conf /etc/nginx/http.d/default.conf
COPY deploy/supervisord.conf /etc/supervisord.conf
COPY deploy/php-fpm/zz-socket.conf /usr/local/etc/php-fpm.d/zz-socket.conf
COPY deploy/entrypoint.sh /usr/local/bin/entrypoint.sh
# Ensure executable
RUN chmod +x /usr/local/bin/entrypoint.sh
# Healthcheck and ports (unchanged)
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=5s --retries=5 \
CMD curl -fsS http://localhost/healthz || exit 1
# Use the entrypoint to run artisan warmups, then exec supervisord
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]