# Use the official PHP image. # https://hub.docker.com/_/php FROM php:8.3.37-apache # Environment variables read by the application. RUN echo "SetEnv WE_ENV production" > /etc/apache2/conf-enabled/environment.conf RUN echo "SetEnv DCK_CONT 1" >> /etc/apache2/conf-enabled/environment.conf # System packages (libicu-dev is required by the intl extension). RUN apt-get update \ && apt-get install -y nano libicu-dev \ && rm -rf /var/lib/apt/lists/* # Configure PHP for Cloud Run. # Precompile PHP code with opcache. RUN docker-php-ext-install mysqli intl RUN docker-php-ext-install -j "$(nproc)" opcache RUN set -ex; \ { \ echo "; Cloud Run enforces memory & timeouts"; \ echo "memory_limit = -1"; \ echo "max_execution_time = 0"; \ echo "; File upload at Cloud Run network limit"; \ echo "upload_max_filesize = 32M"; \ echo "post_max_size = 32M"; \ echo "; Configure Opcache for Containers"; \ echo "opcache.enable = On"; \ echo "opcache.validate_timestamps = Off"; \ echo "; Configure Opcache Memory (Application-specific)"; \ echo "opcache.memory_consumption = 32"; \ } > "$PHP_INI_DIR/conf.d/cloud-run.ini" RUN a2enmod rewrite RUN a2enmod headers COPY config/custom.ini /usr/local/etc/php/conf.d/custom.ini # Listen on the port expected by Cloud Run. RUN sed -i 's/80/8080/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf # Copy in custom code from the host machine. WORKDIR /var/www/html COPY . ./ CMD ["apache2-foreground"]