Created
August 1, 2025 13:02
-
-
Save hgraca/a5653a9a73228b5421605d200189f156 to your computer and use it in GitHub Desktop.
Explicit Dockerfile with explicit tools RUNs to understand what is needed for each tool. To be used only for exploration, as it is very underperformant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# syntax=docker/dockerfile:experimental | |
FROM composer:2 AS composer | |
FROM php:8.4-fpm-bookworm | |
ENV CFLAGS "" | |
ENV CPPFLAGS "" | |
ENV LDFLAGS "" | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y \ | |
locales \ | |
locales-all \ | |
unzip \ | |
git \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# ZIP | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS libzip-dev libzip4 \ | |
&& docker-php-ext-install zip \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS libzip-dev \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# INTL | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS libicu-dev \ | |
&& docker-php-ext-configure intl \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS libicu-dev \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# GD | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS libpng-dev libjpeg62-turbo-dev libfreetype6-dev \ | |
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ | |
&& docker-php-ext-install -j$(nproc) gd \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# FTP | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS \ | |
&& docker-php-ext-install ftp \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# SOAP | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS libxml2-dev\ | |
&& docker-php-ext-install soap \ | |
&& docker-php-ext-enable soap \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# OPcache | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS \ | |
&& docker-php-ext-install opcache \ | |
&& docker-php-ext-enable opcache \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# Mysql/MariaDb | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS \ | |
&& docker-php-ext-install pdo_mysql \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# Redis | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS libzip-dev \ | |
&& pecl install redis-6.1.0 \ | |
&& docker-php-ext-enable redis \ | |
&& pecl clear-cache \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS libzip-dev \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# MongoDB | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS libzip-dev \ | |
&& pecl install mongodb-1.21.0 \ | |
&& docker-php-ext-enable mongodb \ | |
&& pecl clear-cache \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS libzip-dev \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# Kafka | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS librdkafka-dev \ | |
&& pecl install rdkafka-6.0.5 \ | |
&& docker-php-ext-enable rdkafka \ | |
&& pecl clear-cache \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
ARG phpmemlimit=2G | |
RUN cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini \ | |
&& sed -i "s/memory_limit = .*/memory_limit = ${phpmemlimit}/" /usr/local/etc/php/php.ini; | |
# Install PCOV, which is used for running phpunit with coverage, faster | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS \ | |
&& pecl install -o -f pcov \ | |
&& docker-php-ext-enable pcov \ | |
&& pecl clear-cache \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# Install Xdebug | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y --no-install-recommends $PHPIZE_DEPS \ | |
&& pecl install -f xdebug \ | |
&& docker-php-ext-enable xdebug \ | |
&& pecl clear-cache \ | |
&& apt-get purge -y --auto-remove $PHPIZE_DEPS \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# Dev tooling that might have been removed in previous steps | |
RUN --mount=type=cache,target=/var/lib/apt/lists \ | |
--mount=type=cache,target=/var/cache/apt \ | |
apt-get update \ | |
&& apt-get install -y make \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& rm -rf /var/cache/apt/* | |
# Set composer home directory | |
ENV COMPOSER_HOME=/.composer | |
ENV COMPOSER_ALLOW_SUPERUSER=1 | |
COPY --from=composer /usr/bin/composer /usr/bin/composer | |
WORKDIR /app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment