# Combined image for Cloud Run: nginx + php-fpm (PHP 5.6) for legacy Laravel 5 # NOTE: PHP 5.6 is EOL; use only for legacy maintenance. Consider upgrading. FROM php:5.6-fpm # Set build args/env ARG APP_ENV=production ENV APP_ENV=${APP_ENV} \ APP_DEBUG=false \ OPCACHE_VALIDATE_TIMESTAMPS=0 \ COMPOSER_ALLOW_SUPERUSER=1 \ PORT=8080 \ PATH="/var/www/artisan:$PATH" WORKDIR /var/www # Install system deps (Debian variant easier than alpine for mixed services) RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ git curl unzip zip supervisor nginx \ libmcrypt4 libmcrypt-dev \ libpng-dev libjpeg62-turbo-dev libfreetype6-dev libzip-dev zlib1g-dev \ && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ && docker-php-ext-install gd mcrypt mbstring pdo pdo_mysql zip opcache \ && rm -rf /var/lib/apt/lists/* # Install Composer (v1) RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ && composer self-update --1 # Copy composer files & install deps first (cache layer) COPY composer.* ./ RUN composer config platform.php 5.6.40 \ && composer install --no-dev --no-scripts --no-autoloader --prefer-dist # Copy application code COPY . . RUN composer dump-autoload --optimize --no-dev --classmap-authoritative || true # Nginx config COPY cloudrun/nginx.conf /etc/nginx/nginx.conf # Supervisord config COPY cloudrun/supervisord.conf /etc/supervisor/conf.d/supervisord.conf # Remove default nginx site configs if present RUN rm -f /etc/nginx/sites-enabled/default /etc/nginx/conf.d/default.conf || true # Create runtime dirs RUN mkdir -p /run/php /var/log/supervisor /var/www/storage /var/www/bootstrap/cache \ && chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache # PHP production ini tweaks RUN { \ echo "opcache.enable=1"; \ echo "opcache.memory_consumption=128"; \ echo "opcache.interned_strings_buffer=8"; \ echo "opcache.max_accelerated_files=4000"; \ echo "opcache.revalidate_freq=60"; \ echo "opcache.fast_shutdown=1"; \ echo "date.timezone=UTC"; \ } > /usr/local/etc/php/conf.d/zz-custom.ini # Generate app key if missing (non-fatal if artisan fails early) RUN php artisan key:generate || true # Cloud Run listens on $PORT EXPOSE 8080 # Health check path suggestion: /healthz (configure in Cloud Run if desired) # Start supervisor (manages php-fpm + nginx) CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]