diff --git a/.github/workflows/legacy-v5.yml b/.github/workflows/legacy-v5.yml index 17470df9..cba69dd7 100644 --- a/.github/workflows/legacy-v5.yml +++ b/.github/workflows/legacy-v5.yml @@ -34,8 +34,7 @@ jobs: TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ docker buildx bake \ --set "*.platform=linux/${{ matrix.builder.arch }}" \ - --set "*.output=type=docker" \ - --load --progress=quiet \ + --progress=quiet \ ${BAKE_GROUP//.} - name: Display tags built run: | @@ -57,7 +56,7 @@ jobs: TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ docker buildx bake \ --print --progress=quiet \ - ${BAKE_GROUP//.} | jq -r '.target[].tags[]'); + ${BAKE_GROUP//.} | jq -r '.target[].tags // [] | .[]'); for TAG in $TAGS; do docker push --quiet ${TAG}; done; merge-and-publish: @@ -113,7 +112,7 @@ jobs: TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ docker buildx bake \ --print --progress=quiet \ - ${BAKE_GROUP//.} | jq '.target[].tags[]' + ${BAKE_GROUP//.} | jq '.target[].tags // [] | .[]' - name: Create multiarch manifests run: | # Get all targets from the bake group diff --git a/.github/workflows/purge-cache.yml b/.github/workflows/purge-cache.yml new file mode 100644 index 00000000..39f97b61 --- /dev/null +++ b/.github/workflows/purge-cache.yml @@ -0,0 +1,31 @@ +name: Purge the cache of the layers + +# Runs before the weekly build of v5, so that it starts from an empty cache and takes the updates of the packages +on: + schedule: + - cron: '12 3 * * 0' + workflow_dispatch: + +jobs: + purge-cache: + runs-on: ubuntu-24.04 + permissions: + packages: write + steps: + - name: Login to GHCR + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Delete the versions of the cache + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + CACHE_REPO="ghcr.io/${{ github.repository_owner }}/php-cache" + # GitHub refuses to delete the last version of a package: the "keep" tag (an empty image) stays + docker buildx imagetools create -t "${CACHE_REPO}:keep" docker.io/library/hello-world:latest + OWNER_TYPE=$(gh api "users/${{ github.repository_owner }}" --jq 'if .type == "Organization" then "orgs" else "users" end') + VERSIONS="${OWNER_TYPE}/${{ github.repository_owner }}/packages/container/php-cache/versions" + gh api --paginate "${VERSIONS}" --jq '.[] | select(.metadata.container.tags | index("keep") | not) | .id' \ + | xargs -r -I {} gh api --silent -X DELETE "${VERSIONS}/{}" diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 31ac1391..9d3ec05a 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -17,10 +17,9 @@ jobs: fail-fast: false matrix: php_version: ['8.5', '8.4', '8.3', '8.2'] - variant: ['apache','cli','fpm'] builder: [ {arch: "amd64", os: "ubuntu-24.04"}, {arch: "arm64", os: "ubuntu-24.04-arm"}] runs-on: ${{ matrix.builder.os }} - name: Build&test ${{ matrix.php_version }}-${{ matrix.variant }} ${{ matrix.builder.arch }} + name: Build&test ${{ matrix.php_version }} ${{ matrix.builder.arch }} steps: - name: Checkout uses: actions/checkout@v7 @@ -32,36 +31,37 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 + with: + # The layers of the targets built from another target are only found in the registry cache from BuildKit 0.35 + driver-opts: image=moby/buildkit:v0.35.0-rc1 - name: Build run: | PHP_VERSION="${{ matrix.php_version }}" - # Get last cached successful builds - TAGS=$(REPO="ghcr.io/${{ github.repository_owner }}/php" TAG_PREFIX="" docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --progress=quiet --print | jq -r '.target[].tags[]') - for TAG in $TAGS; do - docker pull --quiet ${TAG} || echo "" - done; - # Build the current builds + # The pull requests only read the cache of v5 + CACHE_REPO="ghcr.io/${{ github.repository_owner }}/php-cache" \ + CACHE_WRITE="${{ github.event_name != 'pull_request' && '1' || '0' }}" \ REPO="ghcr.io/${{ github.repository_owner }}/php" \ ARCH_SUFFIX="-${{ matrix.builder.arch }}" \ TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ docker buildx bake \ --set "*.platform=linux/${{ matrix.builder.arch }}" \ - --set "*.output=type=docker" \ - --load --progress=quiet \ - php${PHP_VERSION//.}-${{ matrix.variant }}-all + --progress=quiet \ + php${PHP_VERSION//.} - name: Display tags built run: | docker image ls --filter="reference=ghcr.io/${{ github.repository_owner }}/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}" - name: Test run: | + PHP_VERSION="${{ matrix.php_version }}" REPO="ghcr.io/${{ github.repository_owner }}/php" \ TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ - PHP_VERSION="${{ matrix.php_version }}" \ + PHP_VERSION="${PHP_VERSION}" \ ARCH_SUFFIX="-${{ matrix.builder.arch }}" \ BRANCH="v5" \ - VARIANT="${{ matrix.variant }}" \ PLATFORM="linux/${{ matrix.builder.arch }}" \ - ./tests-suite/bash_unit -f tap ./tests-suite/*.sh + VARIANTS="apache cli fpm" \ + NODE_VERSIONS="$(docker buildx bake --print --progress=quiet php${PHP_VERSION//.} | jq -r '[.target[].args.NODE_VERSION // empty] | unique | join(" ")')" \ + ./tests-suite/run_tests.sh - name: Publish specific arch version if: > # Only from the main repo github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || @@ -73,20 +73,20 @@ jobs: TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ docker buildx bake \ --print --progress=quiet \ - php${PHP_VERSION//.}-${{ matrix.variant }}-all | jq -r '.target[].tags[]'); - for TAG in $TAGS; do docker push --quiet ${TAG}; done; + php${PHP_VERSION//.} | jq -r '.target[].tags // [] | .[]'); + # 4 images at the same time, with retries: ghcr.io sometimes answers "unknown blob" + printf '%s\n' $TAGS | xargs -P 4 -I {} bash -c 'for i in 1 2 3; do docker push --quiet "{}" && exit 0; sleep 5; done; exit 1' merge-and-publish: if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} needs: - build runs-on: ubuntu-latest - name: Merge and publish ${{ matrix.php_version }}-${{ matrix.variant }} + name: Merge and publish ${{ matrix.php_version }} strategy: fail-fast: false matrix: php_version: ['8.5', '8.4', '8.3', '8.2'] - variant: ['apache','cli','fpm'] steps: - name: Checkout uses: actions/checkout@v7 @@ -111,12 +111,12 @@ jobs: - name: Fetch minor version of php run: | # Pull amd64 slim image to get PHP version - docker pull --quiet ghcr.io/${{ github.repository_owner }}/php:rc${GITHUB_RUN_ID}-${{ matrix.php_version }}-v5-slim-${{ matrix.variant }}-amd64 + docker pull --quiet ghcr.io/${{ github.repository_owner }}/php:rc${GITHUB_RUN_ID}-${{ matrix.php_version }}-v5-slim-cli-amd64 # Retrieve minor - PHP_PATCH_MINOR=`docker run --rm ghcr.io/${{ github.repository_owner }}/php:rc${GITHUB_RUN_ID}-${{ matrix.php_version }}-v5-slim-${{ matrix.variant }}-amd64 php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` + PHP_PATCH_MINOR=`docker run --rm ghcr.io/${{ github.repository_owner }}/php:rc${GITHUB_RUN_ID}-${{ matrix.php_version }}-v5-slim-cli-amd64 php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` echo "PHP_PATCH_MINOR=${PHP_PATCH_MINOR}" echo "PHP_PATCH_MINOR=${PHP_PATCH_MINOR}" >> $GITHUB_ENV - - name: Get list of images for this variant + - name: Get list of images for this PHP version id: get-images run: | PHP_VERSION="${{ matrix.php_version }}" @@ -124,13 +124,13 @@ jobs: TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ docker buildx bake \ --print --progress=quiet \ - php${PHP_VERSION//.}-${{ matrix.variant }}-all | jq '.target[].tags[]' + php${PHP_VERSION//.} | jq '.target[].tags // [] | .[]' - name: Create multiarch manifests run: | PHP_VERSION="${{ matrix.php_version }}" - # Get all targets from the bake group - TARGETS=$(docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --progress=quiet --print | jq -r ".group[\"php${PHP_VERSION//.}-${{ matrix.variant }}-all\"].targets[]") + # Get all the published targets of the bake group + TARGETS=$(docker buildx bake php${PHP_VERSION//.} --progress=quiet --print | jq -r '.target | to_entries[] | select(.value.tags) | .key') for TARGET in $TARGETS; do TAG_ORI=$(REPO="ghcr.io/${{ github.repository_owner }}/php" TAG_PREFIX="rc${GITHUB_RUN_ID}-" docker buildx bake ${TARGET} --progress=quiet --print | jq -r ".target | to_entries[] | select(.key == \"${TARGET}\") | .value.tags[0]") diff --git a/CHANGELOG.md b/CHANGELOG.md index dd094f1a..e875f68c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ * **2026-11-05** * The *apache* and *fpm* images stop right away when a `docker stop` is requested during a long startup step (e.g. a `STARTUP_COMMAND_*`, or the configuration of the extensions on a loaded host): they were killed after the stop timeout (exit code 137 after 10 s) + * Apache `mod_cgid` (`APACHE_EXTENSION_CGID=1`) starts in the *slim-apache* image and with the built-in Apache of the *fpm* variant: its socket directory was missing + * The images of a PHP version are built from common layers: the extensions are installed once for the 3 variants. The *fat* images no longer contain the layers of the *slim* image of their variant, their content is unchanged + * The NodeJS images are tested by the CI * **2026-11-03** * The `php` command is about 20 ms faster on each call: it detects the changes of the `PHP_*` environment variables without starting PHP a first time. The configuration is now also regenerated when a `PHP_*` variable is removed diff --git a/Dockerfile.apache b/Dockerfile.apache index abd1ae21..e472e62f 100644 --- a/Dockerfile.apache +++ b/Dockerfile.apache @@ -3,13 +3,9 @@ ARG INSTALL_CRON=1 ARG INSTALL_COMPOSER=1 ARG INSTALL_LOCALES=1 -ARG PHP_VERSION="8.4" -ARG GLOBAL_VERSION="v5" -ARG REPO="thecodingmachine/php" -ARG TAG_PREFIX="" -ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}${PHP_VERSION}-${GLOBAL_VERSION}-slim-apache" -FROM ${FROM_IMAGE} +# The slim Dockerfile of the variant applied on Dockerfile.extensions (see docker-bake.hcl) +FROM slim-with-extensions LABEL authors="Mistral Oz , Julien Neuhart , David Négrier " SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -17,15 +13,10 @@ ARG TARGETOS ARG TARGETARCH ARG BLACKFIRE_VERSION=2 -# |-------------------------------------------------------------------------- -# | Main PHP extensions -# |-------------------------------------------------------------------------- -# | -# | Installs the main PHP extensions -# | - +# The packages of the variant enable all the extensions installed before them: enable only the ones of the slim image USER root -RUN cd /usr/local/lib/thecodingmachine-php/extensions/current/ && ./install_all.sh && ./disable_all.sh +RUN /usr/bin/real_php /usr/local/bin/setup_extensions.php | bash && \ + cd /usr/local/lib/thecodingmachine-php/extensions/current/ && ./disable_all.sh USER docker # |-------------------------------------------------------------------------- diff --git a/Dockerfile.base b/Dockerfile.base new file mode 100644 index 00000000..28f1da12 --- /dev/null +++ b/Dockerfile.base @@ -0,0 +1,164 @@ +#syntax=docker/dockerfile-upstream:1 +# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) +FROM ubuntu:24.04 +LABEL authors="Mistral Oz , Julien Neuhart , David Négrier " +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# Fixes some weird terminal issues such as broken clear / CTRL+L +#ENV TERM=linux + +# Ensure apt doesn't ask questions when installing stuff +ENV DEBIAN_FRONTEND=noninteractive + +ARG PHP_VERSION +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=2 + +ENV TARGETOS=${TARGETOS} +ENV TARGETARCH=${TARGETARCH} +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} +ENV PHP_VERSION=${PHP_VERSION} + +# |-------------------------------------------------------------------------- +# | Main PHP extensions +# |-------------------------------------------------------------------------- +# | +# | Installs the main PHP extensions +# | + +# Install php an other packages +RUN apt update \ + && apt upgrade -y \ + && apt install -y --no-install-recommends curl ca-certificates \ + && curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb \ + && dpkg -i /tmp/debsuryorg-archive-keyring.deb \ + && . /etc/os-release \ + && echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/php.list \ + && apt update \ + && apt install -y --no-install-recommends \ + nano \ + sudo \ + git \ + iproute2 \ + procps \ + curl \ + unzip \ + ca-certificates \ + openssh-client \ + && apt clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* +# Note: From PHP 8.5, opcache is built-in and php${PHP_VERSION}-opcache package doesn't exist +RUN OPCACHE_PACKAGE="" \ + && if [ "${PHP_VERSION}" != "8.5" ]; then \ + OPCACHE_PACKAGE="php${PHP_VERSION}-opcache"; \ + fi \ + && apt update \ + && apt install -y --no-install-recommends \ + php${PHP_VERSION}-cli \ + php${PHP_VERSION}-curl \ + php${PHP_VERSION}-mbstring \ + ${OPCACHE_PACKAGE} \ + php${PHP_VERSION}-readline \ + php${PHP_VERSION}-xml \ + php${PHP_VERSION}-zip \ + && apt clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* + +# |-------------------------------------------------------------------------- +# | User +# |-------------------------------------------------------------------------- +# | +# | Define a default user with sudo rights. +# | + +RUN userdel ubuntu && rm -rf /home/ubuntu +RUN useradd -ms /bin/bash docker && adduser docker sudo +# Users in the sudoers group can sudo as root without password. +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/sudo + +# |-------------------------------------------------------------------------- +# | Default php.ini file +# |-------------------------------------------------------------------------- +# | +# | For some reasons, the official image has a php.ini-production.cli file +# | but no php.ini-development.cli file. Let's create this one. +# | + +RUN cp /usr/lib/php/${PHP_VERSION}/php.ini-development /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ + sed -i 's/^disable_functions/;disable_functions/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ + sed -i 's/^memory_limit = .*/memory_limit = -1/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli + +#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-production /usr/local/etc/php/php.ini-production +#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-development /usr/local/etc/php/php.ini-development +#RUN chmod 644 /usr/local/etc/php/php.ini-* + +ENV TEMPLATE_PHP_INI=development + +# Let's remove the default CLI php.ini file (it will be copied from TEMPLATE_PHP_INI) +RUN rm /etc/php/${PHP_VERSION}/cli/php.ini + +# |-------------------------------------------------------------------------- +# | Composer +# |-------------------------------------------------------------------------- +# | +# | Installs Composer to easily manage your PHP dependencies. +# | + +#ENV COMPOSER_ALLOW_SUPERUSER 1 + +RUN curl -sS --retry 5 --retry-delay 2 https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer &&\ + chmod +x /usr/local/bin/composer +COPY utils/select_composer_version.sh /usr/local/bin/select_composer_version.sh + +# TODO: utils.php in /usr/local/bin... bof! +COPY utils/utils.php /usr/local/bin/utils.php +RUN mv /usr/bin/php /usr/bin/real_php +COPY utils/php_proxy.sh /usr/bin/php +COPY utils/php_env_fingerprint.sh /usr/local/bin/php_env_fingerprint.sh +RUN touch /opt/php_env_fingerprint +COPY utils/generate_conf.php /usr/local/bin/generate_conf.php +COPY utils/setup_extensions.php /usr/local/bin/setup_extensions.php + +# |-------------------------------------------------------------------------- +# | Default PHP extensions to be enabled +# | By default, enable all the extensions that are enabled on a base Ubuntu install +# |-------------------------------------------------------------------------- +ENV PHP_EXTENSION_CALENDAR=1 \ + PHP_EXTENSION_CTYPE=1 \ + PHP_EXTENSION_CURL=1 \ + PHP_EXTENSION_DOM=1 \ + PHP_EXTENSION_EXIF=1 \ + PHP_EXTENSION_FILEINFO=1 \ + PHP_EXTENSION_FTP=1 \ + PHP_EXTENSION_GETTEXT=1 \ + PHP_EXTENSION_ICONV=1 \ + PHP_EXTENSION_JSON=1 \ + PHP_EXTENSION_MBSTRING=1 \ + PHP_EXTENSION_OPCACHE=1 \ + PHP_EXTENSION_PDO=1 \ + PHP_EXTENSION_PHAR=1 \ + PHP_EXTENSION_POSIX=1 \ + PHP_EXTENSION_READLINE=1 \ + PHP_EXTENSION_SHMOP=1 \ + PHP_EXTENSION_SIMPLEXML=1 \ + PHP_EXTENSION_SOCKETS=1 \ + PHP_EXTENSION_SYSVMSG=1 \ + PHP_EXTENSION_SYSVSEM=1 \ + PHP_EXTENSION_SYSVSHM=1 \ + PHP_EXTENSION_TOKENIZER=1 \ + PHP_EXTENSION_WDDX=1 \ + PHP_EXTENSION_XML=1 \ + PHP_EXTENSION_XMLREADER=1 \ + PHP_EXTENSION_XMLWRITER=1 \ + PHP_EXTENSION_XSL=1 \ + PHP_EXTENSION_ZIP=1 + +USER docker +RUN composer global require bamarni/symfony-console-autocomplete && \ + rm -rf ~/.composer/cache + +USER root + +COPY extensions/ /usr/local/lib/thecodingmachine-php/extensions +RUN ln -s ${PHP_VERSION} /usr/local/lib/thecodingmachine-php/extensions/current diff --git a/Dockerfile.cli b/Dockerfile.cli index 61d91277..e472e62f 100644 --- a/Dockerfile.cli +++ b/Dockerfile.cli @@ -3,13 +3,9 @@ ARG INSTALL_CRON=1 ARG INSTALL_COMPOSER=1 ARG INSTALL_LOCALES=1 -ARG PHP_VERSION="8.4" -ARG GLOBAL_VERSION="v5" -ARG REPO="thecodingmachine/php" -ARG TAG_PREFIX="" -ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}${PHP_VERSION}-${GLOBAL_VERSION}-slim-cli" -FROM ${FROM_IMAGE} +# The slim Dockerfile of the variant applied on Dockerfile.extensions (see docker-bake.hcl) +FROM slim-with-extensions LABEL authors="Mistral Oz , Julien Neuhart , David Négrier " SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -17,15 +13,10 @@ ARG TARGETOS ARG TARGETARCH ARG BLACKFIRE_VERSION=2 -# |-------------------------------------------------------------------------- -# | Main PHP extensions -# |-------------------------------------------------------------------------- -# | -# | Installs the main PHP extensions -# | - +# The packages of the variant enable all the extensions installed before them: enable only the ones of the slim image USER root -RUN cd /usr/local/lib/thecodingmachine-php/extensions/current/ && ./install_all.sh && ./disable_all.sh +RUN /usr/bin/real_php /usr/local/bin/setup_extensions.php | bash && \ + cd /usr/local/lib/thecodingmachine-php/extensions/current/ && ./disable_all.sh USER docker # |-------------------------------------------------------------------------- diff --git a/Dockerfile.extensions b/Dockerfile.extensions new file mode 100644 index 00000000..197aef4d --- /dev/null +++ b/Dockerfile.extensions @@ -0,0 +1,16 @@ +#syntax=docker/dockerfile-upstream:1 +# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) +FROM base + +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=2 + +# |-------------------------------------------------------------------------- +# | Main PHP extensions +# |-------------------------------------------------------------------------- +# | +# | Installs the main PHP extensions, shared by the fat images of all the variants +# | + +RUN cd /usr/local/lib/thecodingmachine-php/extensions/current/ && ./install_all.sh && ./disable_all.sh diff --git a/Dockerfile.fpm b/Dockerfile.fpm index bfa0abb9..e472e62f 100644 --- a/Dockerfile.fpm +++ b/Dockerfile.fpm @@ -3,13 +3,9 @@ ARG INSTALL_CRON=1 ARG INSTALL_COMPOSER=1 ARG INSTALL_LOCALES=1 -ARG PHP_VERSION="8.4" -ARG GLOBAL_VERSION="v5" -ARG REPO="thecodingmachine/php" -ARG TAG_PREFIX="" -ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}${PHP_VERSION}-${GLOBAL_VERSION}-slim-fpm" -FROM ${FROM_IMAGE} +# The slim Dockerfile of the variant applied on Dockerfile.extensions (see docker-bake.hcl) +FROM slim-with-extensions LABEL authors="Mistral Oz , Julien Neuhart , David Négrier " SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -17,15 +13,10 @@ ARG TARGETOS ARG TARGETARCH ARG BLACKFIRE_VERSION=2 -# |-------------------------------------------------------------------------- -# | Main PHP extensions -# |-------------------------------------------------------------------------- -# | -# | Installs the main PHP extensions -# | - +# The packages of the variant enable all the extensions installed before them: enable only the ones of the slim image USER root -RUN cd /usr/local/lib/thecodingmachine-php/extensions/current/ && ./install_all.sh && ./disable_all.sh +RUN /usr/bin/real_php /usr/local/bin/setup_extensions.php | bash && \ + cd /usr/local/lib/thecodingmachine-php/extensions/current/ && ./disable_all.sh USER docker # |-------------------------------------------------------------------------- diff --git a/Dockerfile.slim.apache b/Dockerfile.slim.apache index f7cecd31..1482863e 100644 --- a/Dockerfile.slim.apache +++ b/Dockerfile.slim.apache @@ -1,168 +1,12 @@ #syntax=docker/dockerfile-upstream:1 # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) -FROM ubuntu:24.04 -LABEL authors="Mistral Oz , Julien Neuhart , David Négrier " -SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# "base" is Dockerfile.base for the slim images, Dockerfile.extensions for the fat ones (see docker-bake.hcl) +FROM base -# Fixes some weird terminal issues such as broken clear / CTRL+L -#ENV TERM=linux - -# Ensure apt doesn't ask questions when installing stuff -ENV DEBIAN_FRONTEND=noninteractive - -ARG PHP_VERSION -ARG TARGETOS -ARG TARGETARCH -ARG BLACKFIRE_VERSION=2 ONBUILD ARG TARGETOS=${TARGETOS} ONBUILD ARG TARGETARCH=${TARGETARCH} ONBUILD ARG BLACKFIRE_VERSION=${BLACKFIRE_VERSION} -ENV TARGETOS=${TARGETOS} -ENV TARGETARCH=${TARGETARCH} -ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} -ENV PHP_VERSION=${PHP_VERSION} - -# |-------------------------------------------------------------------------- -# | Main PHP extensions -# |-------------------------------------------------------------------------- -# | -# | Installs the main PHP extensions -# | - -# Install php an other packages -RUN apt update \ - && apt upgrade -y \ - && apt install -y --no-install-recommends curl ca-certificates \ - && curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb \ - && dpkg -i /tmp/debsuryorg-archive-keyring.deb \ - && . /etc/os-release \ - && echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/php.list \ - && apt update \ - && apt install -y --no-install-recommends \ - nano \ - sudo \ - git \ - iproute2 \ - procps \ - curl \ - unzip \ - ca-certificates \ - openssh-client \ - && apt clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* -# Note: From PHP 8.5, opcache is built-in and php${PHP_VERSION}-opcache package doesn't exist -RUN OPCACHE_PACKAGE="" \ - && if [ "${PHP_VERSION}" != "8.5" ]; then \ - OPCACHE_PACKAGE="php${PHP_VERSION}-opcache"; \ - fi \ - && apt update \ - && apt install -y --no-install-recommends \ - php${PHP_VERSION}-cli \ - php${PHP_VERSION}-curl \ - php${PHP_VERSION}-mbstring \ - ${OPCACHE_PACKAGE} \ - php${PHP_VERSION}-readline \ - php${PHP_VERSION}-xml \ - php${PHP_VERSION}-zip \ - && apt clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - -# |-------------------------------------------------------------------------- -# | User -# |-------------------------------------------------------------------------- -# | -# | Define a default user with sudo rights. -# | - -RUN userdel ubuntu && rm -rf /home/ubuntu -RUN useradd -ms /bin/bash docker && adduser docker sudo -# Users in the sudoers group can sudo as root without password. -RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/sudo - -# |-------------------------------------------------------------------------- -# | Default php.ini file -# |-------------------------------------------------------------------------- -# | -# | For some reasons, the official image has a php.ini-production.cli file -# | but no php.ini-development.cli file. Let's create this one. -# | - -RUN cp /usr/lib/php/${PHP_VERSION}/php.ini-development /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ - sed -i 's/^disable_functions/;disable_functions/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ - sed -i 's/^memory_limit = .*/memory_limit = -1/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli - -#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-production /usr/local/etc/php/php.ini-production -#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-development /usr/local/etc/php/php.ini-development -#RUN chmod 644 /usr/local/etc/php/php.ini-* - -ENV TEMPLATE_PHP_INI=development - -# Let's remove the default CLI php.ini file (it will be copied from TEMPLATE_PHP_INI) -RUN rm /etc/php/${PHP_VERSION}/cli/php.ini - -# |-------------------------------------------------------------------------- -# | Composer -# |-------------------------------------------------------------------------- -# | -# | Installs Composer to easily manage your PHP dependencies. -# | - -#ENV COMPOSER_ALLOW_SUPERUSER 1 - -RUN curl -sS --retry 5 --retry-delay 2 https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer &&\ - chmod +x /usr/local/bin/composer -COPY utils/select_composer_version.sh /usr/local/bin/select_composer_version.sh - -# TODO: utils.php in /usr/local/bin... bof! -COPY utils/utils.php /usr/local/bin/utils.php -RUN mv /usr/bin/php /usr/bin/real_php -COPY utils/php_proxy.sh /usr/bin/php -COPY utils/php_env_fingerprint.sh /usr/local/bin/php_env_fingerprint.sh -RUN touch /opt/php_env_fingerprint -COPY utils/generate_conf.php /usr/local/bin/generate_conf.php -COPY utils/setup_extensions.php /usr/local/bin/setup_extensions.php - -# |-------------------------------------------------------------------------- -# | Default PHP extensions to be enabled -# | By default, enable all the extensions that are enabled on a base Ubuntu install -# |-------------------------------------------------------------------------- -ENV PHP_EXTENSION_CALENDAR=1 \ - PHP_EXTENSION_CTYPE=1 \ - PHP_EXTENSION_CURL=1 \ - PHP_EXTENSION_DOM=1 \ - PHP_EXTENSION_EXIF=1 \ - PHP_EXTENSION_FILEINFO=1 \ - PHP_EXTENSION_FTP=1 \ - PHP_EXTENSION_GETTEXT=1 \ - PHP_EXTENSION_ICONV=1 \ - PHP_EXTENSION_JSON=1 \ - PHP_EXTENSION_MBSTRING=1 \ - PHP_EXTENSION_OPCACHE=1 \ - PHP_EXTENSION_PDO=1 \ - PHP_EXTENSION_PHAR=1 \ - PHP_EXTENSION_POSIX=1 \ - PHP_EXTENSION_READLINE=1 \ - PHP_EXTENSION_SHMOP=1 \ - PHP_EXTENSION_SIMPLEXML=1 \ - PHP_EXTENSION_SOCKETS=1 \ - PHP_EXTENSION_SYSVMSG=1 \ - PHP_EXTENSION_SYSVSEM=1 \ - PHP_EXTENSION_SYSVSHM=1 \ - PHP_EXTENSION_TOKENIZER=1 \ - PHP_EXTENSION_WDDX=1 \ - PHP_EXTENSION_XML=1 \ - PHP_EXTENSION_XMLREADER=1 \ - PHP_EXTENSION_XMLWRITER=1 \ - PHP_EXTENSION_XSL=1 \ - PHP_EXTENSION_ZIP=1 - -USER docker -RUN composer global require bamarni/symfony-console-autocomplete && \ - rm -rf ~/.composer/cache - -USER root - # Apache: built-in web server of the fpm variant (disabled by default, see PHP_FPM_WEB_SERVER) ENV APACHE_CONFDIR=/etc/apache2 @@ -186,6 +30,7 @@ RUN set -eux; \ for dir in \ "$APACHE_LOCK_DIR" \ "$APACHE_RUN_DIR" \ + "$APACHE_RUN_DIR/socks" \ "$APACHE_LOG_DIR" \ ; do \ rm -rvf "$dir"; \ @@ -338,8 +183,6 @@ COPY utils/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh COPY utils/docker-entrypoint-as-root.sh /usr/local/bin/docker-entrypoint-as-root.sh COPY utils/supervise.sh /usr/local/bin/supervise.sh -COPY extensions/ /usr/local/lib/thecodingmachine-php/extensions -RUN ln -s ${PHP_VERSION} /usr/local/lib/thecodingmachine-php/extensions/current ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] diff --git a/Dockerfile.slim.cli b/Dockerfile.slim.cli index 92e66fca..b0e3a21a 100644 --- a/Dockerfile.slim.cli +++ b/Dockerfile.slim.cli @@ -1,168 +1,12 @@ #syntax=docker/dockerfile-upstream:1 # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) -FROM ubuntu:24.04 -LABEL authors="Mistral Oz , Julien Neuhart , David Négrier " -SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# "base" is Dockerfile.base for the slim images, Dockerfile.extensions for the fat ones (see docker-bake.hcl) +FROM base -# Fixes some weird terminal issues such as broken clear / CTRL+L -#ENV TERM=linux - -# Ensure apt doesn't ask questions when installing stuff -ENV DEBIAN_FRONTEND=noninteractive - -ARG PHP_VERSION -ARG TARGETOS -ARG TARGETARCH -ARG BLACKFIRE_VERSION=2 ONBUILD ARG TARGETOS=${TARGETOS} ONBUILD ARG TARGETARCH=${TARGETARCH} ONBUILD ARG BLACKFIRE_VERSION=${BLACKFIRE_VERSION} -ENV TARGETOS=${TARGETOS} -ENV TARGETARCH=${TARGETARCH} -ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} -ENV PHP_VERSION=${PHP_VERSION} - -# |-------------------------------------------------------------------------- -# | Main PHP extensions -# |-------------------------------------------------------------------------- -# | -# | Installs the main PHP extensions -# | - -# Install php an other packages -RUN apt update \ - && apt upgrade -y \ - && apt install -y --no-install-recommends curl ca-certificates \ - && curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb \ - && dpkg -i /tmp/debsuryorg-archive-keyring.deb \ - && . /etc/os-release \ - && echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/php.list \ - && apt update \ - && apt install -y --no-install-recommends \ - nano \ - sudo \ - git \ - iproute2 \ - procps \ - curl \ - unzip \ - ca-certificates \ - openssh-client \ - && apt clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* -# Note: From PHP 8.5, opcache is built-in and php${PHP_VERSION}-opcache package doesn't exist -RUN OPCACHE_PACKAGE="" \ - && if [ "${PHP_VERSION}" != "8.5" ]; then \ - OPCACHE_PACKAGE="php${PHP_VERSION}-opcache"; \ - fi \ - && apt update \ - && apt install -y --no-install-recommends \ - php${PHP_VERSION}-cli \ - php${PHP_VERSION}-curl \ - php${PHP_VERSION}-mbstring \ - ${OPCACHE_PACKAGE} \ - php${PHP_VERSION}-readline \ - php${PHP_VERSION}-xml \ - php${PHP_VERSION}-zip \ - && apt clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - -# |-------------------------------------------------------------------------- -# | User -# |-------------------------------------------------------------------------- -# | -# | Define a default user with sudo rights. -# | - -RUN userdel ubuntu && rm -rf /home/ubuntu -RUN useradd -ms /bin/bash docker && adduser docker sudo -# Users in the sudoers group can sudo as root without password. -RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/sudo - -# |-------------------------------------------------------------------------- -# | Default php.ini file -# |-------------------------------------------------------------------------- -# | -# | For some reasons, the official image has a php.ini-production.cli file -# | but no php.ini-development.cli file. Let's create this one. -# | - -RUN cp /usr/lib/php/${PHP_VERSION}/php.ini-development /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ - sed -i 's/^disable_functions/;disable_functions/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ - sed -i 's/^memory_limit = .*/memory_limit = -1/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli - -#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-production /usr/local/etc/php/php.ini-production -#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-development /usr/local/etc/php/php.ini-development -#RUN chmod 644 /usr/local/etc/php/php.ini-* - -ENV TEMPLATE_PHP_INI=development - -# Let's remove the default CLI php.ini file (it will be copied from TEMPLATE_PHP_INI) -RUN rm /etc/php/${PHP_VERSION}/cli/php.ini - -# |-------------------------------------------------------------------------- -# | Composer -# |-------------------------------------------------------------------------- -# | -# | Installs Composer to easily manage your PHP dependencies. -# | - -#ENV COMPOSER_ALLOW_SUPERUSER 1 - -RUN curl -sS --retry 5 --retry-delay 2 https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer &&\ - chmod +x /usr/local/bin/composer -COPY utils/select_composer_version.sh /usr/local/bin/select_composer_version.sh - -# TODO: utils.php in /usr/local/bin... bof! -COPY utils/utils.php /usr/local/bin/utils.php -RUN mv /usr/bin/php /usr/bin/real_php -COPY utils/php_proxy.sh /usr/bin/php -COPY utils/php_env_fingerprint.sh /usr/local/bin/php_env_fingerprint.sh -RUN touch /opt/php_env_fingerprint -COPY utils/generate_conf.php /usr/local/bin/generate_conf.php -COPY utils/setup_extensions.php /usr/local/bin/setup_extensions.php - -# |-------------------------------------------------------------------------- -# | Default PHP extensions to be enabled -# | By default, enable all the extensions that are enabled on a base Ubuntu install -# |-------------------------------------------------------------------------- -ENV PHP_EXTENSION_CALENDAR=1 \ - PHP_EXTENSION_CTYPE=1 \ - PHP_EXTENSION_CURL=1 \ - PHP_EXTENSION_DOM=1 \ - PHP_EXTENSION_EXIF=1 \ - PHP_EXTENSION_FILEINFO=1 \ - PHP_EXTENSION_FTP=1 \ - PHP_EXTENSION_GETTEXT=1 \ - PHP_EXTENSION_ICONV=1 \ - PHP_EXTENSION_JSON=1 \ - PHP_EXTENSION_MBSTRING=1 \ - PHP_EXTENSION_OPCACHE=1 \ - PHP_EXTENSION_PDO=1 \ - PHP_EXTENSION_PHAR=1 \ - PHP_EXTENSION_POSIX=1 \ - PHP_EXTENSION_READLINE=1 \ - PHP_EXTENSION_SHMOP=1 \ - PHP_EXTENSION_SIMPLEXML=1 \ - PHP_EXTENSION_SOCKETS=1 \ - PHP_EXTENSION_SYSVMSG=1 \ - PHP_EXTENSION_SYSVSEM=1 \ - PHP_EXTENSION_SYSVSHM=1 \ - PHP_EXTENSION_TOKENIZER=1 \ - PHP_EXTENSION_WDDX=1 \ - PHP_EXTENSION_XML=1 \ - PHP_EXTENSION_XMLREADER=1 \ - PHP_EXTENSION_XMLWRITER=1 \ - PHP_EXTENSION_XSL=1 \ - PHP_EXTENSION_ZIP=1 - -USER docker -RUN composer global require bamarni/symfony-console-autocomplete && \ - rm -rf ~/.composer/cache - -USER root - @@ -251,8 +95,6 @@ COPY utils/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh COPY utils/docker-entrypoint-as-root.sh /usr/local/bin/docker-entrypoint-as-root.sh COPY utils/supervise.sh /usr/local/bin/supervise.sh -COPY extensions/ /usr/local/lib/thecodingmachine-php/extensions -RUN ln -s ${PHP_VERSION} /usr/local/lib/thecodingmachine-php/extensions/current ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] diff --git a/Dockerfile.slim.fpm b/Dockerfile.slim.fpm index 619b8b56..94d56317 100644 --- a/Dockerfile.slim.fpm +++ b/Dockerfile.slim.fpm @@ -1,168 +1,12 @@ #syntax=docker/dockerfile-upstream:1 # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) -FROM ubuntu:24.04 -LABEL authors="Mistral Oz , Julien Neuhart , David Négrier " -SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# "base" is Dockerfile.base for the slim images, Dockerfile.extensions for the fat ones (see docker-bake.hcl) +FROM base -# Fixes some weird terminal issues such as broken clear / CTRL+L -#ENV TERM=linux - -# Ensure apt doesn't ask questions when installing stuff -ENV DEBIAN_FRONTEND=noninteractive - -ARG PHP_VERSION -ARG TARGETOS -ARG TARGETARCH -ARG BLACKFIRE_VERSION=2 ONBUILD ARG TARGETOS=${TARGETOS} ONBUILD ARG TARGETARCH=${TARGETARCH} ONBUILD ARG BLACKFIRE_VERSION=${BLACKFIRE_VERSION} -ENV TARGETOS=${TARGETOS} -ENV TARGETARCH=${TARGETARCH} -ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} -ENV PHP_VERSION=${PHP_VERSION} - -# |-------------------------------------------------------------------------- -# | Main PHP extensions -# |-------------------------------------------------------------------------- -# | -# | Installs the main PHP extensions -# | - -# Install php an other packages -RUN apt update \ - && apt upgrade -y \ - && apt install -y --no-install-recommends curl ca-certificates \ - && curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb \ - && dpkg -i /tmp/debsuryorg-archive-keyring.deb \ - && . /etc/os-release \ - && echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/php.list \ - && apt update \ - && apt install -y --no-install-recommends \ - nano \ - sudo \ - git \ - iproute2 \ - procps \ - curl \ - unzip \ - ca-certificates \ - openssh-client \ - && apt clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* -# Note: From PHP 8.5, opcache is built-in and php${PHP_VERSION}-opcache package doesn't exist -RUN OPCACHE_PACKAGE="" \ - && if [ "${PHP_VERSION}" != "8.5" ]; then \ - OPCACHE_PACKAGE="php${PHP_VERSION}-opcache"; \ - fi \ - && apt update \ - && apt install -y --no-install-recommends \ - php${PHP_VERSION}-cli \ - php${PHP_VERSION}-curl \ - php${PHP_VERSION}-mbstring \ - ${OPCACHE_PACKAGE} \ - php${PHP_VERSION}-readline \ - php${PHP_VERSION}-xml \ - php${PHP_VERSION}-zip \ - && apt clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - -# |-------------------------------------------------------------------------- -# | User -# |-------------------------------------------------------------------------- -# | -# | Define a default user with sudo rights. -# | - -RUN userdel ubuntu && rm -rf /home/ubuntu -RUN useradd -ms /bin/bash docker && adduser docker sudo -# Users in the sudoers group can sudo as root without password. -RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/sudo - -# |-------------------------------------------------------------------------- -# | Default php.ini file -# |-------------------------------------------------------------------------- -# | -# | For some reasons, the official image has a php.ini-production.cli file -# | but no php.ini-development.cli file. Let's create this one. -# | - -RUN cp /usr/lib/php/${PHP_VERSION}/php.ini-development /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ - sed -i 's/^disable_functions/;disable_functions/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ - sed -i 's/^memory_limit = .*/memory_limit = -1/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli - -#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-production /usr/local/etc/php/php.ini-production -#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-development /usr/local/etc/php/php.ini-development -#RUN chmod 644 /usr/local/etc/php/php.ini-* - -ENV TEMPLATE_PHP_INI=development - -# Let's remove the default CLI php.ini file (it will be copied from TEMPLATE_PHP_INI) -RUN rm /etc/php/${PHP_VERSION}/cli/php.ini - -# |-------------------------------------------------------------------------- -# | Composer -# |-------------------------------------------------------------------------- -# | -# | Installs Composer to easily manage your PHP dependencies. -# | - -#ENV COMPOSER_ALLOW_SUPERUSER 1 - -RUN curl -sS --retry 5 --retry-delay 2 https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer &&\ - chmod +x /usr/local/bin/composer -COPY utils/select_composer_version.sh /usr/local/bin/select_composer_version.sh - -# TODO: utils.php in /usr/local/bin... bof! -COPY utils/utils.php /usr/local/bin/utils.php -RUN mv /usr/bin/php /usr/bin/real_php -COPY utils/php_proxy.sh /usr/bin/php -COPY utils/php_env_fingerprint.sh /usr/local/bin/php_env_fingerprint.sh -RUN touch /opt/php_env_fingerprint -COPY utils/generate_conf.php /usr/local/bin/generate_conf.php -COPY utils/setup_extensions.php /usr/local/bin/setup_extensions.php - -# |-------------------------------------------------------------------------- -# | Default PHP extensions to be enabled -# | By default, enable all the extensions that are enabled on a base Ubuntu install -# |-------------------------------------------------------------------------- -ENV PHP_EXTENSION_CALENDAR=1 \ - PHP_EXTENSION_CTYPE=1 \ - PHP_EXTENSION_CURL=1 \ - PHP_EXTENSION_DOM=1 \ - PHP_EXTENSION_EXIF=1 \ - PHP_EXTENSION_FILEINFO=1 \ - PHP_EXTENSION_FTP=1 \ - PHP_EXTENSION_GETTEXT=1 \ - PHP_EXTENSION_ICONV=1 \ - PHP_EXTENSION_JSON=1 \ - PHP_EXTENSION_MBSTRING=1 \ - PHP_EXTENSION_OPCACHE=1 \ - PHP_EXTENSION_PDO=1 \ - PHP_EXTENSION_PHAR=1 \ - PHP_EXTENSION_POSIX=1 \ - PHP_EXTENSION_READLINE=1 \ - PHP_EXTENSION_SHMOP=1 \ - PHP_EXTENSION_SIMPLEXML=1 \ - PHP_EXTENSION_SOCKETS=1 \ - PHP_EXTENSION_SYSVMSG=1 \ - PHP_EXTENSION_SYSVSEM=1 \ - PHP_EXTENSION_SYSVSHM=1 \ - PHP_EXTENSION_TOKENIZER=1 \ - PHP_EXTENSION_WDDX=1 \ - PHP_EXTENSION_XML=1 \ - PHP_EXTENSION_XMLREADER=1 \ - PHP_EXTENSION_XMLWRITER=1 \ - PHP_EXTENSION_XSL=1 \ - PHP_EXTENSION_ZIP=1 - -USER docker -RUN composer global require bamarni/symfony-console-autocomplete && \ - rm -rf ~/.composer/cache - -USER root - # Apache: built-in web server of the fpm variant (disabled by default, see PHP_FPM_WEB_SERVER) ENV APACHE_CONFDIR=/etc/apache2 @@ -186,6 +30,7 @@ RUN set -eux; \ for dir in \ "$APACHE_LOCK_DIR" \ "$APACHE_RUN_DIR" \ + "$APACHE_RUN_DIR/socks" \ "$APACHE_LOG_DIR" \ ; do \ rm -rvf "$dir"; \ @@ -365,8 +210,6 @@ COPY utils/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh COPY utils/docker-entrypoint-as-root.sh /usr/local/bin/docker-entrypoint-as-root.sh COPY utils/supervise.sh /usr/local/bin/supervise.sh -COPY extensions/ /usr/local/lib/thecodingmachine-php/extensions -RUN ln -s ${PHP_VERSION} /usr/local/lib/thecodingmachine-php/extensions/current ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] diff --git a/Makefile b/Makefile index 6c7e0a2c..46ec6148 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ _test-prerequisites: blueprint docker pull ubuntu:20.04 test-hot: ## Test 7.4, 8.0 and 8.1 quickly - docker buildx bake --load \ + docker buildx bake \ --set "*.platform=$$(docker version -f '{{.Server.Os}}/{{.Server.Arch}}')" \ php80-slim-cli php80-cli docker run --rm -it docker.io/thecodingmachine/php:8.0-v5-cli php -v @@ -55,21 +55,21 @@ test-node: ## Test node builds only VERSION=8.4 VARIANT=cli NODE=26 $(MAKE) _test-node _test-node: _test-prerequisites ## Test node for VERSION="" and VARIANT="" - docker buildx bake --load \ + docker buildx bake \ --set "*.platform=$$(docker version -f '{{.Server.Os}}/{{.Server.Arch}}')" \ php$${VERSION//.}-$(VARIANT)-all PHP_VERSION="$(VERSION)" BRANCH=v5 VARIANT=$(VARIANT) NODE=$(NODE) ./tests-suite/bash_unit -f tap ./tests-suite/*.sh || (notify-send -u critical "Tests failed ($(VERSION)-$(VARIANT)-node$(NODE))" && exit 1) notify-send -u critical "Tests passed with success ($(VERSION)-$(VARIANT)-node$(NODE))" _test-version: _test-prerequisites ## Test php build for VERSION="" and VARIANT="" - docker buildx bake --load \ + docker buildx bake \ --set "*.platform=$$(docker version -f '{{.Server.Os}}/{{.Server.Arch}}')" \ php$${VERSION//.}-$(VARIANT)-all PHP_VERSION="$(VERSION)" BRANCH=v5 VARIANT=$(VARIANT) ./tests-suite/bash_unit -f tap ./tests-suite/*.sh || (notify-send -u critical "Tests failed ($(VERSION)-$(VARIANT))" && exit 1) notify-send -u critical "Tests passed with success ($(VERSION)-$(VARIANT))" _test-version-quick: _test-prerequisites ## Test php build for VERSION="" and VARIANT="" (without node variants) - docker buildx bake --load \ + docker buildx bake \ --set "*.platform=$$(docker version -f '{{.Server.Os}}/{{.Server.Arch}}')" \ php$${VERSION//.}-slim-$(VARIANT) php$${VERSION//.}-$(VARIANT) PHP_VERSION="$(VERSION)" BRANCH=v5 VARIANT=$(VARIANT) ./tests-suite/bash_unit -f tap ./tests-suite/*.sh || (notify-send -u critical "Tests failed ($(VERSION)-$(VARIANT))" && exit 1) @@ -80,28 +80,7 @@ clean: ## Clean dangles image after build cves: - docker build \ - --build-arg PHP_VERSION="8.4" \ - --build-arg VARIANT="apache" \ - --build-arg GLOBAL_VERSION="v5" \ - --file ./Dockerfile.slim.apache \ - --tag testv5-slim \ - . - docker --debug build \ - --build-arg PHP_VERSION="8.4" \ - --build-arg VARIANT="apache" \ - --build-arg GLOBAL_VERSION="v5" \ - --build-arg FROM_IMAGE="testv5-slim" \ - --file ./Dockerfile.apache \ - --tag testv5 \ - . - docker --debug build \ - --build-arg PHP_VERSION="8.4" \ - --build-arg VARIANT="apache-node22" \ - --build-arg NODE_VERSION="22" \ - --build-arg GLOBAL_VERSION="v5" \ - --build-arg FROM_IMAGE="testv5" \ - --file ./Dockerfile.apache.node \ - --tag testv5-node \ - . - docker scout cves testv5-node --only-fixed --locations + docker buildx bake \ + --set "*.platform=$$(docker version -f '{{.Server.Os}}/{{.Server.Arch}}')" \ + php84-apache-node22 + docker scout cves thecodingmachine/php:8.4-v5-apache-node22 --only-fixed --locations diff --git a/docker-bake.hcl b/docker-bake.hcl index 171dad41..bf8a167c 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -287,6 +287,21 @@ variable "IS_RELEASE" {default = "0"} variable "GLOBAL_VERSION" {default = "v5"} variable "ARCH_SUFFIX" {default = ""} +# Registry of the cache of the layers between the runs (e.g. ghcr.io/thecodingmachine/php-cache), none by default. +# The cache is only read, unless CACHE_WRITE=1 +variable "CACHE_REPO" {default = ""} +variable "CACHE_WRITE" {default = "0"} + +function "cache_from" { + params = [NAME] + result = equal("", CACHE_REPO) ? [] : ["type=registry,ref=${CACHE_REPO}:${NAME}${ARCH_SUFFIX}"] +} + +function "cache_to" { + params = [NAME] + result = equal("", CACHE_REPO) || !equal("1", CACHE_WRITE) ? [] : ["type=registry,ref=${CACHE_REPO}:${NAME}${ARCH_SUFFIX},mode=max,image-manifest=true,oci-mediatypes=true,ignore-error=true"] +} + function "tag" { params = [PHP_VERSION, VARIANT] result = [ @@ -311,35 +326,79 @@ target "default" { ########################### ## PHP 8.5 ########################### +# Layers shared by the images of all the variants (not published) +target "php85-base" { + inherits = ["default"] + cache-from = cache_from("php85-base") + cache-to = cache_to("php85-base") + dockerfile = "Dockerfile.base" + output = ["type=cacheonly"] + args = { + PHP_VERSION = "8.5" + } +} + +target "php85-extensions" { + inherits = ["default"] + cache-from = cache_from("php85-extensions") + cache-to = cache_to("php85-extensions") + dockerfile = "Dockerfile.extensions" + output = ["type=cacheonly"] + contexts = { + base = "target:php85-base" + } +} + # thecodingmachine/php:8.5-v5-slim-apache target "php85-slim-apache" { inherits = ["default"] + cache-from = cache_from("php85-slim-apache") + cache-to = cache_to("php85-slim-apache") tags = tag("8.5", "slim-apache") dockerfile = "Dockerfile.slim.apache" args = { - PHP_VERSION = "8.5" VARIANT = "apache" } + contexts = { + base = "target:php85-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php85-slim-apache-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php85-slim-apache-with-extensions") + cache-to = cache_to("php85-slim-apache-with-extensions") + dockerfile = "Dockerfile.slim.apache" + args = { + VARIANT = "apache" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php85-extensions" + } } # thecodingmachine/php:8.5-v5-apache target "php85-apache" { inherits = ["default"] + cache-from = cache_from("php85-apache") + cache-to = cache_to("php85-apache") tags = tag("8.5", "apache") dockerfile = "Dockerfile.apache" args = { - PHP_VERSION = "8.5" VARIANT = "apache" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php85-slim-apache" + slim-with-extensions = "target:php85-slim-apache-with-extensions" } } # thecodingmachine/php:8.5-v5-apache-node26 target "php85-apache-node26" { inherits = ["default"] + cache-from = cache_from("php85-apache-node26") + cache-to = cache_to("php85-apache-node26") tags = tag("8.5", "apache-node26") dockerfile = "Dockerfile.apache.node" args = { @@ -356,6 +415,8 @@ target "php85-apache-node26" { # thecodingmachine/php:8.5-v5-apache-node24 target "php85-apache-node24" { inherits = ["default"] + cache-from = cache_from("php85-apache-node24") + cache-to = cache_to("php85-apache-node24") tags = tag("8.5", "apache-node24") dockerfile = "Dockerfile.apache.node" args = { @@ -372,6 +433,8 @@ target "php85-apache-node24" { # thecodingmachine/php:8.5-v5-apache-node22 target "php85-apache-node22" { inherits = ["default"] + cache-from = cache_from("php85-apache-node22") + cache-to = cache_to("php85-apache-node22") tags = tag("8.5", "apache-node22") dockerfile = "Dockerfile.apache.node" args = { @@ -388,6 +451,8 @@ target "php85-apache-node22" { # thecodingmachine/php:8.5-v5-apache-node20 target "php85-apache-node20" { inherits = ["default"] + cache-from = cache_from("php85-apache-node20") + cache-to = cache_to("php85-apache-node20") tags = tag("8.5", "apache-node20") dockerfile = "Dockerfile.apache.node" args = { @@ -404,6 +469,8 @@ target "php85-apache-node20" { # thecodingmachine/php:8.5-v5-apache-node18 target "php85-apache-node18" { inherits = ["default"] + cache-from = cache_from("php85-apache-node18") + cache-to = cache_to("php85-apache-node18") tags = tag("8.5", "apache-node18") dockerfile = "Dockerfile.apache.node" args = { @@ -417,38 +484,56 @@ target "php85-apache-node18" { } } -########################### -## PHP 8.5 -########################### # thecodingmachine/php:8.5-v5-slim-fpm target "php85-slim-fpm" { inherits = ["default"] + cache-from = cache_from("php85-slim-fpm") + cache-to = cache_to("php85-slim-fpm") tags = tag("8.5", "slim-fpm") dockerfile = "Dockerfile.slim.fpm" args = { - PHP_VERSION = "8.5" VARIANT = "fpm" } + contexts = { + base = "target:php85-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php85-slim-fpm-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php85-slim-fpm-with-extensions") + cache-to = cache_to("php85-slim-fpm-with-extensions") + dockerfile = "Dockerfile.slim.fpm" + args = { + VARIANT = "fpm" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php85-extensions" + } } # thecodingmachine/php:8.5-v5-fpm target "php85-fpm" { inherits = ["default"] + cache-from = cache_from("php85-fpm") + cache-to = cache_to("php85-fpm") tags = tag("8.5", "fpm") dockerfile = "Dockerfile.fpm" args = { - PHP_VERSION = "8.5" VARIANT = "fpm" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php85-slim-fpm" + slim-with-extensions = "target:php85-slim-fpm-with-extensions" } } # thecodingmachine/php:8.5-v5-fpm-node26 target "php85-fpm-node26" { inherits = ["default"] + cache-from = cache_from("php85-fpm-node26") + cache-to = cache_to("php85-fpm-node26") tags = tag("8.5", "fpm-node26") dockerfile = "Dockerfile.fpm.node" args = { @@ -465,6 +550,8 @@ target "php85-fpm-node26" { # thecodingmachine/php:8.5-v5-fpm-node24 target "php85-fpm-node24" { inherits = ["default"] + cache-from = cache_from("php85-fpm-node24") + cache-to = cache_to("php85-fpm-node24") tags = tag("8.5", "fpm-node24") dockerfile = "Dockerfile.fpm.node" args = { @@ -481,6 +568,8 @@ target "php85-fpm-node24" { # thecodingmachine/php:8.5-v5-fpm-node22 target "php85-fpm-node22" { inherits = ["default"] + cache-from = cache_from("php85-fpm-node22") + cache-to = cache_to("php85-fpm-node22") tags = tag("8.5", "fpm-node22") dockerfile = "Dockerfile.fpm.node" args = { @@ -497,6 +586,8 @@ target "php85-fpm-node22" { # thecodingmachine/php:8.5-v5-fpm-node20 target "php85-fpm-node20" { inherits = ["default"] + cache-from = cache_from("php85-fpm-node20") + cache-to = cache_to("php85-fpm-node20") tags = tag("8.5", "fpm-node20") dockerfile = "Dockerfile.fpm.node" args = { @@ -513,6 +604,8 @@ target "php85-fpm-node20" { # thecodingmachine/php:8.5-v5-fpm-node18 target "php85-fpm-node18" { inherits = ["default"] + cache-from = cache_from("php85-fpm-node18") + cache-to = cache_to("php85-fpm-node18") tags = tag("8.5", "fpm-node18") dockerfile = "Dockerfile.fpm.node" args = { @@ -526,38 +619,56 @@ target "php85-fpm-node18" { } } -########################### -## PHP 8.5 -########################### # thecodingmachine/php:8.5-v5-slim-cli target "php85-slim-cli" { inherits = ["default"] + cache-from = cache_from("php85-slim-cli") + cache-to = cache_to("php85-slim-cli") tags = tag("8.5", "slim-cli") dockerfile = "Dockerfile.slim.cli" args = { - PHP_VERSION = "8.5" VARIANT = "cli" } + contexts = { + base = "target:php85-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php85-slim-cli-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php85-slim-cli-with-extensions") + cache-to = cache_to("php85-slim-cli-with-extensions") + dockerfile = "Dockerfile.slim.cli" + args = { + VARIANT = "cli" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php85-extensions" + } } # thecodingmachine/php:8.5-v5-cli target "php85-cli" { inherits = ["default"] + cache-from = cache_from("php85-cli") + cache-to = cache_to("php85-cli") tags = tag("8.5", "cli") dockerfile = "Dockerfile.cli" args = { - PHP_VERSION = "8.5" VARIANT = "cli" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php85-slim-cli" + slim-with-extensions = "target:php85-slim-cli-with-extensions" } } # thecodingmachine/php:8.5-v5-cli-node26 target "php85-cli-node26" { inherits = ["default"] + cache-from = cache_from("php85-cli-node26") + cache-to = cache_to("php85-cli-node26") tags = tag("8.5", "cli-node26") dockerfile = "Dockerfile.cli.node" args = { @@ -574,6 +685,8 @@ target "php85-cli-node26" { # thecodingmachine/php:8.5-v5-cli-node24 target "php85-cli-node24" { inherits = ["default"] + cache-from = cache_from("php85-cli-node24") + cache-to = cache_to("php85-cli-node24") tags = tag("8.5", "cli-node24") dockerfile = "Dockerfile.cli.node" args = { @@ -590,6 +703,8 @@ target "php85-cli-node24" { # thecodingmachine/php:8.5-v5-cli-node22 target "php85-cli-node22" { inherits = ["default"] + cache-from = cache_from("php85-cli-node22") + cache-to = cache_to("php85-cli-node22") tags = tag("8.5", "cli-node22") dockerfile = "Dockerfile.cli.node" args = { @@ -606,6 +721,8 @@ target "php85-cli-node22" { # thecodingmachine/php:8.5-v5-cli-node20 target "php85-cli-node20" { inherits = ["default"] + cache-from = cache_from("php85-cli-node20") + cache-to = cache_to("php85-cli-node20") tags = tag("8.5", "cli-node20") dockerfile = "Dockerfile.cli.node" args = { @@ -622,6 +739,8 @@ target "php85-cli-node20" { # thecodingmachine/php:8.5-v5-cli-node18 target "php85-cli-node18" { inherits = ["default"] + cache-from = cache_from("php85-cli-node18") + cache-to = cache_to("php85-cli-node18") tags = tag("8.5", "cli-node18") dockerfile = "Dockerfile.cli.node" args = { @@ -638,35 +757,79 @@ target "php85-cli-node18" { ########################### ## PHP 8.4 ########################### +# Layers shared by the images of all the variants (not published) +target "php84-base" { + inherits = ["default"] + cache-from = cache_from("php84-base") + cache-to = cache_to("php84-base") + dockerfile = "Dockerfile.base" + output = ["type=cacheonly"] + args = { + PHP_VERSION = "8.4" + } +} + +target "php84-extensions" { + inherits = ["default"] + cache-from = cache_from("php84-extensions") + cache-to = cache_to("php84-extensions") + dockerfile = "Dockerfile.extensions" + output = ["type=cacheonly"] + contexts = { + base = "target:php84-base" + } +} + # thecodingmachine/php:8.4-v5-slim-apache target "php84-slim-apache" { inherits = ["default"] + cache-from = cache_from("php84-slim-apache") + cache-to = cache_to("php84-slim-apache") tags = tag("8.4", "slim-apache") dockerfile = "Dockerfile.slim.apache" args = { - PHP_VERSION = "8.4" VARIANT = "apache" } + contexts = { + base = "target:php84-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php84-slim-apache-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php84-slim-apache-with-extensions") + cache-to = cache_to("php84-slim-apache-with-extensions") + dockerfile = "Dockerfile.slim.apache" + args = { + VARIANT = "apache" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php84-extensions" + } } # thecodingmachine/php:8.4-v5-apache target "php84-apache" { inherits = ["default"] + cache-from = cache_from("php84-apache") + cache-to = cache_to("php84-apache") tags = tag("8.4", "apache") dockerfile = "Dockerfile.apache" args = { - PHP_VERSION = "8.4" VARIANT = "apache" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php84-slim-apache" + slim-with-extensions = "target:php84-slim-apache-with-extensions" } } # thecodingmachine/php:8.4-v5-apache-node26 target "php84-apache-node26" { inherits = ["default"] + cache-from = cache_from("php84-apache-node26") + cache-to = cache_to("php84-apache-node26") tags = tag("8.4", "apache-node26") dockerfile = "Dockerfile.apache.node" args = { @@ -683,6 +846,8 @@ target "php84-apache-node26" { # thecodingmachine/php:8.4-v5-apache-node24 target "php84-apache-node24" { inherits = ["default"] + cache-from = cache_from("php84-apache-node24") + cache-to = cache_to("php84-apache-node24") tags = tag("8.4", "apache-node24") dockerfile = "Dockerfile.apache.node" args = { @@ -699,6 +864,8 @@ target "php84-apache-node24" { # thecodingmachine/php:8.4-v5-apache-node22 target "php84-apache-node22" { inherits = ["default"] + cache-from = cache_from("php84-apache-node22") + cache-to = cache_to("php84-apache-node22") tags = tag("8.4", "apache-node22") dockerfile = "Dockerfile.apache.node" args = { @@ -715,6 +882,8 @@ target "php84-apache-node22" { # thecodingmachine/php:8.4-v5-apache-node20 target "php84-apache-node20" { inherits = ["default"] + cache-from = cache_from("php84-apache-node20") + cache-to = cache_to("php84-apache-node20") tags = tag("8.4", "apache-node20") dockerfile = "Dockerfile.apache.node" args = { @@ -731,6 +900,8 @@ target "php84-apache-node20" { # thecodingmachine/php:8.4-v5-apache-node18 target "php84-apache-node18" { inherits = ["default"] + cache-from = cache_from("php84-apache-node18") + cache-to = cache_to("php84-apache-node18") tags = tag("8.4", "apache-node18") dockerfile = "Dockerfile.apache.node" args = { @@ -744,38 +915,56 @@ target "php84-apache-node18" { } } -########################### -## PHP 8.4 -########################### # thecodingmachine/php:8.4-v5-slim-fpm target "php84-slim-fpm" { inherits = ["default"] + cache-from = cache_from("php84-slim-fpm") + cache-to = cache_to("php84-slim-fpm") tags = tag("8.4", "slim-fpm") dockerfile = "Dockerfile.slim.fpm" args = { - PHP_VERSION = "8.4" VARIANT = "fpm" } + contexts = { + base = "target:php84-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php84-slim-fpm-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php84-slim-fpm-with-extensions") + cache-to = cache_to("php84-slim-fpm-with-extensions") + dockerfile = "Dockerfile.slim.fpm" + args = { + VARIANT = "fpm" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php84-extensions" + } } # thecodingmachine/php:8.4-v5-fpm target "php84-fpm" { inherits = ["default"] + cache-from = cache_from("php84-fpm") + cache-to = cache_to("php84-fpm") tags = tag("8.4", "fpm") dockerfile = "Dockerfile.fpm" args = { - PHP_VERSION = "8.4" VARIANT = "fpm" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php84-slim-fpm" + slim-with-extensions = "target:php84-slim-fpm-with-extensions" } } # thecodingmachine/php:8.4-v5-fpm-node26 target "php84-fpm-node26" { inherits = ["default"] + cache-from = cache_from("php84-fpm-node26") + cache-to = cache_to("php84-fpm-node26") tags = tag("8.4", "fpm-node26") dockerfile = "Dockerfile.fpm.node" args = { @@ -792,6 +981,8 @@ target "php84-fpm-node26" { # thecodingmachine/php:8.4-v5-fpm-node24 target "php84-fpm-node24" { inherits = ["default"] + cache-from = cache_from("php84-fpm-node24") + cache-to = cache_to("php84-fpm-node24") tags = tag("8.4", "fpm-node24") dockerfile = "Dockerfile.fpm.node" args = { @@ -808,6 +999,8 @@ target "php84-fpm-node24" { # thecodingmachine/php:8.4-v5-fpm-node22 target "php84-fpm-node22" { inherits = ["default"] + cache-from = cache_from("php84-fpm-node22") + cache-to = cache_to("php84-fpm-node22") tags = tag("8.4", "fpm-node22") dockerfile = "Dockerfile.fpm.node" args = { @@ -824,6 +1017,8 @@ target "php84-fpm-node22" { # thecodingmachine/php:8.4-v5-fpm-node20 target "php84-fpm-node20" { inherits = ["default"] + cache-from = cache_from("php84-fpm-node20") + cache-to = cache_to("php84-fpm-node20") tags = tag("8.4", "fpm-node20") dockerfile = "Dockerfile.fpm.node" args = { @@ -840,6 +1035,8 @@ target "php84-fpm-node20" { # thecodingmachine/php:8.4-v5-fpm-node18 target "php84-fpm-node18" { inherits = ["default"] + cache-from = cache_from("php84-fpm-node18") + cache-to = cache_to("php84-fpm-node18") tags = tag("8.4", "fpm-node18") dockerfile = "Dockerfile.fpm.node" args = { @@ -853,38 +1050,56 @@ target "php84-fpm-node18" { } } -########################### -## PHP 8.4 -########################### # thecodingmachine/php:8.4-v5-slim-cli target "php84-slim-cli" { inherits = ["default"] + cache-from = cache_from("php84-slim-cli") + cache-to = cache_to("php84-slim-cli") tags = tag("8.4", "slim-cli") dockerfile = "Dockerfile.slim.cli" args = { - PHP_VERSION = "8.4" VARIANT = "cli" } + contexts = { + base = "target:php84-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php84-slim-cli-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php84-slim-cli-with-extensions") + cache-to = cache_to("php84-slim-cli-with-extensions") + dockerfile = "Dockerfile.slim.cli" + args = { + VARIANT = "cli" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php84-extensions" + } } # thecodingmachine/php:8.4-v5-cli target "php84-cli" { inherits = ["default"] + cache-from = cache_from("php84-cli") + cache-to = cache_to("php84-cli") tags = tag("8.4", "cli") dockerfile = "Dockerfile.cli" args = { - PHP_VERSION = "8.4" VARIANT = "cli" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php84-slim-cli" + slim-with-extensions = "target:php84-slim-cli-with-extensions" } } # thecodingmachine/php:8.4-v5-cli-node26 target "php84-cli-node26" { inherits = ["default"] + cache-from = cache_from("php84-cli-node26") + cache-to = cache_to("php84-cli-node26") tags = tag("8.4", "cli-node26") dockerfile = "Dockerfile.cli.node" args = { @@ -901,6 +1116,8 @@ target "php84-cli-node26" { # thecodingmachine/php:8.4-v5-cli-node24 target "php84-cli-node24" { inherits = ["default"] + cache-from = cache_from("php84-cli-node24") + cache-to = cache_to("php84-cli-node24") tags = tag("8.4", "cli-node24") dockerfile = "Dockerfile.cli.node" args = { @@ -917,6 +1134,8 @@ target "php84-cli-node24" { # thecodingmachine/php:8.4-v5-cli-node22 target "php84-cli-node22" { inherits = ["default"] + cache-from = cache_from("php84-cli-node22") + cache-to = cache_to("php84-cli-node22") tags = tag("8.4", "cli-node22") dockerfile = "Dockerfile.cli.node" args = { @@ -933,6 +1152,8 @@ target "php84-cli-node22" { # thecodingmachine/php:8.4-v5-cli-node20 target "php84-cli-node20" { inherits = ["default"] + cache-from = cache_from("php84-cli-node20") + cache-to = cache_to("php84-cli-node20") tags = tag("8.4", "cli-node20") dockerfile = "Dockerfile.cli.node" args = { @@ -949,6 +1170,8 @@ target "php84-cli-node20" { # thecodingmachine/php:8.4-v5-cli-node18 target "php84-cli-node18" { inherits = ["default"] + cache-from = cache_from("php84-cli-node18") + cache-to = cache_to("php84-cli-node18") tags = tag("8.4", "cli-node18") dockerfile = "Dockerfile.cli.node" args = { @@ -965,35 +1188,79 @@ target "php84-cli-node18" { ########################### ## PHP 8.3 ########################### +# Layers shared by the images of all the variants (not published) +target "php83-base" { + inherits = ["default"] + cache-from = cache_from("php83-base") + cache-to = cache_to("php83-base") + dockerfile = "Dockerfile.base" + output = ["type=cacheonly"] + args = { + PHP_VERSION = "8.3" + } +} + +target "php83-extensions" { + inherits = ["default"] + cache-from = cache_from("php83-extensions") + cache-to = cache_to("php83-extensions") + dockerfile = "Dockerfile.extensions" + output = ["type=cacheonly"] + contexts = { + base = "target:php83-base" + } +} + # thecodingmachine/php:8.3-v5-slim-apache target "php83-slim-apache" { inherits = ["default"] + cache-from = cache_from("php83-slim-apache") + cache-to = cache_to("php83-slim-apache") tags = tag("8.3", "slim-apache") dockerfile = "Dockerfile.slim.apache" args = { - PHP_VERSION = "8.3" VARIANT = "apache" } + contexts = { + base = "target:php83-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php83-slim-apache-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php83-slim-apache-with-extensions") + cache-to = cache_to("php83-slim-apache-with-extensions") + dockerfile = "Dockerfile.slim.apache" + args = { + VARIANT = "apache" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php83-extensions" + } } # thecodingmachine/php:8.3-v5-apache target "php83-apache" { inherits = ["default"] + cache-from = cache_from("php83-apache") + cache-to = cache_to("php83-apache") tags = tag("8.3", "apache") dockerfile = "Dockerfile.apache" args = { - PHP_VERSION = "8.3" VARIANT = "apache" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php83-slim-apache" + slim-with-extensions = "target:php83-slim-apache-with-extensions" } } # thecodingmachine/php:8.3-v5-apache-node26 target "php83-apache-node26" { inherits = ["default"] + cache-from = cache_from("php83-apache-node26") + cache-to = cache_to("php83-apache-node26") tags = tag("8.3", "apache-node26") dockerfile = "Dockerfile.apache.node" args = { @@ -1010,6 +1277,8 @@ target "php83-apache-node26" { # thecodingmachine/php:8.3-v5-apache-node24 target "php83-apache-node24" { inherits = ["default"] + cache-from = cache_from("php83-apache-node24") + cache-to = cache_to("php83-apache-node24") tags = tag("8.3", "apache-node24") dockerfile = "Dockerfile.apache.node" args = { @@ -1026,6 +1295,8 @@ target "php83-apache-node24" { # thecodingmachine/php:8.3-v5-apache-node22 target "php83-apache-node22" { inherits = ["default"] + cache-from = cache_from("php83-apache-node22") + cache-to = cache_to("php83-apache-node22") tags = tag("8.3", "apache-node22") dockerfile = "Dockerfile.apache.node" args = { @@ -1042,6 +1313,8 @@ target "php83-apache-node22" { # thecodingmachine/php:8.3-v5-apache-node20 target "php83-apache-node20" { inherits = ["default"] + cache-from = cache_from("php83-apache-node20") + cache-to = cache_to("php83-apache-node20") tags = tag("8.3", "apache-node20") dockerfile = "Dockerfile.apache.node" args = { @@ -1058,6 +1331,8 @@ target "php83-apache-node20" { # thecodingmachine/php:8.3-v5-apache-node18 target "php83-apache-node18" { inherits = ["default"] + cache-from = cache_from("php83-apache-node18") + cache-to = cache_to("php83-apache-node18") tags = tag("8.3", "apache-node18") dockerfile = "Dockerfile.apache.node" args = { @@ -1071,38 +1346,56 @@ target "php83-apache-node18" { } } -########################### -## PHP 8.3 -########################### # thecodingmachine/php:8.3-v5-slim-fpm target "php83-slim-fpm" { inherits = ["default"] + cache-from = cache_from("php83-slim-fpm") + cache-to = cache_to("php83-slim-fpm") tags = tag("8.3", "slim-fpm") dockerfile = "Dockerfile.slim.fpm" args = { - PHP_VERSION = "8.3" VARIANT = "fpm" } + contexts = { + base = "target:php83-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php83-slim-fpm-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php83-slim-fpm-with-extensions") + cache-to = cache_to("php83-slim-fpm-with-extensions") + dockerfile = "Dockerfile.slim.fpm" + args = { + VARIANT = "fpm" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php83-extensions" + } } # thecodingmachine/php:8.3-v5-fpm target "php83-fpm" { inherits = ["default"] + cache-from = cache_from("php83-fpm") + cache-to = cache_to("php83-fpm") tags = tag("8.3", "fpm") dockerfile = "Dockerfile.fpm" args = { - PHP_VERSION = "8.3" VARIANT = "fpm" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php83-slim-fpm" + slim-with-extensions = "target:php83-slim-fpm-with-extensions" } } # thecodingmachine/php:8.3-v5-fpm-node26 target "php83-fpm-node26" { inherits = ["default"] + cache-from = cache_from("php83-fpm-node26") + cache-to = cache_to("php83-fpm-node26") tags = tag("8.3", "fpm-node26") dockerfile = "Dockerfile.fpm.node" args = { @@ -1119,6 +1412,8 @@ target "php83-fpm-node26" { # thecodingmachine/php:8.3-v5-fpm-node24 target "php83-fpm-node24" { inherits = ["default"] + cache-from = cache_from("php83-fpm-node24") + cache-to = cache_to("php83-fpm-node24") tags = tag("8.3", "fpm-node24") dockerfile = "Dockerfile.fpm.node" args = { @@ -1135,6 +1430,8 @@ target "php83-fpm-node24" { # thecodingmachine/php:8.3-v5-fpm-node22 target "php83-fpm-node22" { inherits = ["default"] + cache-from = cache_from("php83-fpm-node22") + cache-to = cache_to("php83-fpm-node22") tags = tag("8.3", "fpm-node22") dockerfile = "Dockerfile.fpm.node" args = { @@ -1151,6 +1448,8 @@ target "php83-fpm-node22" { # thecodingmachine/php:8.3-v5-fpm-node20 target "php83-fpm-node20" { inherits = ["default"] + cache-from = cache_from("php83-fpm-node20") + cache-to = cache_to("php83-fpm-node20") tags = tag("8.3", "fpm-node20") dockerfile = "Dockerfile.fpm.node" args = { @@ -1167,6 +1466,8 @@ target "php83-fpm-node20" { # thecodingmachine/php:8.3-v5-fpm-node18 target "php83-fpm-node18" { inherits = ["default"] + cache-from = cache_from("php83-fpm-node18") + cache-to = cache_to("php83-fpm-node18") tags = tag("8.3", "fpm-node18") dockerfile = "Dockerfile.fpm.node" args = { @@ -1180,38 +1481,56 @@ target "php83-fpm-node18" { } } -########################### -## PHP 8.3 -########################### # thecodingmachine/php:8.3-v5-slim-cli target "php83-slim-cli" { inherits = ["default"] + cache-from = cache_from("php83-slim-cli") + cache-to = cache_to("php83-slim-cli") tags = tag("8.3", "slim-cli") dockerfile = "Dockerfile.slim.cli" args = { - PHP_VERSION = "8.3" VARIANT = "cli" } + contexts = { + base = "target:php83-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php83-slim-cli-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php83-slim-cli-with-extensions") + cache-to = cache_to("php83-slim-cli-with-extensions") + dockerfile = "Dockerfile.slim.cli" + args = { + VARIANT = "cli" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php83-extensions" + } } # thecodingmachine/php:8.3-v5-cli target "php83-cli" { inherits = ["default"] + cache-from = cache_from("php83-cli") + cache-to = cache_to("php83-cli") tags = tag("8.3", "cli") dockerfile = "Dockerfile.cli" args = { - PHP_VERSION = "8.3" VARIANT = "cli" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php83-slim-cli" + slim-with-extensions = "target:php83-slim-cli-with-extensions" } } # thecodingmachine/php:8.3-v5-cli-node26 target "php83-cli-node26" { inherits = ["default"] + cache-from = cache_from("php83-cli-node26") + cache-to = cache_to("php83-cli-node26") tags = tag("8.3", "cli-node26") dockerfile = "Dockerfile.cli.node" args = { @@ -1228,6 +1547,8 @@ target "php83-cli-node26" { # thecodingmachine/php:8.3-v5-cli-node24 target "php83-cli-node24" { inherits = ["default"] + cache-from = cache_from("php83-cli-node24") + cache-to = cache_to("php83-cli-node24") tags = tag("8.3", "cli-node24") dockerfile = "Dockerfile.cli.node" args = { @@ -1244,6 +1565,8 @@ target "php83-cli-node24" { # thecodingmachine/php:8.3-v5-cli-node22 target "php83-cli-node22" { inherits = ["default"] + cache-from = cache_from("php83-cli-node22") + cache-to = cache_to("php83-cli-node22") tags = tag("8.3", "cli-node22") dockerfile = "Dockerfile.cli.node" args = { @@ -1260,6 +1583,8 @@ target "php83-cli-node22" { # thecodingmachine/php:8.3-v5-cli-node20 target "php83-cli-node20" { inherits = ["default"] + cache-from = cache_from("php83-cli-node20") + cache-to = cache_to("php83-cli-node20") tags = tag("8.3", "cli-node20") dockerfile = "Dockerfile.cli.node" args = { @@ -1276,6 +1601,8 @@ target "php83-cli-node20" { # thecodingmachine/php:8.3-v5-cli-node18 target "php83-cli-node18" { inherits = ["default"] + cache-from = cache_from("php83-cli-node18") + cache-to = cache_to("php83-cli-node18") tags = tag("8.3", "cli-node18") dockerfile = "Dockerfile.cli.node" args = { @@ -1292,35 +1619,79 @@ target "php83-cli-node18" { ########################### ## PHP 8.2 ########################### +# Layers shared by the images of all the variants (not published) +target "php82-base" { + inherits = ["default"] + cache-from = cache_from("php82-base") + cache-to = cache_to("php82-base") + dockerfile = "Dockerfile.base" + output = ["type=cacheonly"] + args = { + PHP_VERSION = "8.2" + } +} + +target "php82-extensions" { + inherits = ["default"] + cache-from = cache_from("php82-extensions") + cache-to = cache_to("php82-extensions") + dockerfile = "Dockerfile.extensions" + output = ["type=cacheonly"] + contexts = { + base = "target:php82-base" + } +} + # thecodingmachine/php:8.2-v5-slim-apache target "php82-slim-apache" { inherits = ["default"] + cache-from = cache_from("php82-slim-apache") + cache-to = cache_to("php82-slim-apache") tags = tag("8.2", "slim-apache") dockerfile = "Dockerfile.slim.apache" args = { - PHP_VERSION = "8.2" VARIANT = "apache" } + contexts = { + base = "target:php82-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php82-slim-apache-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php82-slim-apache-with-extensions") + cache-to = cache_to("php82-slim-apache-with-extensions") + dockerfile = "Dockerfile.slim.apache" + args = { + VARIANT = "apache" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php82-extensions" + } } # thecodingmachine/php:8.2-v5-apache target "php82-apache" { inherits = ["default"] + cache-from = cache_from("php82-apache") + cache-to = cache_to("php82-apache") tags = tag("8.2", "apache") dockerfile = "Dockerfile.apache" args = { - PHP_VERSION = "8.2" VARIANT = "apache" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php82-slim-apache" + slim-with-extensions = "target:php82-slim-apache-with-extensions" } } # thecodingmachine/php:8.2-v5-apache-node26 target "php82-apache-node26" { inherits = ["default"] + cache-from = cache_from("php82-apache-node26") + cache-to = cache_to("php82-apache-node26") tags = tag("8.2", "apache-node26") dockerfile = "Dockerfile.apache.node" args = { @@ -1337,6 +1708,8 @@ target "php82-apache-node26" { # thecodingmachine/php:8.2-v5-apache-node24 target "php82-apache-node24" { inherits = ["default"] + cache-from = cache_from("php82-apache-node24") + cache-to = cache_to("php82-apache-node24") tags = tag("8.2", "apache-node24") dockerfile = "Dockerfile.apache.node" args = { @@ -1353,6 +1726,8 @@ target "php82-apache-node24" { # thecodingmachine/php:8.2-v5-apache-node22 target "php82-apache-node22" { inherits = ["default"] + cache-from = cache_from("php82-apache-node22") + cache-to = cache_to("php82-apache-node22") tags = tag("8.2", "apache-node22") dockerfile = "Dockerfile.apache.node" args = { @@ -1369,6 +1744,8 @@ target "php82-apache-node22" { # thecodingmachine/php:8.2-v5-apache-node20 target "php82-apache-node20" { inherits = ["default"] + cache-from = cache_from("php82-apache-node20") + cache-to = cache_to("php82-apache-node20") tags = tag("8.2", "apache-node20") dockerfile = "Dockerfile.apache.node" args = { @@ -1385,6 +1762,8 @@ target "php82-apache-node20" { # thecodingmachine/php:8.2-v5-apache-node18 target "php82-apache-node18" { inherits = ["default"] + cache-from = cache_from("php82-apache-node18") + cache-to = cache_to("php82-apache-node18") tags = tag("8.2", "apache-node18") dockerfile = "Dockerfile.apache.node" args = { @@ -1398,38 +1777,56 @@ target "php82-apache-node18" { } } -########################### -## PHP 8.2 -########################### # thecodingmachine/php:8.2-v5-slim-fpm target "php82-slim-fpm" { inherits = ["default"] + cache-from = cache_from("php82-slim-fpm") + cache-to = cache_to("php82-slim-fpm") tags = tag("8.2", "slim-fpm") dockerfile = "Dockerfile.slim.fpm" args = { - PHP_VERSION = "8.2" VARIANT = "fpm" } + contexts = { + base = "target:php82-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php82-slim-fpm-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php82-slim-fpm-with-extensions") + cache-to = cache_to("php82-slim-fpm-with-extensions") + dockerfile = "Dockerfile.slim.fpm" + args = { + VARIANT = "fpm" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php82-extensions" + } } # thecodingmachine/php:8.2-v5-fpm target "php82-fpm" { inherits = ["default"] + cache-from = cache_from("php82-fpm") + cache-to = cache_to("php82-fpm") tags = tag("8.2", "fpm") dockerfile = "Dockerfile.fpm" args = { - PHP_VERSION = "8.2" VARIANT = "fpm" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php82-slim-fpm" + slim-with-extensions = "target:php82-slim-fpm-with-extensions" } } # thecodingmachine/php:8.2-v5-fpm-node26 target "php82-fpm-node26" { inherits = ["default"] + cache-from = cache_from("php82-fpm-node26") + cache-to = cache_to("php82-fpm-node26") tags = tag("8.2", "fpm-node26") dockerfile = "Dockerfile.fpm.node" args = { @@ -1446,6 +1843,8 @@ target "php82-fpm-node26" { # thecodingmachine/php:8.2-v5-fpm-node24 target "php82-fpm-node24" { inherits = ["default"] + cache-from = cache_from("php82-fpm-node24") + cache-to = cache_to("php82-fpm-node24") tags = tag("8.2", "fpm-node24") dockerfile = "Dockerfile.fpm.node" args = { @@ -1462,6 +1861,8 @@ target "php82-fpm-node24" { # thecodingmachine/php:8.2-v5-fpm-node22 target "php82-fpm-node22" { inherits = ["default"] + cache-from = cache_from("php82-fpm-node22") + cache-to = cache_to("php82-fpm-node22") tags = tag("8.2", "fpm-node22") dockerfile = "Dockerfile.fpm.node" args = { @@ -1478,6 +1879,8 @@ target "php82-fpm-node22" { # thecodingmachine/php:8.2-v5-fpm-node20 target "php82-fpm-node20" { inherits = ["default"] + cache-from = cache_from("php82-fpm-node20") + cache-to = cache_to("php82-fpm-node20") tags = tag("8.2", "fpm-node20") dockerfile = "Dockerfile.fpm.node" args = { @@ -1494,6 +1897,8 @@ target "php82-fpm-node20" { # thecodingmachine/php:8.2-v5-fpm-node18 target "php82-fpm-node18" { inherits = ["default"] + cache-from = cache_from("php82-fpm-node18") + cache-to = cache_to("php82-fpm-node18") tags = tag("8.2", "fpm-node18") dockerfile = "Dockerfile.fpm.node" args = { @@ -1507,38 +1912,56 @@ target "php82-fpm-node18" { } } -########################### -## PHP 8.2 -########################### # thecodingmachine/php:8.2-v5-slim-cli target "php82-slim-cli" { inherits = ["default"] + cache-from = cache_from("php82-slim-cli") + cache-to = cache_to("php82-slim-cli") tags = tag("8.2", "slim-cli") dockerfile = "Dockerfile.slim.cli" args = { - PHP_VERSION = "8.2" VARIANT = "cli" } + contexts = { + base = "target:php82-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php82-slim-cli-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php82-slim-cli-with-extensions") + cache-to = cache_to("php82-slim-cli-with-extensions") + dockerfile = "Dockerfile.slim.cli" + args = { + VARIANT = "cli" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php82-extensions" + } } # thecodingmachine/php:8.2-v5-cli target "php82-cli" { inherits = ["default"] + cache-from = cache_from("php82-cli") + cache-to = cache_to("php82-cli") tags = tag("8.2", "cli") dockerfile = "Dockerfile.cli" args = { - PHP_VERSION = "8.2" VARIANT = "cli" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php82-slim-cli" + slim-with-extensions = "target:php82-slim-cli-with-extensions" } } # thecodingmachine/php:8.2-v5-cli-node26 target "php82-cli-node26" { inherits = ["default"] + cache-from = cache_from("php82-cli-node26") + cache-to = cache_to("php82-cli-node26") tags = tag("8.2", "cli-node26") dockerfile = "Dockerfile.cli.node" args = { @@ -1555,6 +1978,8 @@ target "php82-cli-node26" { # thecodingmachine/php:8.2-v5-cli-node24 target "php82-cli-node24" { inherits = ["default"] + cache-from = cache_from("php82-cli-node24") + cache-to = cache_to("php82-cli-node24") tags = tag("8.2", "cli-node24") dockerfile = "Dockerfile.cli.node" args = { @@ -1571,6 +1996,8 @@ target "php82-cli-node24" { # thecodingmachine/php:8.2-v5-cli-node22 target "php82-cli-node22" { inherits = ["default"] + cache-from = cache_from("php82-cli-node22") + cache-to = cache_to("php82-cli-node22") tags = tag("8.2", "cli-node22") dockerfile = "Dockerfile.cli.node" args = { @@ -1587,6 +2014,8 @@ target "php82-cli-node22" { # thecodingmachine/php:8.2-v5-cli-node20 target "php82-cli-node20" { inherits = ["default"] + cache-from = cache_from("php82-cli-node20") + cache-to = cache_to("php82-cli-node20") tags = tag("8.2", "cli-node20") dockerfile = "Dockerfile.cli.node" args = { @@ -1603,6 +2032,8 @@ target "php82-cli-node20" { # thecodingmachine/php:8.2-v5-cli-node18 target "php82-cli-node18" { inherits = ["default"] + cache-from = cache_from("php82-cli-node18") + cache-to = cache_to("php82-cli-node18") tags = tag("8.2", "cli-node18") dockerfile = "Dockerfile.cli.node" args = { @@ -1619,35 +2050,79 @@ target "php82-cli-node18" { ########################### ## PHP 8.1 ########################### +# Layers shared by the images of all the variants (not published) +target "php81-base" { + inherits = ["default"] + cache-from = cache_from("php81-base") + cache-to = cache_to("php81-base") + dockerfile = "Dockerfile.base" + output = ["type=cacheonly"] + args = { + PHP_VERSION = "8.1" + } +} + +target "php81-extensions" { + inherits = ["default"] + cache-from = cache_from("php81-extensions") + cache-to = cache_to("php81-extensions") + dockerfile = "Dockerfile.extensions" + output = ["type=cacheonly"] + contexts = { + base = "target:php81-base" + } +} + # thecodingmachine/php:8.1-v5-slim-apache target "php81-slim-apache" { inherits = ["default"] + cache-from = cache_from("php81-slim-apache") + cache-to = cache_to("php81-slim-apache") tags = tag("8.1", "slim-apache") dockerfile = "Dockerfile.slim.apache" args = { - PHP_VERSION = "8.1" VARIANT = "apache" } + contexts = { + base = "target:php81-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php81-slim-apache-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php81-slim-apache-with-extensions") + cache-to = cache_to("php81-slim-apache-with-extensions") + dockerfile = "Dockerfile.slim.apache" + args = { + VARIANT = "apache" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php81-extensions" + } } # thecodingmachine/php:8.1-v5-apache target "php81-apache" { inherits = ["default"] + cache-from = cache_from("php81-apache") + cache-to = cache_to("php81-apache") tags = tag("8.1", "apache") dockerfile = "Dockerfile.apache" args = { - PHP_VERSION = "8.1" VARIANT = "apache" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php81-slim-apache" + slim-with-extensions = "target:php81-slim-apache-with-extensions" } } # thecodingmachine/php:8.1-v5-apache-node26 target "php81-apache-node26" { inherits = ["default"] + cache-from = cache_from("php81-apache-node26") + cache-to = cache_to("php81-apache-node26") tags = tag("8.1", "apache-node26") dockerfile = "Dockerfile.apache.node" args = { @@ -1664,6 +2139,8 @@ target "php81-apache-node26" { # thecodingmachine/php:8.1-v5-apache-node24 target "php81-apache-node24" { inherits = ["default"] + cache-from = cache_from("php81-apache-node24") + cache-to = cache_to("php81-apache-node24") tags = tag("8.1", "apache-node24") dockerfile = "Dockerfile.apache.node" args = { @@ -1680,6 +2157,8 @@ target "php81-apache-node24" { # thecodingmachine/php:8.1-v5-apache-node22 target "php81-apache-node22" { inherits = ["default"] + cache-from = cache_from("php81-apache-node22") + cache-to = cache_to("php81-apache-node22") tags = tag("8.1", "apache-node22") dockerfile = "Dockerfile.apache.node" args = { @@ -1696,6 +2175,8 @@ target "php81-apache-node22" { # thecodingmachine/php:8.1-v5-apache-node20 target "php81-apache-node20" { inherits = ["default"] + cache-from = cache_from("php81-apache-node20") + cache-to = cache_to("php81-apache-node20") tags = tag("8.1", "apache-node20") dockerfile = "Dockerfile.apache.node" args = { @@ -1712,6 +2193,8 @@ target "php81-apache-node20" { # thecodingmachine/php:8.1-v5-apache-node18 target "php81-apache-node18" { inherits = ["default"] + cache-from = cache_from("php81-apache-node18") + cache-to = cache_to("php81-apache-node18") tags = tag("8.1", "apache-node18") dockerfile = "Dockerfile.apache.node" args = { @@ -1725,38 +2208,56 @@ target "php81-apache-node18" { } } -########################### -## PHP 8.1 -########################### # thecodingmachine/php:8.1-v5-slim-fpm target "php81-slim-fpm" { inherits = ["default"] + cache-from = cache_from("php81-slim-fpm") + cache-to = cache_to("php81-slim-fpm") tags = tag("8.1", "slim-fpm") dockerfile = "Dockerfile.slim.fpm" args = { - PHP_VERSION = "8.1" VARIANT = "fpm" } + contexts = { + base = "target:php81-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php81-slim-fpm-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php81-slim-fpm-with-extensions") + cache-to = cache_to("php81-slim-fpm-with-extensions") + dockerfile = "Dockerfile.slim.fpm" + args = { + VARIANT = "fpm" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php81-extensions" + } } # thecodingmachine/php:8.1-v5-fpm target "php81-fpm" { inherits = ["default"] + cache-from = cache_from("php81-fpm") + cache-to = cache_to("php81-fpm") tags = tag("8.1", "fpm") dockerfile = "Dockerfile.fpm" args = { - PHP_VERSION = "8.1" VARIANT = "fpm" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php81-slim-fpm" + slim-with-extensions = "target:php81-slim-fpm-with-extensions" } } # thecodingmachine/php:8.1-v5-fpm-node26 target "php81-fpm-node26" { inherits = ["default"] + cache-from = cache_from("php81-fpm-node26") + cache-to = cache_to("php81-fpm-node26") tags = tag("8.1", "fpm-node26") dockerfile = "Dockerfile.fpm.node" args = { @@ -1773,6 +2274,8 @@ target "php81-fpm-node26" { # thecodingmachine/php:8.1-v5-fpm-node24 target "php81-fpm-node24" { inherits = ["default"] + cache-from = cache_from("php81-fpm-node24") + cache-to = cache_to("php81-fpm-node24") tags = tag("8.1", "fpm-node24") dockerfile = "Dockerfile.fpm.node" args = { @@ -1789,6 +2292,8 @@ target "php81-fpm-node24" { # thecodingmachine/php:8.1-v5-fpm-node22 target "php81-fpm-node22" { inherits = ["default"] + cache-from = cache_from("php81-fpm-node22") + cache-to = cache_to("php81-fpm-node22") tags = tag("8.1", "fpm-node22") dockerfile = "Dockerfile.fpm.node" args = { @@ -1805,6 +2310,8 @@ target "php81-fpm-node22" { # thecodingmachine/php:8.1-v5-fpm-node20 target "php81-fpm-node20" { inherits = ["default"] + cache-from = cache_from("php81-fpm-node20") + cache-to = cache_to("php81-fpm-node20") tags = tag("8.1", "fpm-node20") dockerfile = "Dockerfile.fpm.node" args = { @@ -1821,6 +2328,8 @@ target "php81-fpm-node20" { # thecodingmachine/php:8.1-v5-fpm-node18 target "php81-fpm-node18" { inherits = ["default"] + cache-from = cache_from("php81-fpm-node18") + cache-to = cache_to("php81-fpm-node18") tags = tag("8.1", "fpm-node18") dockerfile = "Dockerfile.fpm.node" args = { @@ -1834,38 +2343,56 @@ target "php81-fpm-node18" { } } -########################### -## PHP 8.1 -########################### # thecodingmachine/php:8.1-v5-slim-cli target "php81-slim-cli" { inherits = ["default"] + cache-from = cache_from("php81-slim-cli") + cache-to = cache_to("php81-slim-cli") tags = tag("8.1", "slim-cli") dockerfile = "Dockerfile.slim.cli" args = { - PHP_VERSION = "8.1" VARIANT = "cli" } + contexts = { + base = "target:php81-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php81-slim-cli-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php81-slim-cli-with-extensions") + cache-to = cache_to("php81-slim-cli-with-extensions") + dockerfile = "Dockerfile.slim.cli" + args = { + VARIANT = "cli" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php81-extensions" + } } # thecodingmachine/php:8.1-v5-cli target "php81-cli" { inherits = ["default"] + cache-from = cache_from("php81-cli") + cache-to = cache_to("php81-cli") tags = tag("8.1", "cli") dockerfile = "Dockerfile.cli" args = { - PHP_VERSION = "8.1" VARIANT = "cli" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php81-slim-cli" + slim-with-extensions = "target:php81-slim-cli-with-extensions" } } # thecodingmachine/php:8.1-v5-cli-node26 target "php81-cli-node26" { inherits = ["default"] + cache-from = cache_from("php81-cli-node26") + cache-to = cache_to("php81-cli-node26") tags = tag("8.1", "cli-node26") dockerfile = "Dockerfile.cli.node" args = { @@ -1882,6 +2409,8 @@ target "php81-cli-node26" { # thecodingmachine/php:8.1-v5-cli-node24 target "php81-cli-node24" { inherits = ["default"] + cache-from = cache_from("php81-cli-node24") + cache-to = cache_to("php81-cli-node24") tags = tag("8.1", "cli-node24") dockerfile = "Dockerfile.cli.node" args = { @@ -1898,6 +2427,8 @@ target "php81-cli-node24" { # thecodingmachine/php:8.1-v5-cli-node22 target "php81-cli-node22" { inherits = ["default"] + cache-from = cache_from("php81-cli-node22") + cache-to = cache_to("php81-cli-node22") tags = tag("8.1", "cli-node22") dockerfile = "Dockerfile.cli.node" args = { @@ -1914,6 +2445,8 @@ target "php81-cli-node22" { # thecodingmachine/php:8.1-v5-cli-node20 target "php81-cli-node20" { inherits = ["default"] + cache-from = cache_from("php81-cli-node20") + cache-to = cache_to("php81-cli-node20") tags = tag("8.1", "cli-node20") dockerfile = "Dockerfile.cli.node" args = { @@ -1930,6 +2463,8 @@ target "php81-cli-node20" { # thecodingmachine/php:8.1-v5-cli-node18 target "php81-cli-node18" { inherits = ["default"] + cache-from = cache_from("php81-cli-node18") + cache-to = cache_to("php81-cli-node18") tags = tag("8.1", "cli-node18") dockerfile = "Dockerfile.cli.node" args = { @@ -1946,35 +2481,79 @@ target "php81-cli-node18" { ########################### ## PHP 8.0 ########################### +# Layers shared by the images of all the variants (not published) +target "php80-base" { + inherits = ["default"] + cache-from = cache_from("php80-base") + cache-to = cache_to("php80-base") + dockerfile = "Dockerfile.base" + output = ["type=cacheonly"] + args = { + PHP_VERSION = "8.0" + } +} + +target "php80-extensions" { + inherits = ["default"] + cache-from = cache_from("php80-extensions") + cache-to = cache_to("php80-extensions") + dockerfile = "Dockerfile.extensions" + output = ["type=cacheonly"] + contexts = { + base = "target:php80-base" + } +} + # thecodingmachine/php:8.0-v5-slim-apache target "php80-slim-apache" { inherits = ["default"] + cache-from = cache_from("php80-slim-apache") + cache-to = cache_to("php80-slim-apache") tags = tag("8.0", "slim-apache") dockerfile = "Dockerfile.slim.apache" args = { - PHP_VERSION = "8.0" VARIANT = "apache" } + contexts = { + base = "target:php80-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php80-slim-apache-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php80-slim-apache-with-extensions") + cache-to = cache_to("php80-slim-apache-with-extensions") + dockerfile = "Dockerfile.slim.apache" + args = { + VARIANT = "apache" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php80-extensions" + } } # thecodingmachine/php:8.0-v5-apache target "php80-apache" { inherits = ["default"] + cache-from = cache_from("php80-apache") + cache-to = cache_to("php80-apache") tags = tag("8.0", "apache") dockerfile = "Dockerfile.apache" args = { - PHP_VERSION = "8.0" VARIANT = "apache" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php80-slim-apache" + slim-with-extensions = "target:php80-slim-apache-with-extensions" } } # thecodingmachine/php:8.0-v5-apache-node26 target "php80-apache-node26" { inherits = ["default"] + cache-from = cache_from("php80-apache-node26") + cache-to = cache_to("php80-apache-node26") tags = tag("8.0", "apache-node26") dockerfile = "Dockerfile.apache.node" args = { @@ -1991,6 +2570,8 @@ target "php80-apache-node26" { # thecodingmachine/php:8.0-v5-apache-node24 target "php80-apache-node24" { inherits = ["default"] + cache-from = cache_from("php80-apache-node24") + cache-to = cache_to("php80-apache-node24") tags = tag("8.0", "apache-node24") dockerfile = "Dockerfile.apache.node" args = { @@ -2007,6 +2588,8 @@ target "php80-apache-node24" { # thecodingmachine/php:8.0-v5-apache-node22 target "php80-apache-node22" { inherits = ["default"] + cache-from = cache_from("php80-apache-node22") + cache-to = cache_to("php80-apache-node22") tags = tag("8.0", "apache-node22") dockerfile = "Dockerfile.apache.node" args = { @@ -2023,6 +2606,8 @@ target "php80-apache-node22" { # thecodingmachine/php:8.0-v5-apache-node20 target "php80-apache-node20" { inherits = ["default"] + cache-from = cache_from("php80-apache-node20") + cache-to = cache_to("php80-apache-node20") tags = tag("8.0", "apache-node20") dockerfile = "Dockerfile.apache.node" args = { @@ -2039,6 +2624,8 @@ target "php80-apache-node20" { # thecodingmachine/php:8.0-v5-apache-node18 target "php80-apache-node18" { inherits = ["default"] + cache-from = cache_from("php80-apache-node18") + cache-to = cache_to("php80-apache-node18") tags = tag("8.0", "apache-node18") dockerfile = "Dockerfile.apache.node" args = { @@ -2052,38 +2639,56 @@ target "php80-apache-node18" { } } -########################### -## PHP 8.0 -########################### # thecodingmachine/php:8.0-v5-slim-fpm target "php80-slim-fpm" { inherits = ["default"] + cache-from = cache_from("php80-slim-fpm") + cache-to = cache_to("php80-slim-fpm") tags = tag("8.0", "slim-fpm") dockerfile = "Dockerfile.slim.fpm" args = { - PHP_VERSION = "8.0" VARIANT = "fpm" } + contexts = { + base = "target:php80-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php80-slim-fpm-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php80-slim-fpm-with-extensions") + cache-to = cache_to("php80-slim-fpm-with-extensions") + dockerfile = "Dockerfile.slim.fpm" + args = { + VARIANT = "fpm" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php80-extensions" + } } # thecodingmachine/php:8.0-v5-fpm target "php80-fpm" { inherits = ["default"] + cache-from = cache_from("php80-fpm") + cache-to = cache_to("php80-fpm") tags = tag("8.0", "fpm") dockerfile = "Dockerfile.fpm" args = { - PHP_VERSION = "8.0" VARIANT = "fpm" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php80-slim-fpm" + slim-with-extensions = "target:php80-slim-fpm-with-extensions" } } # thecodingmachine/php:8.0-v5-fpm-node26 target "php80-fpm-node26" { inherits = ["default"] + cache-from = cache_from("php80-fpm-node26") + cache-to = cache_to("php80-fpm-node26") tags = tag("8.0", "fpm-node26") dockerfile = "Dockerfile.fpm.node" args = { @@ -2100,6 +2705,8 @@ target "php80-fpm-node26" { # thecodingmachine/php:8.0-v5-fpm-node24 target "php80-fpm-node24" { inherits = ["default"] + cache-from = cache_from("php80-fpm-node24") + cache-to = cache_to("php80-fpm-node24") tags = tag("8.0", "fpm-node24") dockerfile = "Dockerfile.fpm.node" args = { @@ -2116,6 +2723,8 @@ target "php80-fpm-node24" { # thecodingmachine/php:8.0-v5-fpm-node22 target "php80-fpm-node22" { inherits = ["default"] + cache-from = cache_from("php80-fpm-node22") + cache-to = cache_to("php80-fpm-node22") tags = tag("8.0", "fpm-node22") dockerfile = "Dockerfile.fpm.node" args = { @@ -2132,6 +2741,8 @@ target "php80-fpm-node22" { # thecodingmachine/php:8.0-v5-fpm-node20 target "php80-fpm-node20" { inherits = ["default"] + cache-from = cache_from("php80-fpm-node20") + cache-to = cache_to("php80-fpm-node20") tags = tag("8.0", "fpm-node20") dockerfile = "Dockerfile.fpm.node" args = { @@ -2148,6 +2759,8 @@ target "php80-fpm-node20" { # thecodingmachine/php:8.0-v5-fpm-node18 target "php80-fpm-node18" { inherits = ["default"] + cache-from = cache_from("php80-fpm-node18") + cache-to = cache_to("php80-fpm-node18") tags = tag("8.0", "fpm-node18") dockerfile = "Dockerfile.fpm.node" args = { @@ -2161,38 +2774,56 @@ target "php80-fpm-node18" { } } -########################### -## PHP 8.0 -########################### # thecodingmachine/php:8.0-v5-slim-cli target "php80-slim-cli" { inherits = ["default"] + cache-from = cache_from("php80-slim-cli") + cache-to = cache_to("php80-slim-cli") tags = tag("8.0", "slim-cli") dockerfile = "Dockerfile.slim.cli" args = { - PHP_VERSION = "8.0" VARIANT = "cli" } + contexts = { + base = "target:php80-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php80-slim-cli-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php80-slim-cli-with-extensions") + cache-to = cache_to("php80-slim-cli-with-extensions") + dockerfile = "Dockerfile.slim.cli" + args = { + VARIANT = "cli" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php80-extensions" + } } # thecodingmachine/php:8.0-v5-cli target "php80-cli" { inherits = ["default"] + cache-from = cache_from("php80-cli") + cache-to = cache_to("php80-cli") tags = tag("8.0", "cli") dockerfile = "Dockerfile.cli" args = { - PHP_VERSION = "8.0" VARIANT = "cli" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php80-slim-cli" + slim-with-extensions = "target:php80-slim-cli-with-extensions" } } # thecodingmachine/php:8.0-v5-cli-node26 target "php80-cli-node26" { inherits = ["default"] + cache-from = cache_from("php80-cli-node26") + cache-to = cache_to("php80-cli-node26") tags = tag("8.0", "cli-node26") dockerfile = "Dockerfile.cli.node" args = { @@ -2209,6 +2840,8 @@ target "php80-cli-node26" { # thecodingmachine/php:8.0-v5-cli-node24 target "php80-cli-node24" { inherits = ["default"] + cache-from = cache_from("php80-cli-node24") + cache-to = cache_to("php80-cli-node24") tags = tag("8.0", "cli-node24") dockerfile = "Dockerfile.cli.node" args = { @@ -2225,6 +2858,8 @@ target "php80-cli-node24" { # thecodingmachine/php:8.0-v5-cli-node22 target "php80-cli-node22" { inherits = ["default"] + cache-from = cache_from("php80-cli-node22") + cache-to = cache_to("php80-cli-node22") tags = tag("8.0", "cli-node22") dockerfile = "Dockerfile.cli.node" args = { @@ -2241,6 +2876,8 @@ target "php80-cli-node22" { # thecodingmachine/php:8.0-v5-cli-node20 target "php80-cli-node20" { inherits = ["default"] + cache-from = cache_from("php80-cli-node20") + cache-to = cache_to("php80-cli-node20") tags = tag("8.0", "cli-node20") dockerfile = "Dockerfile.cli.node" args = { @@ -2257,6 +2894,8 @@ target "php80-cli-node20" { # thecodingmachine/php:8.0-v5-cli-node18 target "php80-cli-node18" { inherits = ["default"] + cache-from = cache_from("php80-cli-node18") + cache-to = cache_to("php80-cli-node18") tags = tag("8.0", "cli-node18") dockerfile = "Dockerfile.cli.node" args = { @@ -2273,35 +2912,79 @@ target "php80-cli-node18" { ########################### ## PHP 7.4 ########################### +# Layers shared by the images of all the variants (not published) +target "php74-base" { + inherits = ["default"] + cache-from = cache_from("php74-base") + cache-to = cache_to("php74-base") + dockerfile = "Dockerfile.base" + output = ["type=cacheonly"] + args = { + PHP_VERSION = "7.4" + } +} + +target "php74-extensions" { + inherits = ["default"] + cache-from = cache_from("php74-extensions") + cache-to = cache_to("php74-extensions") + dockerfile = "Dockerfile.extensions" + output = ["type=cacheonly"] + contexts = { + base = "target:php74-base" + } +} + # thecodingmachine/php:7.4-v5-slim-apache target "php74-slim-apache" { inherits = ["default"] + cache-from = cache_from("php74-slim-apache") + cache-to = cache_to("php74-slim-apache") tags = tag("7.4", "slim-apache") dockerfile = "Dockerfile.slim.apache" args = { - PHP_VERSION = "7.4" VARIANT = "apache" } + contexts = { + base = "target:php74-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php74-slim-apache-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php74-slim-apache-with-extensions") + cache-to = cache_to("php74-slim-apache-with-extensions") + dockerfile = "Dockerfile.slim.apache" + args = { + VARIANT = "apache" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php74-extensions" + } } # thecodingmachine/php:7.4-v5-apache target "php74-apache" { inherits = ["default"] + cache-from = cache_from("php74-apache") + cache-to = cache_to("php74-apache") tags = tag("7.4", "apache") dockerfile = "Dockerfile.apache" args = { - PHP_VERSION = "7.4" VARIANT = "apache" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php74-slim-apache" + slim-with-extensions = "target:php74-slim-apache-with-extensions" } } # thecodingmachine/php:7.4-v5-apache-node26 target "php74-apache-node26" { inherits = ["default"] + cache-from = cache_from("php74-apache-node26") + cache-to = cache_to("php74-apache-node26") tags = tag("7.4", "apache-node26") dockerfile = "Dockerfile.apache.node" args = { @@ -2318,6 +3001,8 @@ target "php74-apache-node26" { # thecodingmachine/php:7.4-v5-apache-node24 target "php74-apache-node24" { inherits = ["default"] + cache-from = cache_from("php74-apache-node24") + cache-to = cache_to("php74-apache-node24") tags = tag("7.4", "apache-node24") dockerfile = "Dockerfile.apache.node" args = { @@ -2334,6 +3019,8 @@ target "php74-apache-node24" { # thecodingmachine/php:7.4-v5-apache-node22 target "php74-apache-node22" { inherits = ["default"] + cache-from = cache_from("php74-apache-node22") + cache-to = cache_to("php74-apache-node22") tags = tag("7.4", "apache-node22") dockerfile = "Dockerfile.apache.node" args = { @@ -2350,6 +3037,8 @@ target "php74-apache-node22" { # thecodingmachine/php:7.4-v5-apache-node20 target "php74-apache-node20" { inherits = ["default"] + cache-from = cache_from("php74-apache-node20") + cache-to = cache_to("php74-apache-node20") tags = tag("7.4", "apache-node20") dockerfile = "Dockerfile.apache.node" args = { @@ -2366,6 +3055,8 @@ target "php74-apache-node20" { # thecodingmachine/php:7.4-v5-apache-node18 target "php74-apache-node18" { inherits = ["default"] + cache-from = cache_from("php74-apache-node18") + cache-to = cache_to("php74-apache-node18") tags = tag("7.4", "apache-node18") dockerfile = "Dockerfile.apache.node" args = { @@ -2379,38 +3070,56 @@ target "php74-apache-node18" { } } -########################### -## PHP 7.4 -########################### # thecodingmachine/php:7.4-v5-slim-fpm target "php74-slim-fpm" { inherits = ["default"] + cache-from = cache_from("php74-slim-fpm") + cache-to = cache_to("php74-slim-fpm") tags = tag("7.4", "slim-fpm") dockerfile = "Dockerfile.slim.fpm" args = { - PHP_VERSION = "7.4" VARIANT = "fpm" } + contexts = { + base = "target:php74-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php74-slim-fpm-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php74-slim-fpm-with-extensions") + cache-to = cache_to("php74-slim-fpm-with-extensions") + dockerfile = "Dockerfile.slim.fpm" + args = { + VARIANT = "fpm" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php74-extensions" + } } # thecodingmachine/php:7.4-v5-fpm target "php74-fpm" { inherits = ["default"] + cache-from = cache_from("php74-fpm") + cache-to = cache_to("php74-fpm") tags = tag("7.4", "fpm") dockerfile = "Dockerfile.fpm" args = { - PHP_VERSION = "7.4" VARIANT = "fpm" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php74-slim-fpm" + slim-with-extensions = "target:php74-slim-fpm-with-extensions" } } # thecodingmachine/php:7.4-v5-fpm-node26 target "php74-fpm-node26" { inherits = ["default"] + cache-from = cache_from("php74-fpm-node26") + cache-to = cache_to("php74-fpm-node26") tags = tag("7.4", "fpm-node26") dockerfile = "Dockerfile.fpm.node" args = { @@ -2427,6 +3136,8 @@ target "php74-fpm-node26" { # thecodingmachine/php:7.4-v5-fpm-node24 target "php74-fpm-node24" { inherits = ["default"] + cache-from = cache_from("php74-fpm-node24") + cache-to = cache_to("php74-fpm-node24") tags = tag("7.4", "fpm-node24") dockerfile = "Dockerfile.fpm.node" args = { @@ -2443,6 +3154,8 @@ target "php74-fpm-node24" { # thecodingmachine/php:7.4-v5-fpm-node22 target "php74-fpm-node22" { inherits = ["default"] + cache-from = cache_from("php74-fpm-node22") + cache-to = cache_to("php74-fpm-node22") tags = tag("7.4", "fpm-node22") dockerfile = "Dockerfile.fpm.node" args = { @@ -2459,6 +3172,8 @@ target "php74-fpm-node22" { # thecodingmachine/php:7.4-v5-fpm-node20 target "php74-fpm-node20" { inherits = ["default"] + cache-from = cache_from("php74-fpm-node20") + cache-to = cache_to("php74-fpm-node20") tags = tag("7.4", "fpm-node20") dockerfile = "Dockerfile.fpm.node" args = { @@ -2475,6 +3190,8 @@ target "php74-fpm-node20" { # thecodingmachine/php:7.4-v5-fpm-node18 target "php74-fpm-node18" { inherits = ["default"] + cache-from = cache_from("php74-fpm-node18") + cache-to = cache_to("php74-fpm-node18") tags = tag("7.4", "fpm-node18") dockerfile = "Dockerfile.fpm.node" args = { @@ -2488,38 +3205,56 @@ target "php74-fpm-node18" { } } -########################### -## PHP 7.4 -########################### # thecodingmachine/php:7.4-v5-slim-cli target "php74-slim-cli" { inherits = ["default"] + cache-from = cache_from("php74-slim-cli") + cache-to = cache_to("php74-slim-cli") tags = tag("7.4", "slim-cli") dockerfile = "Dockerfile.slim.cli" args = { - PHP_VERSION = "7.4" VARIANT = "cli" } + contexts = { + base = "target:php74-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php74-slim-cli-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php74-slim-cli-with-extensions") + cache-to = cache_to("php74-slim-cli-with-extensions") + dockerfile = "Dockerfile.slim.cli" + args = { + VARIANT = "cli" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php74-extensions" + } } # thecodingmachine/php:7.4-v5-cli target "php74-cli" { inherits = ["default"] + cache-from = cache_from("php74-cli") + cache-to = cache_to("php74-cli") tags = tag("7.4", "cli") dockerfile = "Dockerfile.cli" args = { - PHP_VERSION = "7.4" VARIANT = "cli" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php74-slim-cli" + slim-with-extensions = "target:php74-slim-cli-with-extensions" } } # thecodingmachine/php:7.4-v5-cli-node26 target "php74-cli-node26" { inherits = ["default"] + cache-from = cache_from("php74-cli-node26") + cache-to = cache_to("php74-cli-node26") tags = tag("7.4", "cli-node26") dockerfile = "Dockerfile.cli.node" args = { @@ -2536,6 +3271,8 @@ target "php74-cli-node26" { # thecodingmachine/php:7.4-v5-cli-node24 target "php74-cli-node24" { inherits = ["default"] + cache-from = cache_from("php74-cli-node24") + cache-to = cache_to("php74-cli-node24") tags = tag("7.4", "cli-node24") dockerfile = "Dockerfile.cli.node" args = { @@ -2552,6 +3289,8 @@ target "php74-cli-node24" { # thecodingmachine/php:7.4-v5-cli-node22 target "php74-cli-node22" { inherits = ["default"] + cache-from = cache_from("php74-cli-node22") + cache-to = cache_to("php74-cli-node22") tags = tag("7.4", "cli-node22") dockerfile = "Dockerfile.cli.node" args = { @@ -2568,6 +3307,8 @@ target "php74-cli-node22" { # thecodingmachine/php:7.4-v5-cli-node20 target "php74-cli-node20" { inherits = ["default"] + cache-from = cache_from("php74-cli-node20") + cache-to = cache_to("php74-cli-node20") tags = tag("7.4", "cli-node20") dockerfile = "Dockerfile.cli.node" args = { @@ -2584,6 +3325,8 @@ target "php74-cli-node20" { # thecodingmachine/php:7.4-v5-cli-node18 target "php74-cli-node18" { inherits = ["default"] + cache-from = cache_from("php74-cli-node18") + cache-to = cache_to("php74-cli-node18") tags = tag("7.4", "cli-node18") dockerfile = "Dockerfile.cli.node" args = { diff --git a/docs/contributing.md b/docs/contributing.md index 2ec34ad7..9a844b7c 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -14,6 +14,14 @@ $ make blueprint The pages of the `docs` directory are not generated: edit them directly. +The images of a PHP version share their first layers (see `utils/docker-bake.blueprint.hcl`): + +- `Dockerfile.base`: the layers common to all the images; +- `Dockerfile.slim.`: the *slim* image of the variant, built on `Dockerfile.base`; +- `Dockerfile.extensions`: the extensions, installed once for the 3 variants on `Dockerfile.base`; +- `Dockerfile.`: the *fat* image, built on `Dockerfile.slim.` applied on `Dockerfile.extensions`; +- `Dockerfile..node`: the *node* images, built on the *fat* image. + ## Building and testing The tests use [bash_unit](https://github.com/pgrange/bash_unit) (see the [test suite](../tests-suite/README.md)). @@ -31,6 +39,13 @@ To test images already built, run the test suite directly: $ PHP_VERSION=8.4 BRANCH=v5 VARIANT=apache ./tests-suite/bash_unit -f tap ./tests-suite/*.sh ``` +To run the test files of several variants in parallel, as the CI does (`TEST_JOBS` test files at the same time, 2 by +default, with one log per test file): + +```bash +$ PHP_VERSION=8.4 BRANCH=v5 VARIANTS="apache cli fpm" NODE_VERSIONS="22 24 26" ./tests-suite/run_tests.sh +``` + The variables of [`tests-suite/config`](../tests-suite/config) select the images to test, e.g. `TAG_PREFIX` (images built with `TAG_PREFIX=mytest- docker buildx bake ...`) or `PLATFORM` (e.g. `linux/arm64` with QEMU). diff --git a/orbit.yml b/orbit.yml index e299420e..e88490d4 100644 --- a/orbit.yml +++ b/orbit.yml @@ -19,6 +19,8 @@ tasks: - use: generate short: Generates all Dockerfiles and the README.md file run: + - orbit generate -f utils/Dockerfile.base.blueprint -o Dockerfile.base + - orbit generate -f utils/Dockerfile.extensions.blueprint -o Dockerfile.extensions - orbit generate -f utils/Dockerfile.slim.blueprint -o Dockerfile.slim.apache -p "variant,apache" - orbit generate -f utils/Dockerfile.slim.blueprint -o Dockerfile.slim.cli -p "variant,cli" - orbit generate -f utils/Dockerfile.slim.blueprint -o Dockerfile.slim.fpm -p "variant,fpm" diff --git a/tests-suite/run_tests.sh b/tests-suite/run_tests.sh new file mode 100755 index 00000000..3169ba95 --- /dev/null +++ b/tests-suite/run_tests.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# Runs the test files for each variant of VARIANTS (and each NodeJS version of NODE_VERSIONS for variant-node.sh), +# TEST_JOBS test files at the same time, with one log per test file in LOG_DIR. +# Usage: VARIANTS="apache cli fpm" NODE_VERSIONS="22 24 26" [TEST_JOBS=2] ./tests-suite/run_tests.sh +set -u +cd "$(dirname "$0")" + +export TEST_JOBS="${TEST_JOBS:-2}" +export LOG_DIR="${LOG_DIR:-$(mktemp -d)}" +mkdir -p "${LOG_DIR}" +# Started first so that the longest test files are spread over the parallel jobs instead of ending on a single one +SLOW_TEST_FILES="tool-supercronic.sh onbuild.sh variant-fpm.sh tool-daemon.sh php-extensions.sh" + +test_units() { + local file variant node + for file in ${SLOW_TEST_FILES} $(ls *.sh | grep -vxF -f <(tr ' ' '\n' <<< "${SLOW_TEST_FILES} run_tests.sh")); do + for variant in ${VARIANTS}; do + if [[ "${file}" == "variant-node.sh" ]]; then + for node in ${NODE_VERSIONS:-}; do echo "${variant} ${file} ${node}"; done + else + echo "${variant} ${file}" + fi + done + done +} + +run_test_unit() { + local variant=$1 file=$2 node=${3:-} name start status + name="${variant}${node:+-node${node}}-${file%.sh}" + start=${SECONDS} + if (export VARIANT="${variant}"; if [[ -n "${node}" ]]; then export NODE="${node}"; fi; ./bash_unit -f tap "${file}") > "${LOG_DIR}/${name}.log" 2>&1; then + status=ok + else + status=FAILED + fi + echo "${status} ${name} $((SECONDS - start))s" +} +export -f run_test_unit + +test_units | xargs -P "${TEST_JOBS}" -L 1 bash -c 'run_test_unit "$@"' _ | tee "${LOG_DIR}/summary" + +FAILED=0 +for log in "${LOG_DIR}"/*.log; do + name=$(basename "${log}" .log) + if grep -q "^FAILED ${name} " "${LOG_DIR}/summary"; then + FAILED=1 + echo "::group::FAILED ${name}" + else + echo "::group::${name}" + fi + cat "${log}" + echo "::endgroup::" +done +if [[ "${FAILED}" == "1" ]]; then + echo "Failed test files:" + grep "^FAILED" "${LOG_DIR}/summary" +fi +exit "${FAILED}" diff --git a/tests-suite/tool-daemon.sh b/tests-suite/tool-daemon.sh index 669bece4..b23bc189 100755 --- a/tests-suite/tool-daemon.sh +++ b/tests-suite/tool-daemon.sh @@ -3,6 +3,21 @@ IMAGE="${REPO}:${TAG_PREFIX}${PHP_VERSION}-${BRANCH}-slim-${BRANCH_VARIANT}${ARCH_SUFFIX}" +# Waits until the main command of the variant answers and the daemon "sleep 300" runs in the container $1 +wait_started() { + local check + case "${VARIANT}" in + apache*) check='curl -s -o /dev/null http://localhost/ && pgrep -x sleep' ;; + fpm*) check='php-fpm-healthcheck && pgrep -x sleep' ;; + *) check='test "$(pgrep -cx sleep)" -ge 2' ;; + esac + for _ in $(seq 1 60); do + docker exec "$1" bash -c "${check}" > /dev/null 2>&1 && return 0 + sleep 0.5 + done + return 1 +} + ############################################################ ## DAEMON_COMMAND runs along with the main command, with the same user ############################################################ @@ -37,7 +52,7 @@ test_stopWhenDaemonExits() { test_dockerStop() { if [[ $VARIANT == cli* ]]; then COMMAND="sleep 300"; else COMMAND=""; fi docker run --name "${STOP_NAME}" ${RUN_OPTIONS} -d -e DAEMON_COMMAND_1="sleep 300" "${IMAGE}" ${COMMAND} > /dev/null - sleep 3 + wait_started "${STOP_NAME}" START=$(date +%s) docker stop "${STOP_NAME}" > /dev/null 2>&1 DURATION=$(( $(date +%s) - START )) diff --git a/tests-suite/variant-apache.sh b/tests-suite/variant-apache.sh index 65091a96..9a384864 100755 --- a/tests-suite/variant-apache.sh +++ b/tests-suite/variant-apache.sh @@ -69,6 +69,16 @@ test_switchMpm() { assert_not_matches "ERROR" "$RESULT" "a2enmod/a2dismod failed" } ############################################################ +## mod_cgid starts (its socket directory exists) +############################################################ +test_cgid() { + for image in "slim-${BRANCH_VARIANT}" "${BRANCH_VARIANT}"; do + RESULT="$(docker run ${RUN_OPTIONS} --rm -e APACHE_EXTENSION_CGID=1 \ + "${REPO}:${TAG_PREFIX}${PHP_VERSION}-${BRANCH}-${image}${ARCH_SUFFIX}" bash -c 'timeout 3 apache2-foreground 2>&1')" + assert_not_matches "cgid:(error|crit)" "$RESULT" "mod_cgid does not start in the ${image} image" + done +} +############################################################ ## A stop requested during the initialization is not lost ############################################################ test_stopDuringStartup() { diff --git a/utils/Dockerfile.base.blueprint b/utils/Dockerfile.base.blueprint new file mode 100644 index 00000000..9f217d9a --- /dev/null +++ b/utils/Dockerfile.base.blueprint @@ -0,0 +1,163 @@ +#syntax=docker/dockerfile-upstream:1 +FROM ubuntu:24.04 +LABEL authors="Mistral Oz , Julien Neuhart , David Négrier " +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# Fixes some weird terminal issues such as broken clear / CTRL+L +#ENV TERM=linux + +# Ensure apt doesn't ask questions when installing stuff +ENV DEBIAN_FRONTEND=noninteractive + +ARG PHP_VERSION +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=2 + +ENV TARGETOS=${TARGETOS} +ENV TARGETARCH=${TARGETARCH} +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} +ENV PHP_VERSION=${PHP_VERSION} + +# |-------------------------------------------------------------------------- +# | Main PHP extensions +# |-------------------------------------------------------------------------- +# | +# | Installs the main PHP extensions +# | + +# Install php an other packages +RUN apt update \ + && apt upgrade -y \ + && apt install -y --no-install-recommends curl ca-certificates \ + && curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb \ + && dpkg -i /tmp/debsuryorg-archive-keyring.deb \ + && . /etc/os-release \ + && echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/php.list \ + && apt update \ + && apt install -y --no-install-recommends \ + nano \ + sudo \ + git \ + iproute2 \ + procps \ + curl \ + unzip \ + ca-certificates \ + openssh-client \ + && apt clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* +# Note: From PHP 8.5, opcache is built-in and php${PHP_VERSION}-opcache package doesn't exist +RUN OPCACHE_PACKAGE="" \ + && if [ "${PHP_VERSION}" != "8.5" ]; then \ + OPCACHE_PACKAGE="php${PHP_VERSION}-opcache"; \ + fi \ + && apt update \ + && apt install -y --no-install-recommends \ + php${PHP_VERSION}-cli \ + php${PHP_VERSION}-curl \ + php${PHP_VERSION}-mbstring \ + ${OPCACHE_PACKAGE} \ + php${PHP_VERSION}-readline \ + php${PHP_VERSION}-xml \ + php${PHP_VERSION}-zip \ + && apt clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* + +# |-------------------------------------------------------------------------- +# | User +# |-------------------------------------------------------------------------- +# | +# | Define a default user with sudo rights. +# | + +RUN userdel ubuntu && rm -rf /home/ubuntu +RUN useradd -ms /bin/bash docker && adduser docker sudo +# Users in the sudoers group can sudo as root without password. +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/sudo + +# |-------------------------------------------------------------------------- +# | Default php.ini file +# |-------------------------------------------------------------------------- +# | +# | For some reasons, the official image has a php.ini-production.cli file +# | but no php.ini-development.cli file. Let's create this one. +# | + +RUN cp /usr/lib/php/${PHP_VERSION}/php.ini-development /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ + sed -i 's/^disable_functions/;disable_functions/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ + sed -i 's/^memory_limit = .*/memory_limit = -1/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli + +#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-production /usr/local/etc/php/php.ini-production +#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-development /usr/local/etc/php/php.ini-development +#RUN chmod 644 /usr/local/etc/php/php.ini-* + +ENV TEMPLATE_PHP_INI=development + +# Let's remove the default CLI php.ini file (it will be copied from TEMPLATE_PHP_INI) +RUN rm /etc/php/${PHP_VERSION}/cli/php.ini + +# |-------------------------------------------------------------------------- +# | Composer +# |-------------------------------------------------------------------------- +# | +# | Installs Composer to easily manage your PHP dependencies. +# | + +#ENV COMPOSER_ALLOW_SUPERUSER 1 + +RUN curl -sS --retry 5 --retry-delay 2 https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer &&\ + chmod +x /usr/local/bin/composer +COPY utils/select_composer_version.sh /usr/local/bin/select_composer_version.sh + +# TODO: utils.php in /usr/local/bin... bof! +COPY utils/utils.php /usr/local/bin/utils.php +RUN mv /usr/bin/php /usr/bin/real_php +COPY utils/php_proxy.sh /usr/bin/php +COPY utils/php_env_fingerprint.sh /usr/local/bin/php_env_fingerprint.sh +RUN touch /opt/php_env_fingerprint +COPY utils/generate_conf.php /usr/local/bin/generate_conf.php +COPY utils/setup_extensions.php /usr/local/bin/setup_extensions.php + +# |-------------------------------------------------------------------------- +# | Default PHP extensions to be enabled +# | By default, enable all the extensions that are enabled on a base Ubuntu install +# |-------------------------------------------------------------------------- +ENV PHP_EXTENSION_CALENDAR=1 \ + PHP_EXTENSION_CTYPE=1 \ + PHP_EXTENSION_CURL=1 \ + PHP_EXTENSION_DOM=1 \ + PHP_EXTENSION_EXIF=1 \ + PHP_EXTENSION_FILEINFO=1 \ + PHP_EXTENSION_FTP=1 \ + PHP_EXTENSION_GETTEXT=1 \ + PHP_EXTENSION_ICONV=1 \ + PHP_EXTENSION_JSON=1 \ + PHP_EXTENSION_MBSTRING=1 \ + PHP_EXTENSION_OPCACHE=1 \ + PHP_EXTENSION_PDO=1 \ + PHP_EXTENSION_PHAR=1 \ + PHP_EXTENSION_POSIX=1 \ + PHP_EXTENSION_READLINE=1 \ + PHP_EXTENSION_SHMOP=1 \ + PHP_EXTENSION_SIMPLEXML=1 \ + PHP_EXTENSION_SOCKETS=1 \ + PHP_EXTENSION_SYSVMSG=1 \ + PHP_EXTENSION_SYSVSEM=1 \ + PHP_EXTENSION_SYSVSHM=1 \ + PHP_EXTENSION_TOKENIZER=1 \ + PHP_EXTENSION_WDDX=1 \ + PHP_EXTENSION_XML=1 \ + PHP_EXTENSION_XMLREADER=1 \ + PHP_EXTENSION_XMLWRITER=1 \ + PHP_EXTENSION_XSL=1 \ + PHP_EXTENSION_ZIP=1 + +USER docker +RUN composer global require bamarni/symfony-console-autocomplete && \ + rm -rf ~/.composer/cache + +USER root + +COPY extensions/ /usr/local/lib/thecodingmachine-php/extensions +RUN ln -s ${PHP_VERSION} /usr/local/lib/thecodingmachine-php/extensions/current diff --git a/utils/Dockerfile.blueprint b/utils/Dockerfile.blueprint index 42e49a30..3941c751 100644 --- a/utils/Dockerfile.blueprint +++ b/utils/Dockerfile.blueprint @@ -2,13 +2,9 @@ ARG INSTALL_CRON=1 ARG INSTALL_COMPOSER=1 ARG INSTALL_LOCALES=1 -ARG PHP_VERSION="8.4" -ARG GLOBAL_VERSION="v5" -ARG REPO="thecodingmachine/php" -ARG TAG_PREFIX="" -ARG FROM_IMAGE="${REPO}:${TAG_PREFIX}${PHP_VERSION}-${GLOBAL_VERSION}-slim-{{ .Orbit.variant }}" -FROM ${FROM_IMAGE} +# The slim Dockerfile of the variant applied on Dockerfile.extensions (see docker-bake.hcl) +FROM slim-with-extensions LABEL authors="Mistral Oz , Julien Neuhart , David Négrier " SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -16,15 +12,10 @@ ARG TARGETOS ARG TARGETARCH ARG BLACKFIRE_VERSION=2 -# |-------------------------------------------------------------------------- -# | Main PHP extensions -# |-------------------------------------------------------------------------- -# | -# | Installs the main PHP extensions -# | - +# The packages of the variant enable all the extensions installed before them: enable only the ones of the slim image USER root -RUN cd /usr/local/lib/thecodingmachine-php/extensions/current/ && ./install_all.sh && ./disable_all.sh +RUN /usr/bin/real_php /usr/local/bin/setup_extensions.php | bash && \ + cd /usr/local/lib/thecodingmachine-php/extensions/current/ && ./disable_all.sh USER docker # |-------------------------------------------------------------------------- diff --git a/utils/Dockerfile.extensions.blueprint b/utils/Dockerfile.extensions.blueprint new file mode 100644 index 00000000..5a548513 --- /dev/null +++ b/utils/Dockerfile.extensions.blueprint @@ -0,0 +1,15 @@ +#syntax=docker/dockerfile-upstream:1 +FROM base + +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=2 + +# |-------------------------------------------------------------------------- +# | Main PHP extensions +# |-------------------------------------------------------------------------- +# | +# | Installs the main PHP extensions, shared by the fat images of all the variants +# | + +RUN cd /usr/local/lib/thecodingmachine-php/extensions/current/ && ./install_all.sh && ./disable_all.sh diff --git a/utils/Dockerfile.slim.blueprint b/utils/Dockerfile.slim.blueprint index a621a9e5..e5f71de2 100644 --- a/utils/Dockerfile.slim.blueprint +++ b/utils/Dockerfile.slim.blueprint @@ -1,167 +1,11 @@ #syntax=docker/dockerfile-upstream:1 -FROM ubuntu:24.04 -LABEL authors="Mistral Oz , Julien Neuhart , David Négrier " -SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# "base" is Dockerfile.base for the slim images, Dockerfile.extensions for the fat ones (see docker-bake.hcl) +FROM base -# Fixes some weird terminal issues such as broken clear / CTRL+L -#ENV TERM=linux - -# Ensure apt doesn't ask questions when installing stuff -ENV DEBIAN_FRONTEND=noninteractive - -ARG PHP_VERSION -ARG TARGETOS -ARG TARGETARCH -ARG BLACKFIRE_VERSION=2 ONBUILD ARG TARGETOS=${TARGETOS} ONBUILD ARG TARGETARCH=${TARGETARCH} ONBUILD ARG BLACKFIRE_VERSION=${BLACKFIRE_VERSION} -ENV TARGETOS=${TARGETOS} -ENV TARGETARCH=${TARGETARCH} -ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} -ENV PHP_VERSION=${PHP_VERSION} - -# |-------------------------------------------------------------------------- -# | Main PHP extensions -# |-------------------------------------------------------------------------- -# | -# | Installs the main PHP extensions -# | - -# Install php an other packages -RUN apt update \ - && apt upgrade -y \ - && apt install -y --no-install-recommends curl ca-certificates \ - && curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb \ - && dpkg -i /tmp/debsuryorg-archive-keyring.deb \ - && . /etc/os-release \ - && echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/php.list \ - && apt update \ - && apt install -y --no-install-recommends \ - nano \ - sudo \ - git \ - iproute2 \ - procps \ - curl \ - unzip \ - ca-certificates \ - openssh-client \ - && apt clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* -# Note: From PHP 8.5, opcache is built-in and php${PHP_VERSION}-opcache package doesn't exist -RUN OPCACHE_PACKAGE="" \ - && if [ "${PHP_VERSION}" != "8.5" ]; then \ - OPCACHE_PACKAGE="php${PHP_VERSION}-opcache"; \ - fi \ - && apt update \ - && apt install -y --no-install-recommends \ - php${PHP_VERSION}-cli \ - php${PHP_VERSION}-curl \ - php${PHP_VERSION}-mbstring \ - ${OPCACHE_PACKAGE} \ - php${PHP_VERSION}-readline \ - php${PHP_VERSION}-xml \ - php${PHP_VERSION}-zip \ - && apt clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* - -# |-------------------------------------------------------------------------- -# | User -# |-------------------------------------------------------------------------- -# | -# | Define a default user with sudo rights. -# | - -RUN userdel ubuntu && rm -rf /home/ubuntu -RUN useradd -ms /bin/bash docker && adduser docker sudo -# Users in the sudoers group can sudo as root without password. -RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/sudo - -# |-------------------------------------------------------------------------- -# | Default php.ini file -# |-------------------------------------------------------------------------- -# | -# | For some reasons, the official image has a php.ini-production.cli file -# | but no php.ini-development.cli file. Let's create this one. -# | - -RUN cp /usr/lib/php/${PHP_VERSION}/php.ini-development /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ - sed -i 's/^disable_functions/;disable_functions/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli && \ - sed -i 's/^memory_limit = .*/memory_limit = -1/g' /usr/lib/php/${PHP_VERSION}/php.ini-development.cli - -#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-production /usr/local/etc/php/php.ini-production -#ADD https://raw.githubusercontent.com/php/php-src/PHP-${PHP_VERSION}/php.ini-development /usr/local/etc/php/php.ini-development -#RUN chmod 644 /usr/local/etc/php/php.ini-* - -ENV TEMPLATE_PHP_INI=development - -# Let's remove the default CLI php.ini file (it will be copied from TEMPLATE_PHP_INI) -RUN rm /etc/php/${PHP_VERSION}/cli/php.ini - -# |-------------------------------------------------------------------------- -# | Composer -# |-------------------------------------------------------------------------- -# | -# | Installs Composer to easily manage your PHP dependencies. -# | - -#ENV COMPOSER_ALLOW_SUPERUSER 1 - -RUN curl -sS --retry 5 --retry-delay 2 https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer &&\ - chmod +x /usr/local/bin/composer -COPY utils/select_composer_version.sh /usr/local/bin/select_composer_version.sh - -# TODO: utils.php in /usr/local/bin... bof! -COPY utils/utils.php /usr/local/bin/utils.php -RUN mv /usr/bin/php /usr/bin/real_php -COPY utils/php_proxy.sh /usr/bin/php -COPY utils/php_env_fingerprint.sh /usr/local/bin/php_env_fingerprint.sh -RUN touch /opt/php_env_fingerprint -COPY utils/generate_conf.php /usr/local/bin/generate_conf.php -COPY utils/setup_extensions.php /usr/local/bin/setup_extensions.php - -# |-------------------------------------------------------------------------- -# | Default PHP extensions to be enabled -# | By default, enable all the extensions that are enabled on a base Ubuntu install -# |-------------------------------------------------------------------------- -ENV PHP_EXTENSION_CALENDAR=1 \ - PHP_EXTENSION_CTYPE=1 \ - PHP_EXTENSION_CURL=1 \ - PHP_EXTENSION_DOM=1 \ - PHP_EXTENSION_EXIF=1 \ - PHP_EXTENSION_FILEINFO=1 \ - PHP_EXTENSION_FTP=1 \ - PHP_EXTENSION_GETTEXT=1 \ - PHP_EXTENSION_ICONV=1 \ - PHP_EXTENSION_JSON=1 \ - PHP_EXTENSION_MBSTRING=1 \ - PHP_EXTENSION_OPCACHE=1 \ - PHP_EXTENSION_PDO=1 \ - PHP_EXTENSION_PHAR=1 \ - PHP_EXTENSION_POSIX=1 \ - PHP_EXTENSION_READLINE=1 \ - PHP_EXTENSION_SHMOP=1 \ - PHP_EXTENSION_SIMPLEXML=1 \ - PHP_EXTENSION_SOCKETS=1 \ - PHP_EXTENSION_SYSVMSG=1 \ - PHP_EXTENSION_SYSVSEM=1 \ - PHP_EXTENSION_SYSVSHM=1 \ - PHP_EXTENSION_TOKENIZER=1 \ - PHP_EXTENSION_WDDX=1 \ - PHP_EXTENSION_XML=1 \ - PHP_EXTENSION_XMLREADER=1 \ - PHP_EXTENSION_XMLWRITER=1 \ - PHP_EXTENSION_XSL=1 \ - PHP_EXTENSION_ZIP=1 - -USER docker -RUN composer global require bamarni/symfony-console-autocomplete && \ - rm -rf ~/.composer/cache - -USER root - {{if or (eq .Orbit.variant "apache") (eq .Orbit.variant "fpm") }} # Apache: built-in web server of the fpm variant (disabled by default, see PHP_FPM_WEB_SERVER) ENV APACHE_CONFDIR=/etc/apache2 @@ -185,6 +29,7 @@ RUN set -eux; \ for dir in \ "$APACHE_LOCK_DIR" \ "$APACHE_RUN_DIR" \ + "$APACHE_RUN_DIR/socks" \ "$APACHE_LOG_DIR" \ ; do \ rm -rvf "$dir"; \ @@ -385,8 +230,6 @@ COPY utils/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh COPY utils/docker-entrypoint-as-root.sh /usr/local/bin/docker-entrypoint-as-root.sh COPY utils/supervise.sh /usr/local/bin/supervise.sh -COPY extensions/ /usr/local/lib/thecodingmachine-php/extensions -RUN ln -s ${PHP_VERSION} /usr/local/lib/thecodingmachine-php/extensions/current ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] diff --git a/utils/docker-bake.blueprint.hcl b/utils/docker-bake.blueprint.hcl index 0f1aa89b..6937e77b 100644 --- a/utils/docker-bake.blueprint.hcl +++ b/utils/docker-bake.blueprint.hcl @@ -34,6 +34,21 @@ variable "IS_RELEASE" {default = "0"} variable "GLOBAL_VERSION" {default = "v5"} variable "ARCH_SUFFIX" {default = ""} +# Registry of the cache of the layers between the runs (e.g. ghcr.io/thecodingmachine/php-cache), none by default. +# The cache is only read, unless CACHE_WRITE=1 +variable "CACHE_REPO" {default = ""} +variable "CACHE_WRITE" {default = "0"} + +function "cache_from" { + params = [NAME] + result = equal("", CACHE_REPO) ? [] : ["type=registry,ref=${CACHE_REPO}:${NAME}${ARCH_SUFFIX}"] +} + +function "cache_to" { + params = [NAME] + result = equal("", CACHE_REPO) || !equal("1", CACHE_WRITE) ? [] : ["type=registry,ref=${CACHE_REPO}:${NAME}${ARCH_SUFFIX},mode=max,image-manifest=true,oci-mediatypes=true,ignore-error=true"] +} + function "tag" { params = [PHP_VERSION, VARIANT] result = [ @@ -54,39 +69,83 @@ target "default" { output = ["type=docker"] # export in local docker } -{{range $phpV := $versions}}{{range $variant := $variants}}{{ $nodes := $legacyNodeVersions }} +{{range $phpV := $versions}} ########################### ## PHP {{ $phpV }} ########################### +# Layers shared by the images of all the variants (not published) +target "php{{ $phpV | replace "." "" }}-base" { + inherits = ["default"] + cache-from = cache_from("php{{ $phpV | replace "." "" }}-base") + cache-to = cache_to("php{{ $phpV | replace "." "" }}-base") + dockerfile = "Dockerfile.base" + output = ["type=cacheonly"] + args = { + PHP_VERSION = "{{ $phpV }}" + } +} + +target "php{{ $phpV | replace "." "" }}-extensions" { + inherits = ["default"] + cache-from = cache_from("php{{ $phpV | replace "." "" }}-extensions") + cache-to = cache_to("php{{ $phpV | replace "." "" }}-extensions") + dockerfile = "Dockerfile.extensions" + output = ["type=cacheonly"] + contexts = { + base = "target:php{{ $phpV | replace "." "" }}-base" + } +} +{{range $variant := $variants}}{{ $nodes := $legacyNodeVersions }} # thecodingmachine/php:{{ $phpV }}-v5-slim-{{ $variant }} target "php{{ $phpV | replace "." "" }}-slim-{{ $variant }}" { inherits = ["default"] + cache-from = cache_from("php{{ $phpV | replace "." "" }}-slim-{{ $variant }}") + cache-to = cache_to("php{{ $phpV | replace "." "" }}-slim-{{ $variant }}") tags = tag("{{ $phpV }}", "slim-{{ $variant }}") dockerfile = "Dockerfile.slim.{{ $variant }}" args = { - PHP_VERSION = "{{ $phpV }}" VARIANT = "{{ $variant }}" } + contexts = { + base = "target:php{{ $phpV | replace "." "" }}-base" + } +} + +# The slim image of the variant with the extensions (not published) +target "php{{ $phpV | replace "." "" }}-slim-{{ $variant }}-with-extensions" { + inherits = ["default"] + cache-from = cache_from("php{{ $phpV | replace "." "" }}-slim-{{ $variant }}-with-extensions") + cache-to = cache_to("php{{ $phpV | replace "." "" }}-slim-{{ $variant }}-with-extensions") + dockerfile = "Dockerfile.slim.{{ $variant }}" + args = { + VARIANT = "{{ $variant }}" + } + output = ["type=cacheonly"] + contexts = { + base = "target:php{{ $phpV | replace "." "" }}-extensions" + } } # thecodingmachine/php:{{ $phpV }}-v5-{{ $variant }} target "php{{ $phpV | replace "." "" }}-{{ $variant }}" { inherits = ["default"] + cache-from = cache_from("php{{ $phpV | replace "." "" }}-{{ $variant }}") + cache-to = cache_to("php{{ $phpV | replace "." "" }}-{{ $variant }}") tags = tag("{{ $phpV }}", "{{ $variant }}") dockerfile = "Dockerfile.{{ $variant }}" args = { - PHP_VERSION = "{{ $phpV }}" VARIANT = "{{ $variant }}" - FROM_IMAGE = "slim" } contexts = { - slim = "target:php{{ $phpV | replace "." "" }}-slim-{{ $variant }}" + slim-with-extensions = "target:php{{ $phpV | replace "." "" }}-slim-{{ $variant }}-with-extensions" } } {{range $nodeV := $nodes}} # thecodingmachine/php:{{ $phpV }}-v5-{{ $variant }}-node{{ $nodeV }} target "php{{ $phpV | replace "." "" }}-{{ $variant }}-node{{ $nodeV }}" { inherits = ["default"] + cache-from = cache_from("php{{ $phpV | replace "." "" }}-{{ $variant }}-node{{ $nodeV }}") + cache-to = cache_to("php{{ $phpV | replace "." "" }}-{{ $variant }}-node{{ $nodeV }}") tags = tag("{{ $phpV }}", "{{ $variant }}-node{{ $nodeV }}") dockerfile = "Dockerfile.{{ $variant }}.node" args = {