# -------- 1) Composer deps (no scripts; avoids artisan during build) -------- 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 --classmap-authoritative --no-scripts; \ fi # -------- 2) App source -------- FROM alpine:3.22 AS app_src WORKDIR /app COPY . ./ # -------- 3) Final: Nginx + PHP-FPM + PGSQL drivers -------- FROM php:8.4-fpm-alpine # Build + runtime deps (incl. oniguruma for mbstring, GD runtime libs) RUN set -eux; \ 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 \ && 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 \ && apk del .build-deps \ && rm -rf /var/cache/apk/* /tmp/* # PHP runtime tuning RUN set -eux; \ { \ echo "memory_limit=512M"; \ echo "upload_max_filesize=64M"; \ echo "post_max_size=64M"; \ echo "max_execution_time=60"; \ } > /usr/local/etc/php/conf.d/laravel.ini # Set timezone RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime # Copy application source WORKDIR /app COPY --from=app_src /app /app COPY --from=vendor /app/vendor /app/vendor # Set permissions for Laravel storage and cache RUN set -eux; \ chown -R www-data:www-data /app/storage /app/bootstrap/cache /app/public; \ chmod -R 775 /app/storage /app/bootstrap/cache /app/public # Configure Nginx RUN mkdir -p /run/nginx COPY ./deploy/nginx/default.conf /etc/nginx/nginx.conf # Configure Supervisor COPY ./deploy/supervisord.conf /etc/supervisor/conf.d/supervisord.conf # Expose ports EXPOSE 80 # Start Supervisor CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]