# Apache with mod_php, not because it is fashionable but because it is the same # shape as the shared hosting this has to run on. One image, one process. FROM php:8.5-apache # Passed by CI from the git tag, so the running app knows its own version. ARG VERSION=0.5.6 ENV PHAROS_VERSION=${VERSION} # unzip is not in the base image, and without it composer cannot unpack a single # package from dist. OPcache is part of PHP itself since 8.5; the ini below tunes it. RUN apt-get update \ && apt-get install -y --no-install-recommends unzip libzip-dev \ && rm -rf /var/lib/apt/lists/* \ && a2enmod rewrite \ && docker-php-ext-install -j"$(nproc)" pdo_mysql bcmath zip \ && printf 'opcache.enable=1\nopcache.validate_timestamps=0\nopcache.memory_consumption=128\n' \ > /usr/local/etc/php/conf.d/opcache.ini \ && printf 'expose_php=Off\n' > /usr/local/etc/php/conf.d/hardening.ini ENV APACHE_DOCUMENT_ROOT=/var/www/html/public RUN sed -ri 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' \ /etc/apache2/sites-available/*.conf /etc/apache2/apache2.conf COPY --from=composer:2 /usr/bin/composer /usr/bin/composer WORKDIR /var/www/html # Dependencies first so a code change does not re-resolve the whole tree. COPY composer.json composer.lock ./ RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --no-interaction COPY . . # The version travels with the code, as in the release zip: stamp the config so # the Updates screen shows the tag even when the environment is not passed on. RUN sed -i "s/'version' => env('PHAROS_VERSION', '[^']*')/'version' => env('PHAROS_VERSION', '${VERSION}')/" config/pharos.php \ && grep -q "'${VERSION}'" config/pharos.php \ && composer dump-autoload --optimize --no-interaction \ && chown -R www-data:www-data storage bootstrap/cache database COPY docker/entrypoint.sh /usr/local/bin/entrypoint RUN chmod +x /usr/local/bin/entrypoint EXPOSE 80 # The framework's health route; curl is not in the image, PHP is. HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \ CMD php -r 'exit(@file_get_contents("http://127.0.0.1/up") === false ? 1 : 0);' ENTRYPOINT ["entrypoint"] CMD ["apache2-foreground"]