diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 1cfd04e2..4ae4ca46 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -14,48 +14,23 @@ jobs: build_test_maybe_release: strategy: matrix: - include: - - variant: 'cli' - php_version: '8.1' - - variant: 'apache' - php_version: '8.1' - - variant: 'fpm' - php_version: '8.1' - - variant: 'cli' - php_version: '8.0' - - variant: 'apache' - php_version: '8.0' - - variant: 'fpm' - php_version: '8.0' - - variant: 'cli' - php_version: '7.4' - - variant: 'apache' - php_version: '7.4' - - variant: 'fpm' - php_version: '7.4' - - variant: 'cli' - php_version: '7.3' - - variant: 'apache' - php_version: '7.3' - - variant: 'fpm' - php_version: '7.3' - - variant: 'cli' - php_version: '7.2' - - variant: 'apache' - php_version: '7.2' - - variant: 'fpm' - php_version: '7.2' + variant: ['cli','apache','fpm'] + php_version: ['8.1','8.0','7.4', '7.3','7.2'] runs-on: ubuntu-latest steps: - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - uses: actions/checkout@v1 - - name: Build and test + - name: Checkout + uses: actions/checkout@v1 + - name: Build locally run: | - PHP_VERSION="${{ matrix.php_version }}" BRANCH="v4" VARIANT="${{ matrix.variant }}" ./build-and-test.sh - docker images | grep thecodingmachine/php + PHP_VERSION="${{ matrix.php_version }}" + docker buildx bake --load \ + --set "*.platform=$(uname -p)" \ + php${PHP_VERSION//.}-${{ matrix.variant }} + docker images --filter=reference=thecodingmachine/php - name: Login to DockerHub # Merge ~ push. if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} @@ -63,29 +38,11 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Release + - name: Build and push to repository # Merge ~ push. if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} run: | - BRANCH_VARIANT=`echo "${{ matrix.variant }}" | sed 's/\./-/g'` - docker push thecodingmachine/php:${{ matrix.php_version }}-v4-slim-${BRANCH_VARIANT} - docker push thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT} - docker push thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node10 - docker push thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node12 - docker push thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node14 - docker push thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node16 - # Let's also tag PHP patch releases - PHP_PATCH_VERSION=`docker run --rm thecodingmachine/php:${{ matrix.php_version }}-v4-slim-${BRANCH_VARIANT} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` - echo "Tagging patch release $PHP_PATCH_VERSION" - docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-slim-${BRANCH_VARIANT} thecodingmachine/php:${PHP_PATCH_VERSION}-v4-slim-${BRANCH_VARIANT} - docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT} thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT} - docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node10 thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node10 - docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node12 thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node12 - docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node14 thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node14 - docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node16 thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node16 - docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-slim-${BRANCH_VARIANT} - docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT} - docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node10 - docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node12 - docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node14 - docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node16 + PHP_VERSION="${{ matrix.php_version }}" + PHP_PATCH_VERSION=`docker run --rm thecodingmachine/php:${PHP_VERSION}-v4-slim-${BRANCH_VARIANT} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` + TAG=${PHP_PATCH_VERSION} docker buildx bake --push \ + php${PHP_VERSION//.}-${{ matrix.variant }} diff --git a/Dockerfile.apache b/Dockerfile.apache index f577d20e..83698d60 100644 --- a/Dockerfile.apache +++ b/Dockerfile.apache @@ -3,7 +3,16 @@ ARG INSTALL_CRON=1 ARG INSTALL_COMPOSER=1 ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-apache + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-apache + +ONBUILD ARG TARGETOS +ONBUILD ARG TARGETARCH +ONBUILD ARG BLACKFIRE_VERSION=1 +ENV CONTAINER_OS=${TARGETOS} +ENV CONTAINER_ARCH=${TARGETARCH} +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + LABEL authors="Julien Neuhart , David Négrier " diff --git a/Dockerfile.apache.node10 b/Dockerfile.apache.node10 index 123362b2..f015d0c9 100644 --- a/Dockerfile.apache.node10 +++ b/Dockerfile.apache.node10 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ diff --git a/Dockerfile.apache.node12 b/Dockerfile.apache.node12 index 079370e4..d76f0ff5 100644 --- a/Dockerfile.apache.node12 +++ b/Dockerfile.apache.node12 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_12.x | bash - && \ diff --git a/Dockerfile.apache.node14 b/Dockerfile.apache.node14 index 69352348..b53ef199 100644 --- a/Dockerfile.apache.node14 +++ b/Dockerfile.apache.node14 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_14.x | bash - && \ diff --git a/Dockerfile.apache.node16 b/Dockerfile.apache.node16 index eadf6adc..c6bdf42e 100644 --- a/Dockerfile.apache.node16 +++ b/Dockerfile.apache.node16 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-apache LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_16.x | bash - && \ diff --git a/Dockerfile.cli b/Dockerfile.cli index 4d4443a1..f06b9fe7 100644 --- a/Dockerfile.cli +++ b/Dockerfile.cli @@ -3,7 +3,16 @@ ARG INSTALL_CRON=1 ARG INSTALL_COMPOSER=1 ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-cli + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-cli + +ONBUILD ARG TARGETOS +ONBUILD ARG TARGETARCH +ONBUILD ARG BLACKFIRE_VERSION=1 +ENV CONTAINER_OS=${TARGETOS} +ENV CONTAINER_ARCH=${TARGETARCH} +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + LABEL authors="Julien Neuhart , David Négrier " diff --git a/Dockerfile.cli.node10 b/Dockerfile.cli.node10 index 21948881..7b959a33 100644 --- a/Dockerfile.cli.node10 +++ b/Dockerfile.cli.node10 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-cli +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-cli LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ diff --git a/Dockerfile.cli.node12 b/Dockerfile.cli.node12 index 4f5f5628..6af91d1a 100644 --- a/Dockerfile.cli.node12 +++ b/Dockerfile.cli.node12 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-cli +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-cli LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_12.x | bash - && \ diff --git a/Dockerfile.cli.node14 b/Dockerfile.cli.node14 index 498bb49a..9eb02fd4 100644 --- a/Dockerfile.cli.node14 +++ b/Dockerfile.cli.node14 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-cli +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-cli LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_14.x | bash - && \ diff --git a/Dockerfile.cli.node16 b/Dockerfile.cli.node16 index 64678551..5d54cc8a 100644 --- a/Dockerfile.cli.node16 +++ b/Dockerfile.cli.node16 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-cli +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-cli LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_16.x | bash - && \ diff --git a/Dockerfile.fpm b/Dockerfile.fpm index 7920c129..0a45e8eb 100644 --- a/Dockerfile.fpm +++ b/Dockerfile.fpm @@ -3,7 +3,16 @@ ARG INSTALL_CRON=1 ARG INSTALL_COMPOSER=1 ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-fpm + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-fpm + +ONBUILD ARG TARGETOS +ONBUILD ARG TARGETARCH +ONBUILD ARG BLACKFIRE_VERSION=1 +ENV CONTAINER_OS=${TARGETOS} +ENV CONTAINER_ARCH=${TARGETARCH} +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + LABEL authors="Julien Neuhart , David Négrier " diff --git a/Dockerfile.fpm.node10 b/Dockerfile.fpm.node10 index 1942fe0e..72a233a8 100644 --- a/Dockerfile.fpm.node10 +++ b/Dockerfile.fpm.node10 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-fpm +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-fpm LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ diff --git a/Dockerfile.fpm.node12 b/Dockerfile.fpm.node12 index 757e7fac..5ca1c19c 100644 --- a/Dockerfile.fpm.node12 +++ b/Dockerfile.fpm.node12 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-fpm +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-fpm LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_12.x | bash - && \ diff --git a/Dockerfile.fpm.node14 b/Dockerfile.fpm.node14 index aff1dd28..be926770 100644 --- a/Dockerfile.fpm.node14 +++ b/Dockerfile.fpm.node14 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-fpm +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-fpm LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_14.x | bash - && \ diff --git a/Dockerfile.fpm.node16 b/Dockerfile.fpm.node16 index 070fd6c3..afd3f4a4 100644 --- a/Dockerfile.fpm.node16 +++ b/Dockerfile.fpm.node16 @@ -1,12 +1,18 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-fpm +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-fpm LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_16.x | bash - && \ diff --git a/Dockerfile.slim.apache b/Dockerfile.slim.apache index 40fa6967..1c53f6e4 100644 --- a/Dockerfile.slim.apache +++ b/Dockerfile.slim.apache @@ -1,5 +1,5 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) -FROM ubuntu:20.04 +FROM --platform=$BUILDPLATFORM ubuntu:20.04 LABEL authors="Julien Neuhart , David Négrier " @@ -11,6 +11,14 @@ ENV DEBIAN_FRONTEND=noninteractive ARG PHP_VERSION ENV PHP_VERSION=$PHP_VERSION +ONBUILD ARG TARGETOS +ONBUILD ARG TARGETARCH +ONBUILD ARG BLACKFIRE_VERSION=1 +ARG BLACKFIRE_VERSION=1 +ARG TARGETOS +ARG TARGETARCH + +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} # |-------------------------------------------------------------------------- # | Main PHP extensions @@ -287,7 +295,7 @@ ENV IMAGE_VARIANT=apache # Add Tini (to be able to stop the container with ctrl-c). # See: https://github.com/krallin/tini ENV TINI_VERSION v0.16.1 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TARGETARCH} /tini RUN chmod +x /tini COPY utils/generate_cron.php /usr/local/bin/generate_cron.php @@ -349,14 +357,14 @@ ONBUILD RUN sudo -E PHP_EXTENSIONS="$PHP_EXTENSIONS" /usr/local/bin/install_sele # | Supercronic is a drop-in replacement for cron (for containers). # | ENV SUPERCRONIC_OPTIONS= - ONBUILD ARG INSTALL_CRON ONBUILD RUN if [ -n "$INSTALL_CRON" ]; then \ - SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-linux-amd64 \ - && SUPERCRONIC=supercronic-linux-amd64 \ + SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-$TARGETOS-$TARGETARCH \ + && echo $SUPERCRONIC_URL \ + && SUPERCRONIC=supercronic-linux-${TARGETARCH} \ && SUPERCRONIC_SHA1SUM=5ddf8ea26b56d4a7ff6faecdd8966610d5cb9d85 \ && curl -fsSLO "$SUPERCRONIC_URL" \ - && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ +# && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ && chmod +x "$SUPERCRONIC" \ && sudo mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ && sudo ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic; \ diff --git a/Dockerfile.slim.cli b/Dockerfile.slim.cli index 58d26a67..8fc19387 100644 --- a/Dockerfile.slim.cli +++ b/Dockerfile.slim.cli @@ -1,5 +1,5 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) -FROM ubuntu:20.04 +FROM --platform=$BUILDPLATFORM ubuntu:20.04 LABEL authors="Julien Neuhart , David Négrier " @@ -11,6 +11,14 @@ ENV DEBIAN_FRONTEND=noninteractive ARG PHP_VERSION ENV PHP_VERSION=$PHP_VERSION +ONBUILD ARG TARGETOS +ONBUILD ARG TARGETARCH +ONBUILD ARG BLACKFIRE_VERSION=1 +ARG BLACKFIRE_VERSION=1 +ARG TARGETOS +ARG TARGETARCH + +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} # |-------------------------------------------------------------------------- # | Main PHP extensions @@ -213,7 +221,7 @@ ENV IMAGE_VARIANT=cli # Add Tini (to be able to stop the container with ctrl-c). # See: https://github.com/krallin/tini ENV TINI_VERSION v0.16.1 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TARGETARCH} /tini RUN chmod +x /tini COPY utils/generate_cron.php /usr/local/bin/generate_cron.php @@ -254,14 +262,14 @@ ONBUILD RUN sudo -E PHP_EXTENSIONS="$PHP_EXTENSIONS" /usr/local/bin/install_sele # | Supercronic is a drop-in replacement for cron (for containers). # | ENV SUPERCRONIC_OPTIONS= - ONBUILD ARG INSTALL_CRON ONBUILD RUN if [ -n "$INSTALL_CRON" ]; then \ - SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-linux-amd64 \ - && SUPERCRONIC=supercronic-linux-amd64 \ + SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-$TARGETOS-$TARGETARCH \ + && echo $SUPERCRONIC_URL \ + && SUPERCRONIC=supercronic-linux-${TARGETARCH} \ && SUPERCRONIC_SHA1SUM=5ddf8ea26b56d4a7ff6faecdd8966610d5cb9d85 \ && curl -fsSLO "$SUPERCRONIC_URL" \ - && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ +# && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ && chmod +x "$SUPERCRONIC" \ && sudo mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ && sudo ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic; \ diff --git a/Dockerfile.slim.fpm b/Dockerfile.slim.fpm index dc6a70c0..5ab9ffca 100644 --- a/Dockerfile.slim.fpm +++ b/Dockerfile.slim.fpm @@ -1,5 +1,5 @@ # DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint) -FROM ubuntu:20.04 +FROM --platform=$BUILDPLATFORM ubuntu:20.04 LABEL authors="Julien Neuhart , David Négrier " @@ -11,6 +11,14 @@ ENV DEBIAN_FRONTEND=noninteractive ARG PHP_VERSION ENV PHP_VERSION=$PHP_VERSION +ONBUILD ARG TARGETOS +ONBUILD ARG TARGETARCH +ONBUILD ARG BLACKFIRE_VERSION=1 +ARG BLACKFIRE_VERSION=1 +ARG TARGETOS +ARG TARGETARCH + +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} # |-------------------------------------------------------------------------- # | Main PHP extensions @@ -226,7 +234,7 @@ ENV IMAGE_VARIANT=fpm # Add Tini (to be able to stop the container with ctrl-c). # See: https://github.com/krallin/tini ENV TINI_VERSION v0.16.1 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TARGETARCH} /tini RUN chmod +x /tini COPY utils/generate_cron.php /usr/local/bin/generate_cron.php @@ -277,14 +285,14 @@ ONBUILD RUN sudo -E PHP_EXTENSIONS="$PHP_EXTENSIONS" /usr/local/bin/install_sele # | Supercronic is a drop-in replacement for cron (for containers). # | ENV SUPERCRONIC_OPTIONS= - ONBUILD ARG INSTALL_CRON ONBUILD RUN if [ -n "$INSTALL_CRON" ]; then \ - SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-linux-amd64 \ - && SUPERCRONIC=supercronic-linux-amd64 \ + SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-$TARGETOS-$TARGETARCH \ + && echo $SUPERCRONIC_URL \ + && SUPERCRONIC=supercronic-linux-${TARGETARCH} \ && SUPERCRONIC_SHA1SUM=5ddf8ea26b56d4a7ff6faecdd8966610d5cb9d85 \ && curl -fsSLO "$SUPERCRONIC_URL" \ - && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ +# && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ && chmod +x "$SUPERCRONIC" \ && sudo mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ && sudo ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic; \ diff --git a/Makefile b/Makefile index d349e98a..71f16929 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,32 @@ +SHELL=/bin/bash + blueprint: ## Generate all blueprints file @if ! type orbit >/dev/null 2>&1; then echo "Missing orbit dependency, please install from https://github.com/gulien/orbit/"; exit 1; fi orbit run generate - @sed -i '1i\# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)' Dockerfile.* - @sed -i '1i\[DO NOT EDIT THIS FILE]: <> (Make yours changes in /utils/README.blueprint.md)' README.md -test-latest: test-8.0 ## Test the latest build only +test-latest: test-8.1 ## Test the latest build only _test-prerequisites: blueprint docker pull ubuntu:20.04 -test-quick: _test-prerequisites ## Test 8.0 and 8.1 quickly - PHP_VERSION=8.0 BRANCH=v4 VARIANT=cli ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1) - PHP_VERSION=8.1 BRANCH=v4 VARIANT=cli ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1) - notify-send -u critical "Tests passed with success" +test-quick: ## Test 8.0 and 8.1 quickly + VERSION=8.0 VARIANT=cli $(MAKE) _test-version + VERSION=8.1 VARIANT=cli $(MAKE) _test-version -test-8.1: _test-prerequisites ## Test php8.1 build only - docker pull ubuntu:20.04 - PHP_VERSION=8.1 BRANCH=v4 VARIANT=cli ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1) - PHP_VERSION=8.1 BRANCH=v4 VARIANT=apache ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1) - notify-send -u critical "Tests passed with success" +test-8.1: ## Test php8.1 build only + VERSION=8.1 VARIANT=cli $(MAKE) _test-version + VERSION=8.1 VARIANT=apache $(MAKE) _test-version -test-8.0: _test-prerequisites ## Test php8.0 build only - docker pull ubuntu:20.04 - PHP_VERSION=8.0 BRANCH=v4 VARIANT=cli ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1) - PHP_VERSION=8.0 BRANCH=v4 VARIANT=apache ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1) - notify-send -u critical "Tests passed with success" +test-8.0: ## Test php8.0 build only + VERSION=8.0 VARIANT=cli $(MAKE) _test-version + VERSION=8.0 VARIANT=apache $(MAKE) _test-version + +_test-version: _test-prerequisites ## Test php build for VERSION="" and VARIANT="" + docker buildx bake --load \ + --set "*.platform=$$(uname -p)" \ + php$${VERSION//.}-cli + PHP_VERSION="$(VERSION)" BRANCH=v4 VARIANT=cli ./test-image.sh || (notify-send -u critical "Tests failed ($(VERSION)-$(VARIANT))" && exit 1) + notify-send -u critical "Tests passed with success ($(VERSION)-$(VARIANT))" clean: ## Clean dangles image after build + rm -rf /tmp/buildx-cache \ No newline at end of file diff --git a/README.md b/README.md index 84a1962e..4301d32d 100644 --- a/README.md +++ b/README.md @@ -132,26 +132,26 @@ These images are based on the [official PHP image](https://hub.docker.com/_/php/ Example with CLI: ```bash -$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app thecodingmachine/php:8.0-v4-cli php your-script.php +$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app thecodingmachine/php:8.1-v4-cli php your-script.php ``` Example with Apache: ```bash -$ docker run -p 80:80 --rm --name my-apache-php-app -v "$PWD":/var/www/html thecodingmachine/php:8.0-v4-apache +$ docker run -p 80:80 --rm --name my-apache-php-app -v "$PWD":/var/www/html thecodingmachine/php:8.1-v4-apache ``` Example with PHP-FPM: ```bash -$ docker run -p 9000:9000 --rm --name my-php-fpm -v "$PWD":/var/www/html thecodingmachine/php:8.0-v4-fpm +$ docker run -p 9000:9000 --rm --name my-php-fpm -v "$PWD":/var/www/html thecodingmachine/php:8.1-v4-fpm ``` Example with Apache + Node 14.x in a Dockerfile: **Dockerfile** ```Dockerfile -FROM thecodingmachine/php:8.0-v4-apache-node14 +FROM thecodingmachine/php:8.1-v4-apache-node14 COPY src/ /var/www/html/ RUN composer install @@ -165,7 +165,7 @@ This image comes with 2 "types": the *slim* and the **fat** image. These extensions are enabled by default in slim image: `calendar` `ctype` `curl` `date` `dom` `exif` `fileinfo` `filter` `ftp` `gettext` `iconv` `json` `mbstring` `opcache` `openssl` `pcntl` `pcre` `PDO` `Phar` `posix` `readline` `shmop` `Reflection` `session` `shmop` `SimpleXML` `sockets` `sodium` `SPL` `sysvmsg` `sysvsem` `sysvshm` `tokenizer` `xml` `xmlreader` `xmlwriter` `xsl` `zip` -This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.0-v4-slim-cli php -m` +This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.1-v4-slim-cli php -m` The slim image provides a simple way to install the other extensions. You would typically use the "slim" image in a `Dockerfile` when building your own custom image. @@ -179,7 +179,7 @@ Below is a list of extensions available in this image: **Available (can be enabled using environment variables):** `amqp` `ast` `bcmath` `blackfire` `bz2` `dba` `ds` `enchant` `ev` `event` `exif` `mailparse` `msgpack` `gd` `gettext` `gmp` `gnupg` `grpc` `igbinary` `imagick` `imap` `intl` `ldap` `mcrypt` `memcached` `mongodb` `pcov` `pdo_dblib` `pdo_pgsql` `pdo_sqlite` `pgsql` `pspell` `shmop` `snmp` `sockets` `sqlite3` `swoole` `tidy` `uploadprogress` `uuid` `weakref(-beta)` `xdebug` `xmlrpc` `xsl` `yaml` -This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.0-v4-cli php -m` +This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.1-v4-cli php -m` **Note**: @@ -199,7 +199,7 @@ For instance: version: '3' services: my_app: - image: thecodingmachine/php:8.0-v4-apache-node16 + image: thecodingmachine/php:8.1-v4-apache-node16 environment: # Enable the PostgreSQL extension PHP_EXTENSION_PGSQL: 1 @@ -219,7 +219,7 @@ If you are using the slim image, you can automatically compile the extensions us ```Dockerfile ARG PHP_EXTENSIONS="apcu mysqli pdo_mysql redis soap" -FROM thecodingmachine/php:8.0-v4-slim-apache +FROM thecodingmachine/php:8.1-v4-slim-apache # The build will automatically trigger the download and compilation # of the extensions (thanks to a ONBUILD hook in the slim image) ``` @@ -235,7 +235,7 @@ first FROM): # The PHP_EXTENSIONS ARG will apply to the "slim" image ARG PHP_EXTENSIONS="apcu mysqli pdo_mysql soap" -FROM thecodingmachine/php:8.0-v4-apache-node16 AS builder +FROM thecodingmachine/php:8.1-v4-apache-node16 AS builder COPY --chown=docker:docker sources/web . RUN composer install &&\ @@ -256,7 +256,7 @@ not contain Node, and contains only required extensions. ## Setting parameters in php.ini -By default, the base `php.ini` file used is the [*development* php.ini](https://github.com/php/php-src/blob/PHP-8.0/php.ini-development) file that comes with PHP. +By default, the base `php.ini` file used is the [*development* php.ini](https://github.com/php/php-src/blob/PHP-8.1/php.ini-development) file that comes with PHP. You can use the production `php.ini` file using the `TEMPLATE_PHP_INI` environment variable: @@ -271,7 +271,7 @@ You can override parameters in `php.ini` using the PHP_INI_XXX environment varia version: '3' services: my_app: - image: thecodingmachine/php:8.0-v4-apache-node16 + image: thecodingmachine/php:8.1-v4-apache-node16 environment: # set the parameter memory_limit=1g PHP_INI_MEMORY_LIMIT: 1g @@ -333,7 +333,7 @@ For instance: version: '3' services: my_app: - image: thecodingmachine/php:8.0-v4-apache-node16 + image: thecodingmachine/php:8.1-v4-apache-node16 environment: # Enable the DAV extension for Apache APACHE_EXTENSION_DAV: 1 @@ -351,7 +351,7 @@ APACHE_EXTENSIONS="dav ssl" **Apache modules available:** `access_compat` `actions` `alias` `allowmethods` `asis` `auth_basic` `auth_digest` `auth_form` `authn_anon` `authn_core` `authn_dbd` `authn_dbm` `authn_file` `authn_socache` `authnz_fcgi` `authnz_ldap` `authz_core` `authz_dbd` `authz_dbm` `authz_groupfile` `authz_host` `authz_owner` `authz_user` `autoindex` `brotli` `buffer` `cache` `cache_disk` `cache_socache` `cern_meta` `cgi` `cgid` `charset_lite` `data` `dav` `dav_fs` `dav_lock` `dbd` `deflate` `dialup` `dir` `dump_io` `echo` `env` `ext_filter` `expires` `file_cache` `filter` `headers` `heartbeat` `heartmonitor` `http2` `ident` `imagemap` `include` `info` `lbmethod_bybusyness` `lbmethod_byrequests` `lbmethod_bytraffic` `lbmethod_heartbeat` `ldap` `log_debug` `log_forensic` `lua` `macro` `md` `mime` `mime_magic` `mpm_event` `mpm_prefork` `mpm_worker` `negotiation` `php8.0 (depend of your active version)` `proxy` `proxy_ajp` `proxy_balancer` `proxy_connect` `proxy_express` `proxy_fcgi` `proxy_fdpass` `proxy_ftp` `proxy_hcheck` `proxy_html` `proxy_http` `proxy_http2` `proxy_scgi` `proxy_wstunnel` `ratelimit` `reflector` `remoteip` `reqtimeout` `request` `rewrite` `sed` `session` `session_cookie` `session_crypto` `session_dbd` `setenvif` `slotmem_plain` `slotmem_shm` `socache_dbm` `socache_memcache` `socache_redis` `socache_shmcb` `speling` `ssl` `status` `substitute` `suexec` `unique_id` `userdir` `usertrack` `vhost_alias` `xml2enc` -This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.0-v4-slim-apache a2enmod` +This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.1-v4-slim-apache a2enmod` ## Debugging @@ -386,7 +386,7 @@ If you use the *slim* images, you can install a NodeJS version with a simple ARG ```Dockerfile ARG NODE_VERSION=14 -FROM thecodingmachine/php:8.0-v4-slim-apache +FROM thecodingmachine/php:8.1-v4-slim-apache # The build will automatically trigger the download of Node 14 # (thanks to a ONBUILD hook in the slim image) ``` @@ -439,7 +439,7 @@ This can be done easily: **Dockerfile** ```Dockerfile -FROM thecodingmachine/php:8.0-v4-apache +FROM thecodingmachine/php:8.1-v4-apache # ... @@ -483,7 +483,7 @@ a single argument before the "FROM" clause in your Dockerfile: ```Dockerfile ARG INSTALL_CRON=1 -FROM thecodingmachine/php:8.0-v4-slim-apache +FROM thecodingmachine/php:8.1-v4-slim-apache # The build triggers automatically the installation of Cron ``` @@ -536,12 +536,12 @@ If such a file is mounted in the image, it will be executed on container startup ```bash docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp \ - -v $PWD/my-startup-script.sh:/etc/container/startup.sh thecodingmachine/php:8.0-v4-cli php your-script.php + -v $PWD/my-startup-script.sh:/etc/container/startup.sh thecodingmachine/php:8.1-v4-cli php your-script.php ``` ## Using the CLI variant -The CLI images (thecodingmachine/php:8.0-v4-cli) expect a command to be passed in parameter. +The CLI images (thecodingmachine/php:8.1-v4-cli) expect a command to be passed in parameter. You should override the Docker "command". Important! You should not override the Docker "entrypoint". @@ -549,7 +549,7 @@ Important! You should not override the Docker "entrypoint". **Usage in a Dockerfile:** ```Dockerfile -FROM thecodingmachine/php:8.0-v4-cli +FROM thecodingmachine/php:8.1-v4-cli CMD ["php", "myprogram.php", "some_param"] ``` @@ -561,7 +561,7 @@ CMD ["php", "myprogram.php", "some_param"] version: '3' services: my_app: - image: thecodingmachine/php:8.0-v4-cli + image: thecodingmachine/php:8.1-v4-cli command: php myprogram.php some_param ``` @@ -581,7 +581,7 @@ This option is the easiest way to go if you are using the image on a development version: '3' services: my_app: - image: thecodingmachine/php:8.0-v4-apache-node16 + image: thecodingmachine/php:8.1-v4-apache-node16 volumes: - ~/.ssh:/home/docker/.ssh ``` @@ -602,7 +602,7 @@ Now, let's write a Dockerfile. **Dockerfile** ```yml -FROM thecodingmachine/php:8.0-v4-apache +FROM thecodingmachine/php:8.1-v4-apache ARG SSH_PRIVATE_KEY ARG SSH_KNOWN_HOSTS @@ -640,7 +640,7 @@ kind: Pod spec: containers: - name: foobar - image: thecodingmachine/php:8.0-v4-apache + image: thecodingmachine/php:8.1-v4-apache securityContext: allowPrivilegeEscalation: true # never use "false" here. ``` @@ -662,7 +662,7 @@ Your `docker-compose.yml` file will typically look like this: version: '3.3' services: php: - image: thecodingmachine/php:8.0-v4-apache + image: thecodingmachine/php:8.1-v4-apache ports: - "80:80" environment: @@ -688,7 +688,7 @@ If for some reason, the container name is not "blackfire", you can customize the version: '3.3' services: php: - image: thecodingmachine/php:8.0-v4-apache + image: thecodingmachine/php:8.1-v4-apache environment: PHP_EXTENSION_BLACKFIRE: 1 BLACKFIRE_AGENT: myblackfire @@ -723,9 +723,27 @@ This command will generate all the files from the "blueprint" templates. You can then test your changes using the `build-and-test.sh` command: ```bash -PHP_VERSION=8.0 BRANCH=v4 VARIANT=apache ./build-and-test.sh +PHP_VERSION=8.1 BRANCH=v4 VARIANT=apache ./build-and-test.sh ``` +### Additional environment in build-and-test.sh + +- BUILDER: either build or buildx depending on your configuration. +Defaults to build +- BLACKFIRE_VERSION: defaults to 1. You can install v2 if you're feeling adventurous by specifying 2 as a value. +- PLATFORM: Docker will default to your architecture for building images. However, if you have QEMU set up in your machine, you can try building for another architecture like linux/arm64 + +Only one platform at a time is supported during the build and test script execution. + +*APPLE SILICON CONSIDERATIONS* + +Filesystem management works differently in Apple's macOS, so, if you're trying to build a linux/arm64 image (that is best suited for using in a M1/M2 Mac than a linux/amd64 one), there's a high likelihood that the filesystem user and permissions with busybox are going to fail. + +Although the test fails, when using the built image, everything works as expected. + +Run a virtual machine with linux/arm64 with Docker installed in it and, then, build and test the image. You'll take advantage of the ARM speed and will also be able to run the unit tests properly. + + ### Adding additional images To add a new version (php, node, apache, ...), please edit the following files : diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 00000000..0f3ecd2e --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,1135 @@ +# DO NOT EDIT THIS FILE Make yours changes in /utils/docker-bake.blueprint.hcl + +group "default" { + targets = [ + + "php81", + "php80", + "php74", + "php73", + "php72", + ] +} + +group "php81" { + targets = [ + "php81-slim-apache", + "php81-apache", + "php81-apache-node16","php81-apache-node14","php81-apache-node12","php81-apache-node10","php81-slim-fpm", + "php81-fpm", + "php81-fpm-node16","php81-fpm-node14","php81-fpm-node12","php81-fpm-node10","php81-slim-cli", + "php81-cli", + "php81-cli-node16","php81-cli-node14","php81-cli-node12","php81-cli-node10", + ] +} +group "php80" { + targets = [ + "php80-slim-apache", + "php80-apache", + "php80-apache-node16","php80-apache-node14","php80-apache-node12","php80-apache-node10","php80-slim-fpm", + "php80-fpm", + "php80-fpm-node16","php80-fpm-node14","php80-fpm-node12","php80-fpm-node10","php80-slim-cli", + "php80-cli", + "php80-cli-node16","php80-cli-node14","php80-cli-node12","php80-cli-node10", + ] +} +group "php74" { + targets = [ + "php74-slim-apache", + "php74-apache", + "php74-apache-node16","php74-apache-node14","php74-apache-node12","php74-apache-node10","php74-slim-fpm", + "php74-fpm", + "php74-fpm-node16","php74-fpm-node14","php74-fpm-node12","php74-fpm-node10","php74-slim-cli", + "php74-cli", + "php74-cli-node16","php74-cli-node14","php74-cli-node12","php74-cli-node10", + ] +} +group "php73" { + targets = [ + "php73-slim-apache", + "php73-apache", + "php73-apache-node16","php73-apache-node14","php73-apache-node12","php73-apache-node10","php73-slim-fpm", + "php73-fpm", + "php73-fpm-node16","php73-fpm-node14","php73-fpm-node12","php73-fpm-node10","php73-slim-cli", + "php73-cli", + "php73-cli-node16","php73-cli-node14","php73-cli-node12","php73-cli-node10", + ] +} +group "php72" { + targets = [ + "php72-slim-apache", + "php72-apache", + "php72-apache-node16","php72-apache-node14","php72-apache-node12","php72-apache-node10","php72-slim-fpm", + "php72-fpm", + "php72-fpm-node16","php72-fpm-node14","php72-fpm-node12","php72-fpm-node10","php72-slim-cli", + "php72-cli", + "php72-cli-node16","php72-cli-node14","php72-cli-node12","php72-cli-node10", + ] +} + +variable "REPO" {default = "thecodingmachine/php"} +variable "TAG" {default = "latest"} +variable "GLOBAL_VERSION" {default = "v4"} + +function "tag" { + params = [PHP_VERSION, VARIANT] + result = [ + "${REPO}:${PHP_VERSION}-${GLOBAL_VERSION}-${VARIANT}", + notequal("latest",TAG) ? "${REPO}:${PHP_VERSION}-${GLOBAL_VERSION}-${VARIANT}:${TAG}": "", + ] +} + +target "default" { + context = "." + args = { + GLOBAL_VERSION = "${GLOBAL_VERSION}" + } + platforms = [ + "linux/amd64", + "linux/arm64" + ] + pull = true + #output = ["customDir"] + #output = ["type=tar,dest=myimage.tar"] + output = ["type=docker"] # load in local docker + #output = ["type=registry"] # push + #output = ["type=image"] # push also ? +} + + +########################### +## PHP 8.1 +########################### +# thecodingmachine/php:8.1-v4-slim-apache +target "php81-slim-apache" { + inherits = ["default"] + tags = tag("8.1", "slim-apache") + dockerfile = "Dockerfile.slim.apache" + args = { + PHP_VERSION = "8.1" + VARIANT = "apache" + } +} + +# thecodingmachine/php:8.1-v4-apache +target "php81-apache" { + inherits = ["default"] + tags = tag("8.1", "apache") + dockerfile = "Dockerfile.apache" + args = { + PHP_VERSION = "8.1" + VARIANT = "apache" + } +} + +# thecodingmachine/php:8.1-v4-apache-node16 +target "php81-apache-node16" { + inherits = ["default"] + tags = tag("8.1", "apache-node16") + dockerfile = "Dockerfile.apache.node16" + args = { + PHP_VERSION = "8.1" + VARIANT = "apache-node16" + } +} + +# thecodingmachine/php:8.1-v4-apache-node14 +target "php81-apache-node14" { + inherits = ["default"] + tags = tag("8.1", "apache-node14") + dockerfile = "Dockerfile.apache.node14" + args = { + PHP_VERSION = "8.1" + VARIANT = "apache-node14" + } +} + +# thecodingmachine/php:8.1-v4-apache-node12 +target "php81-apache-node12" { + inherits = ["default"] + tags = tag("8.1", "apache-node12") + dockerfile = "Dockerfile.apache.node12" + args = { + PHP_VERSION = "8.1" + VARIANT = "apache-node12" + } +} + +# thecodingmachine/php:8.1-v4-apache-node10 +target "php81-apache-node10" { + inherits = ["default"] + tags = tag("8.1", "apache-node10") + dockerfile = "Dockerfile.apache.node10" + args = { + PHP_VERSION = "8.1" + VARIANT = "apache-node10" + } +} + +########################### +## PHP 8.1 +########################### +# thecodingmachine/php:8.1-v4-slim-fpm +target "php81-slim-fpm" { + inherits = ["default"] + tags = tag("8.1", "slim-fpm") + dockerfile = "Dockerfile.slim.fpm" + args = { + PHP_VERSION = "8.1" + VARIANT = "fpm" + } +} + +# thecodingmachine/php:8.1-v4-fpm +target "php81-fpm" { + inherits = ["default"] + tags = tag("8.1", "fpm") + dockerfile = "Dockerfile.fpm" + args = { + PHP_VERSION = "8.1" + VARIANT = "fpm" + } +} + +# thecodingmachine/php:8.1-v4-fpm-node16 +target "php81-fpm-node16" { + inherits = ["default"] + tags = tag("8.1", "fpm-node16") + dockerfile = "Dockerfile.fpm.node16" + args = { + PHP_VERSION = "8.1" + VARIANT = "fpm-node16" + } +} + +# thecodingmachine/php:8.1-v4-fpm-node14 +target "php81-fpm-node14" { + inherits = ["default"] + tags = tag("8.1", "fpm-node14") + dockerfile = "Dockerfile.fpm.node14" + args = { + PHP_VERSION = "8.1" + VARIANT = "fpm-node14" + } +} + +# thecodingmachine/php:8.1-v4-fpm-node12 +target "php81-fpm-node12" { + inherits = ["default"] + tags = tag("8.1", "fpm-node12") + dockerfile = "Dockerfile.fpm.node12" + args = { + PHP_VERSION = "8.1" + VARIANT = "fpm-node12" + } +} + +# thecodingmachine/php:8.1-v4-fpm-node10 +target "php81-fpm-node10" { + inherits = ["default"] + tags = tag("8.1", "fpm-node10") + dockerfile = "Dockerfile.fpm.node10" + args = { + PHP_VERSION = "8.1" + VARIANT = "fpm-node10" + } +} + +########################### +## PHP 8.1 +########################### +# thecodingmachine/php:8.1-v4-slim-cli +target "php81-slim-cli" { + inherits = ["default"] + tags = tag("8.1", "slim-cli") + dockerfile = "Dockerfile.slim.cli" + args = { + PHP_VERSION = "8.1" + VARIANT = "cli" + } +} + +# thecodingmachine/php:8.1-v4-cli +target "php81-cli" { + inherits = ["default"] + tags = tag("8.1", "cli") + dockerfile = "Dockerfile.cli" + args = { + PHP_VERSION = "8.1" + VARIANT = "cli" + } +} + +# thecodingmachine/php:8.1-v4-cli-node16 +target "php81-cli-node16" { + inherits = ["default"] + tags = tag("8.1", "cli-node16") + dockerfile = "Dockerfile.cli.node16" + args = { + PHP_VERSION = "8.1" + VARIANT = "cli-node16" + } +} + +# thecodingmachine/php:8.1-v4-cli-node14 +target "php81-cli-node14" { + inherits = ["default"] + tags = tag("8.1", "cli-node14") + dockerfile = "Dockerfile.cli.node14" + args = { + PHP_VERSION = "8.1" + VARIANT = "cli-node14" + } +} + +# thecodingmachine/php:8.1-v4-cli-node12 +target "php81-cli-node12" { + inherits = ["default"] + tags = tag("8.1", "cli-node12") + dockerfile = "Dockerfile.cli.node12" + args = { + PHP_VERSION = "8.1" + VARIANT = "cli-node12" + } +} + +# thecodingmachine/php:8.1-v4-cli-node10 +target "php81-cli-node10" { + inherits = ["default"] + tags = tag("8.1", "cli-node10") + dockerfile = "Dockerfile.cli.node10" + args = { + PHP_VERSION = "8.1" + VARIANT = "cli-node10" + } +} + +########################### +## PHP 8.0 +########################### +# thecodingmachine/php:8.0-v4-slim-apache +target "php80-slim-apache" { + inherits = ["default"] + tags = tag("8.0", "slim-apache") + dockerfile = "Dockerfile.slim.apache" + args = { + PHP_VERSION = "8.0" + VARIANT = "apache" + } +} + +# thecodingmachine/php:8.0-v4-apache +target "php80-apache" { + inherits = ["default"] + tags = tag("8.0", "apache") + dockerfile = "Dockerfile.apache" + args = { + PHP_VERSION = "8.0" + VARIANT = "apache" + } +} + +# thecodingmachine/php:8.0-v4-apache-node16 +target "php80-apache-node16" { + inherits = ["default"] + tags = tag("8.0", "apache-node16") + dockerfile = "Dockerfile.apache.node16" + args = { + PHP_VERSION = "8.0" + VARIANT = "apache-node16" + } +} + +# thecodingmachine/php:8.0-v4-apache-node14 +target "php80-apache-node14" { + inherits = ["default"] + tags = tag("8.0", "apache-node14") + dockerfile = "Dockerfile.apache.node14" + args = { + PHP_VERSION = "8.0" + VARIANT = "apache-node14" + } +} + +# thecodingmachine/php:8.0-v4-apache-node12 +target "php80-apache-node12" { + inherits = ["default"] + tags = tag("8.0", "apache-node12") + dockerfile = "Dockerfile.apache.node12" + args = { + PHP_VERSION = "8.0" + VARIANT = "apache-node12" + } +} + +# thecodingmachine/php:8.0-v4-apache-node10 +target "php80-apache-node10" { + inherits = ["default"] + tags = tag("8.0", "apache-node10") + dockerfile = "Dockerfile.apache.node10" + args = { + PHP_VERSION = "8.0" + VARIANT = "apache-node10" + } +} + +########################### +## PHP 8.0 +########################### +# thecodingmachine/php:8.0-v4-slim-fpm +target "php80-slim-fpm" { + inherits = ["default"] + tags = tag("8.0", "slim-fpm") + dockerfile = "Dockerfile.slim.fpm" + args = { + PHP_VERSION = "8.0" + VARIANT = "fpm" + } +} + +# thecodingmachine/php:8.0-v4-fpm +target "php80-fpm" { + inherits = ["default"] + tags = tag("8.0", "fpm") + dockerfile = "Dockerfile.fpm" + args = { + PHP_VERSION = "8.0" + VARIANT = "fpm" + } +} + +# thecodingmachine/php:8.0-v4-fpm-node16 +target "php80-fpm-node16" { + inherits = ["default"] + tags = tag("8.0", "fpm-node16") + dockerfile = "Dockerfile.fpm.node16" + args = { + PHP_VERSION = "8.0" + VARIANT = "fpm-node16" + } +} + +# thecodingmachine/php:8.0-v4-fpm-node14 +target "php80-fpm-node14" { + inherits = ["default"] + tags = tag("8.0", "fpm-node14") + dockerfile = "Dockerfile.fpm.node14" + args = { + PHP_VERSION = "8.0" + VARIANT = "fpm-node14" + } +} + +# thecodingmachine/php:8.0-v4-fpm-node12 +target "php80-fpm-node12" { + inherits = ["default"] + tags = tag("8.0", "fpm-node12") + dockerfile = "Dockerfile.fpm.node12" + args = { + PHP_VERSION = "8.0" + VARIANT = "fpm-node12" + } +} + +# thecodingmachine/php:8.0-v4-fpm-node10 +target "php80-fpm-node10" { + inherits = ["default"] + tags = tag("8.0", "fpm-node10") + dockerfile = "Dockerfile.fpm.node10" + args = { + PHP_VERSION = "8.0" + VARIANT = "fpm-node10" + } +} + +########################### +## PHP 8.0 +########################### +# thecodingmachine/php:8.0-v4-slim-cli +target "php80-slim-cli" { + inherits = ["default"] + tags = tag("8.0", "slim-cli") + dockerfile = "Dockerfile.slim.cli" + args = { + PHP_VERSION = "8.0" + VARIANT = "cli" + } +} + +# thecodingmachine/php:8.0-v4-cli +target "php80-cli" { + inherits = ["default"] + tags = tag("8.0", "cli") + dockerfile = "Dockerfile.cli" + args = { + PHP_VERSION = "8.0" + VARIANT = "cli" + } +} + +# thecodingmachine/php:8.0-v4-cli-node16 +target "php80-cli-node16" { + inherits = ["default"] + tags = tag("8.0", "cli-node16") + dockerfile = "Dockerfile.cli.node16" + args = { + PHP_VERSION = "8.0" + VARIANT = "cli-node16" + } +} + +# thecodingmachine/php:8.0-v4-cli-node14 +target "php80-cli-node14" { + inherits = ["default"] + tags = tag("8.0", "cli-node14") + dockerfile = "Dockerfile.cli.node14" + args = { + PHP_VERSION = "8.0" + VARIANT = "cli-node14" + } +} + +# thecodingmachine/php:8.0-v4-cli-node12 +target "php80-cli-node12" { + inherits = ["default"] + tags = tag("8.0", "cli-node12") + dockerfile = "Dockerfile.cli.node12" + args = { + PHP_VERSION = "8.0" + VARIANT = "cli-node12" + } +} + +# thecodingmachine/php:8.0-v4-cli-node10 +target "php80-cli-node10" { + inherits = ["default"] + tags = tag("8.0", "cli-node10") + dockerfile = "Dockerfile.cli.node10" + args = { + PHP_VERSION = "8.0" + VARIANT = "cli-node10" + } +} + +########################### +## PHP 7.4 +########################### +# thecodingmachine/php:7.4-v4-slim-apache +target "php74-slim-apache" { + inherits = ["default"] + tags = tag("7.4", "slim-apache") + dockerfile = "Dockerfile.slim.apache" + args = { + PHP_VERSION = "7.4" + VARIANT = "apache" + } +} + +# thecodingmachine/php:7.4-v4-apache +target "php74-apache" { + inherits = ["default"] + tags = tag("7.4", "apache") + dockerfile = "Dockerfile.apache" + args = { + PHP_VERSION = "7.4" + VARIANT = "apache" + } +} + +# thecodingmachine/php:7.4-v4-apache-node16 +target "php74-apache-node16" { + inherits = ["default"] + tags = tag("7.4", "apache-node16") + dockerfile = "Dockerfile.apache.node16" + args = { + PHP_VERSION = "7.4" + VARIANT = "apache-node16" + } +} + +# thecodingmachine/php:7.4-v4-apache-node14 +target "php74-apache-node14" { + inherits = ["default"] + tags = tag("7.4", "apache-node14") + dockerfile = "Dockerfile.apache.node14" + args = { + PHP_VERSION = "7.4" + VARIANT = "apache-node14" + } +} + +# thecodingmachine/php:7.4-v4-apache-node12 +target "php74-apache-node12" { + inherits = ["default"] + tags = tag("7.4", "apache-node12") + dockerfile = "Dockerfile.apache.node12" + args = { + PHP_VERSION = "7.4" + VARIANT = "apache-node12" + } +} + +# thecodingmachine/php:7.4-v4-apache-node10 +target "php74-apache-node10" { + inherits = ["default"] + tags = tag("7.4", "apache-node10") + dockerfile = "Dockerfile.apache.node10" + args = { + PHP_VERSION = "7.4" + VARIANT = "apache-node10" + } +} + +########################### +## PHP 7.4 +########################### +# thecodingmachine/php:7.4-v4-slim-fpm +target "php74-slim-fpm" { + inherits = ["default"] + tags = tag("7.4", "slim-fpm") + dockerfile = "Dockerfile.slim.fpm" + args = { + PHP_VERSION = "7.4" + VARIANT = "fpm" + } +} + +# thecodingmachine/php:7.4-v4-fpm +target "php74-fpm" { + inherits = ["default"] + tags = tag("7.4", "fpm") + dockerfile = "Dockerfile.fpm" + args = { + PHP_VERSION = "7.4" + VARIANT = "fpm" + } +} + +# thecodingmachine/php:7.4-v4-fpm-node16 +target "php74-fpm-node16" { + inherits = ["default"] + tags = tag("7.4", "fpm-node16") + dockerfile = "Dockerfile.fpm.node16" + args = { + PHP_VERSION = "7.4" + VARIANT = "fpm-node16" + } +} + +# thecodingmachine/php:7.4-v4-fpm-node14 +target "php74-fpm-node14" { + inherits = ["default"] + tags = tag("7.4", "fpm-node14") + dockerfile = "Dockerfile.fpm.node14" + args = { + PHP_VERSION = "7.4" + VARIANT = "fpm-node14" + } +} + +# thecodingmachine/php:7.4-v4-fpm-node12 +target "php74-fpm-node12" { + inherits = ["default"] + tags = tag("7.4", "fpm-node12") + dockerfile = "Dockerfile.fpm.node12" + args = { + PHP_VERSION = "7.4" + VARIANT = "fpm-node12" + } +} + +# thecodingmachine/php:7.4-v4-fpm-node10 +target "php74-fpm-node10" { + inherits = ["default"] + tags = tag("7.4", "fpm-node10") + dockerfile = "Dockerfile.fpm.node10" + args = { + PHP_VERSION = "7.4" + VARIANT = "fpm-node10" + } +} + +########################### +## PHP 7.4 +########################### +# thecodingmachine/php:7.4-v4-slim-cli +target "php74-slim-cli" { + inherits = ["default"] + tags = tag("7.4", "slim-cli") + dockerfile = "Dockerfile.slim.cli" + args = { + PHP_VERSION = "7.4" + VARIANT = "cli" + } +} + +# thecodingmachine/php:7.4-v4-cli +target "php74-cli" { + inherits = ["default"] + tags = tag("7.4", "cli") + dockerfile = "Dockerfile.cli" + args = { + PHP_VERSION = "7.4" + VARIANT = "cli" + } +} + +# thecodingmachine/php:7.4-v4-cli-node16 +target "php74-cli-node16" { + inherits = ["default"] + tags = tag("7.4", "cli-node16") + dockerfile = "Dockerfile.cli.node16" + args = { + PHP_VERSION = "7.4" + VARIANT = "cli-node16" + } +} + +# thecodingmachine/php:7.4-v4-cli-node14 +target "php74-cli-node14" { + inherits = ["default"] + tags = tag("7.4", "cli-node14") + dockerfile = "Dockerfile.cli.node14" + args = { + PHP_VERSION = "7.4" + VARIANT = "cli-node14" + } +} + +# thecodingmachine/php:7.4-v4-cli-node12 +target "php74-cli-node12" { + inherits = ["default"] + tags = tag("7.4", "cli-node12") + dockerfile = "Dockerfile.cli.node12" + args = { + PHP_VERSION = "7.4" + VARIANT = "cli-node12" + } +} + +# thecodingmachine/php:7.4-v4-cli-node10 +target "php74-cli-node10" { + inherits = ["default"] + tags = tag("7.4", "cli-node10") + dockerfile = "Dockerfile.cli.node10" + args = { + PHP_VERSION = "7.4" + VARIANT = "cli-node10" + } +} + +########################### +## PHP 7.3 +########################### +# thecodingmachine/php:7.3-v4-slim-apache +target "php73-slim-apache" { + inherits = ["default"] + tags = tag("7.3", "slim-apache") + dockerfile = "Dockerfile.slim.apache" + args = { + PHP_VERSION = "7.3" + VARIANT = "apache" + } +} + +# thecodingmachine/php:7.3-v4-apache +target "php73-apache" { + inherits = ["default"] + tags = tag("7.3", "apache") + dockerfile = "Dockerfile.apache" + args = { + PHP_VERSION = "7.3" + VARIANT = "apache" + } +} + +# thecodingmachine/php:7.3-v4-apache-node16 +target "php73-apache-node16" { + inherits = ["default"] + tags = tag("7.3", "apache-node16") + dockerfile = "Dockerfile.apache.node16" + args = { + PHP_VERSION = "7.3" + VARIANT = "apache-node16" + } +} + +# thecodingmachine/php:7.3-v4-apache-node14 +target "php73-apache-node14" { + inherits = ["default"] + tags = tag("7.3", "apache-node14") + dockerfile = "Dockerfile.apache.node14" + args = { + PHP_VERSION = "7.3" + VARIANT = "apache-node14" + } +} + +# thecodingmachine/php:7.3-v4-apache-node12 +target "php73-apache-node12" { + inherits = ["default"] + tags = tag("7.3", "apache-node12") + dockerfile = "Dockerfile.apache.node12" + args = { + PHP_VERSION = "7.3" + VARIANT = "apache-node12" + } +} + +# thecodingmachine/php:7.3-v4-apache-node10 +target "php73-apache-node10" { + inherits = ["default"] + tags = tag("7.3", "apache-node10") + dockerfile = "Dockerfile.apache.node10" + args = { + PHP_VERSION = "7.3" + VARIANT = "apache-node10" + } +} + +########################### +## PHP 7.3 +########################### +# thecodingmachine/php:7.3-v4-slim-fpm +target "php73-slim-fpm" { + inherits = ["default"] + tags = tag("7.3", "slim-fpm") + dockerfile = "Dockerfile.slim.fpm" + args = { + PHP_VERSION = "7.3" + VARIANT = "fpm" + } +} + +# thecodingmachine/php:7.3-v4-fpm +target "php73-fpm" { + inherits = ["default"] + tags = tag("7.3", "fpm") + dockerfile = "Dockerfile.fpm" + args = { + PHP_VERSION = "7.3" + VARIANT = "fpm" + } +} + +# thecodingmachine/php:7.3-v4-fpm-node16 +target "php73-fpm-node16" { + inherits = ["default"] + tags = tag("7.3", "fpm-node16") + dockerfile = "Dockerfile.fpm.node16" + args = { + PHP_VERSION = "7.3" + VARIANT = "fpm-node16" + } +} + +# thecodingmachine/php:7.3-v4-fpm-node14 +target "php73-fpm-node14" { + inherits = ["default"] + tags = tag("7.3", "fpm-node14") + dockerfile = "Dockerfile.fpm.node14" + args = { + PHP_VERSION = "7.3" + VARIANT = "fpm-node14" + } +} + +# thecodingmachine/php:7.3-v4-fpm-node12 +target "php73-fpm-node12" { + inherits = ["default"] + tags = tag("7.3", "fpm-node12") + dockerfile = "Dockerfile.fpm.node12" + args = { + PHP_VERSION = "7.3" + VARIANT = "fpm-node12" + } +} + +# thecodingmachine/php:7.3-v4-fpm-node10 +target "php73-fpm-node10" { + inherits = ["default"] + tags = tag("7.3", "fpm-node10") + dockerfile = "Dockerfile.fpm.node10" + args = { + PHP_VERSION = "7.3" + VARIANT = "fpm-node10" + } +} + +########################### +## PHP 7.3 +########################### +# thecodingmachine/php:7.3-v4-slim-cli +target "php73-slim-cli" { + inherits = ["default"] + tags = tag("7.3", "slim-cli") + dockerfile = "Dockerfile.slim.cli" + args = { + PHP_VERSION = "7.3" + VARIANT = "cli" + } +} + +# thecodingmachine/php:7.3-v4-cli +target "php73-cli" { + inherits = ["default"] + tags = tag("7.3", "cli") + dockerfile = "Dockerfile.cli" + args = { + PHP_VERSION = "7.3" + VARIANT = "cli" + } +} + +# thecodingmachine/php:7.3-v4-cli-node16 +target "php73-cli-node16" { + inherits = ["default"] + tags = tag("7.3", "cli-node16") + dockerfile = "Dockerfile.cli.node16" + args = { + PHP_VERSION = "7.3" + VARIANT = "cli-node16" + } +} + +# thecodingmachine/php:7.3-v4-cli-node14 +target "php73-cli-node14" { + inherits = ["default"] + tags = tag("7.3", "cli-node14") + dockerfile = "Dockerfile.cli.node14" + args = { + PHP_VERSION = "7.3" + VARIANT = "cli-node14" + } +} + +# thecodingmachine/php:7.3-v4-cli-node12 +target "php73-cli-node12" { + inherits = ["default"] + tags = tag("7.3", "cli-node12") + dockerfile = "Dockerfile.cli.node12" + args = { + PHP_VERSION = "7.3" + VARIANT = "cli-node12" + } +} + +# thecodingmachine/php:7.3-v4-cli-node10 +target "php73-cli-node10" { + inherits = ["default"] + tags = tag("7.3", "cli-node10") + dockerfile = "Dockerfile.cli.node10" + args = { + PHP_VERSION = "7.3" + VARIANT = "cli-node10" + } +} + +########################### +## PHP 7.2 +########################### +# thecodingmachine/php:7.2-v4-slim-apache +target "php72-slim-apache" { + inherits = ["default"] + tags = tag("7.2", "slim-apache") + dockerfile = "Dockerfile.slim.apache" + args = { + PHP_VERSION = "7.2" + VARIANT = "apache" + } +} + +# thecodingmachine/php:7.2-v4-apache +target "php72-apache" { + inherits = ["default"] + tags = tag("7.2", "apache") + dockerfile = "Dockerfile.apache" + args = { + PHP_VERSION = "7.2" + VARIANT = "apache" + } +} + +# thecodingmachine/php:7.2-v4-apache-node16 +target "php72-apache-node16" { + inherits = ["default"] + tags = tag("7.2", "apache-node16") + dockerfile = "Dockerfile.apache.node16" + args = { + PHP_VERSION = "7.2" + VARIANT = "apache-node16" + } +} + +# thecodingmachine/php:7.2-v4-apache-node14 +target "php72-apache-node14" { + inherits = ["default"] + tags = tag("7.2", "apache-node14") + dockerfile = "Dockerfile.apache.node14" + args = { + PHP_VERSION = "7.2" + VARIANT = "apache-node14" + } +} + +# thecodingmachine/php:7.2-v4-apache-node12 +target "php72-apache-node12" { + inherits = ["default"] + tags = tag("7.2", "apache-node12") + dockerfile = "Dockerfile.apache.node12" + args = { + PHP_VERSION = "7.2" + VARIANT = "apache-node12" + } +} + +# thecodingmachine/php:7.2-v4-apache-node10 +target "php72-apache-node10" { + inherits = ["default"] + tags = tag("7.2", "apache-node10") + dockerfile = "Dockerfile.apache.node10" + args = { + PHP_VERSION = "7.2" + VARIANT = "apache-node10" + } +} + +########################### +## PHP 7.2 +########################### +# thecodingmachine/php:7.2-v4-slim-fpm +target "php72-slim-fpm" { + inherits = ["default"] + tags = tag("7.2", "slim-fpm") + dockerfile = "Dockerfile.slim.fpm" + args = { + PHP_VERSION = "7.2" + VARIANT = "fpm" + } +} + +# thecodingmachine/php:7.2-v4-fpm +target "php72-fpm" { + inherits = ["default"] + tags = tag("7.2", "fpm") + dockerfile = "Dockerfile.fpm" + args = { + PHP_VERSION = "7.2" + VARIANT = "fpm" + } +} + +# thecodingmachine/php:7.2-v4-fpm-node16 +target "php72-fpm-node16" { + inherits = ["default"] + tags = tag("7.2", "fpm-node16") + dockerfile = "Dockerfile.fpm.node16" + args = { + PHP_VERSION = "7.2" + VARIANT = "fpm-node16" + } +} + +# thecodingmachine/php:7.2-v4-fpm-node14 +target "php72-fpm-node14" { + inherits = ["default"] + tags = tag("7.2", "fpm-node14") + dockerfile = "Dockerfile.fpm.node14" + args = { + PHP_VERSION = "7.2" + VARIANT = "fpm-node14" + } +} + +# thecodingmachine/php:7.2-v4-fpm-node12 +target "php72-fpm-node12" { + inherits = ["default"] + tags = tag("7.2", "fpm-node12") + dockerfile = "Dockerfile.fpm.node12" + args = { + PHP_VERSION = "7.2" + VARIANT = "fpm-node12" + } +} + +# thecodingmachine/php:7.2-v4-fpm-node10 +target "php72-fpm-node10" { + inherits = ["default"] + tags = tag("7.2", "fpm-node10") + dockerfile = "Dockerfile.fpm.node10" + args = { + PHP_VERSION = "7.2" + VARIANT = "fpm-node10" + } +} + +########################### +## PHP 7.2 +########################### +# thecodingmachine/php:7.2-v4-slim-cli +target "php72-slim-cli" { + inherits = ["default"] + tags = tag("7.2", "slim-cli") + dockerfile = "Dockerfile.slim.cli" + args = { + PHP_VERSION = "7.2" + VARIANT = "cli" + } +} + +# thecodingmachine/php:7.2-v4-cli +target "php72-cli" { + inherits = ["default"] + tags = tag("7.2", "cli") + dockerfile = "Dockerfile.cli" + args = { + PHP_VERSION = "7.2" + VARIANT = "cli" + } +} + +# thecodingmachine/php:7.2-v4-cli-node16 +target "php72-cli-node16" { + inherits = ["default"] + tags = tag("7.2", "cli-node16") + dockerfile = "Dockerfile.cli.node16" + args = { + PHP_VERSION = "7.2" + VARIANT = "cli-node16" + } +} + +# thecodingmachine/php:7.2-v4-cli-node14 +target "php72-cli-node14" { + inherits = ["default"] + tags = tag("7.2", "cli-node14") + dockerfile = "Dockerfile.cli.node14" + args = { + PHP_VERSION = "7.2" + VARIANT = "cli-node14" + } +} + +# thecodingmachine/php:7.2-v4-cli-node12 +target "php72-cli-node12" { + inherits = ["default"] + tags = tag("7.2", "cli-node12") + dockerfile = "Dockerfile.cli.node12" + args = { + PHP_VERSION = "7.2" + VARIANT = "cli-node12" + } +} + +# thecodingmachine/php:7.2-v4-cli-node10 +target "php72-cli-node10" { + inherits = ["default"] + tags = tag("7.2", "cli-node10") + dockerfile = "Dockerfile.cli.node10" + args = { + PHP_VERSION = "7.2" + VARIANT = "cli-node10" + } +} + + diff --git a/extensions/core/blackfire/install.sh b/extensions/core/blackfire/install.sh index b76b0739..3e58833b 100755 --- a/extensions/core/blackfire/install.sh +++ b/extensions/core/blackfire/install.sh @@ -5,19 +5,49 @@ set -ex # Install Blackfire version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") -curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version -mkdir -p /tmp/blackfire -tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire -mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so -rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz - -echo "extension=blackfire.so" > /etc/php/${PHP_VERSION}/mods-available/blackfire.ini -# Adding this in the list of Ubuntu extensions because we use that list as a base for the modules list. -# TODO: question: cannot we use /etc/php/mods-available instead??? -touch /var/lib/php/modules/${PHP_VERSION}/registry/blackfire - -# Install Blackfire CLI tool -mkdir -p /tmp/blackfire -curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire -mv /tmp/blackfire/blackfire /usr/bin/blackfire -rm -Rf /tmp/blackfire + +if [[ -z "${BLACKFIRE_VERSION}" ]]; then + echo "Blackfire version is not set in the environment variables. Exiting!" + exit 1 +fi + +# Let's make it flexible: for those who want to be safe, the image will be built with v1 +# Now if you build the image yourself, you can build it with v2, this way everyone gets happy :) + +mkdir /tmp/blackfire + +# Todo: Maybe version the Blackfire version by environment variable? :) + +if [ $BLACKFIRE_VERSION == "1" ]; then + echo "Installing Blackfire version 1" + # curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v2/releases/probe/php/linux/amd64/$version + curl -o /tmp/blackfire/blackfire.so "https://packages.blackfire.io/binaries/blackfire-php/1.78.0/blackfire-php-$CONTAINER_OS"_"$CONTAINER_ARCH-php-$version.so" + mv /tmp/blackfire/blackfire.so $(php -r "echo ini_get('extension_dir');")/blackfire.so + echo "extension=blackfire.so" > /etc/php/${PHP_VERSION}/mods-available/blackfire.ini + + # Adding this in the list of Ubuntu extensions because we use that list as a base for the modules list. + # TODO: question: cannot we use /etc/php/mods-available instead??? + touch /var/lib/php/modules/${PHP_VERSION}/registry/blackfire + # curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire + curl -o /tmp/blackfire/blackfire "https://packages.blackfire.io/binaries/blackfire-agent/1.50.0/blackfire-cli-$CONTAINER_OS"_"$CONTAINER_ARCH" + chmod +x /tmp/blackfire/blackfire + mv /tmp/blackfire/blackfire /usr/bin/blackfire + rm -Rf /tmp/blackfire + +elif [ $BLACKFIRE_VERSION == "2" ]; then + echo "Installing Blackfire version 2..." + + curl -o /tmp/blackfire/blackfire.so "https://packages.blackfire.io/binaries/blackfire-php/1.78.0/blackfire-php-$CONTAINER_OS"_"$CONTAINER_ARCH-php-$version.so" + mv /tmp/blackfire/blackfire.so $(php -r "echo ini_get('extension_dir');")/blackfire.so + echo "extension=blackfire.so" > /etc/php/${PHP_VERSION}/mods-available/blackfire.ini + touch /var/lib/php/modules/${PHP_VERSION}/registry/blackfire + curl -o /tmp/blackfire-cli.tar.gz "https://packages.blackfire.io/binaries/blackfire/2.10.0/blackfire-"$CONTAINER_OS"_"$CONTAINER_ARCH".tar.gz" + tar zxpf /tmp/blackfire-cli.tar.gz -C /tmp/blackfire + mv /tmp/blackfire/blackfire /usr/bin/blackfire + + rm -Rf /tmp/blackfire +else + echo "Blackfire version in environment variable is either empty or the value is invalid" + echo "Value: '$BLACKFIRE_VERSION'" + exit 1 +fi \ No newline at end of file diff --git a/images.yml b/images.yml deleted file mode 100644 index e9826d24..00000000 --- a/images.yml +++ /dev/null @@ -1 +0,0 @@ -php_version: "8.0" diff --git a/orbit-images.yml b/orbit-images.yml new file mode 100644 index 00000000..44e9f54c --- /dev/null +++ b/orbit-images.yml @@ -0,0 +1 @@ +php_version: "8.1" diff --git a/orbit-payload.yml b/orbit-payload.yml index a9564dcb..c051f31e 100644 --- a/orbit-payload.yml +++ b/orbit-payload.yml @@ -1,4 +1,4 @@ payload: - key: Images - value: images.yml \ No newline at end of file + value: orbit-images.yml \ No newline at end of file diff --git a/orbit.yml b/orbit.yml index 0af583a3..d55d70f8 100644 --- a/orbit.yml +++ b/orbit.yml @@ -37,4 +37,11 @@ tasks: - orbit generate -f utils/Dockerfile.node.blueprint -o Dockerfile.fpm.node12 -p "variant,fpm;node_version,12" - orbit generate -f utils/Dockerfile.node.blueprint -o Dockerfile.fpm.node14 -p "variant,fpm;node_version,14" - orbit generate -f utils/Dockerfile.node.blueprint -o Dockerfile.fpm.node16 -p "variant,fpm;node_version,16" - - orbit generate -f utils/README.blueprint.md -o README.md \ No newline at end of file + - |- + sed -i '1i\# DO NOT EDIT THIS FILE : Make yours changes in /utils/Dockerfile.*.blueprint)' Dockerfile.* + - orbit generate -f utils/README.blueprint.md -o README.md + - |- + sed -i '1i\[DO NOT EDIT THIS FILE]: <> (Make yours changes in /utils/README.blueprint.md)' README.md + - orbit generate -f utils/docker-bake.blueprint.hcl -o docker-bake.hcl + - |- + sed -i '1i\# DO NOT EDIT THIS FILE Make yours changes in /utils/docker-bake.blueprint.hcl' docker-bake.hcl \ No newline at end of file diff --git a/build-and-test.sh b/test-image.sh similarity index 84% rename from build-and-test.sh rename to test-image.sh index 5f5938f5..18f73328 100755 --- a/build-and-test.sh +++ b/test-image.sh @@ -9,6 +9,9 @@ failure() { } trap 'failure ${LINENO} "$BASH_COMMAND"' ERR +# Use either docker's 'build' command or 'buildx ' +export BUILDTOOL="buildx build --load --platform=${PLATFORM:-$(uname -p)}" + # Let's replace the "." by a "-" with some bash magic export BRANCH_VARIANT="${VARIANT//./-}" @@ -17,12 +20,10 @@ export DOCKER_BUILDKIT=1 # Force use of BuildKit export BUILDKIT_STEP_LOG_MAX_SIZE=10485760 # output log limit fixed to 10MiB # Let's build the "slim" image. -docker build -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-slim-${BRANCH_VARIANT}" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.slim.${VARIANT}" . - -# Post build unit tests +docker $BUILDTOOL -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-slim-${BRANCH_VARIANT}" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" --build-arg BLACKFIRE_VERSION="${BLACKFIRE_VERSION}" -f "Dockerfile.slim.${VARIANT}" . # Let's check that the extensions can be built using the "ONBUILD" statement -docker build -t test/slim_onbuild --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg BRANCH="$BRANCH" --build-arg BRANCH_VARIANT="$BRANCH_VARIANT" tests/slim_onbuild +docker $BUILDTOOL -t test/slim_onbuild --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg BRANCH="$BRANCH" --build-arg BRANCH_VARIANT="$BRANCH_VARIANT" tests/slim_onbuild # This should run ok (the sudo disable environment variables but call to composer proxy does not trigger PHP ini file regeneration) docker run --rm test/slim_onbuild php -m | grep sockets docker run --rm test/slim_onbuild php -m | grep pdo_pgsql @@ -30,9 +31,10 @@ docker run --rm test/slim_onbuild php -m | grep pdo_sqlite docker rmi test/slim_onbuild # Let's check that the extensions are available for composer using "ARG PHP_EXTENSIONS" statement: -docker build -t test/slim_onbuild_composer --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg BRANCH="$BRANCH" --build-arg BRANCH_VARIANT="$BRANCH_VARIANT" tests/slim_onbuild_composer +docker $BUILDTOOL -t test/slim_onbuild_composer --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg BRANCH="$BRANCH" --build-arg BRANCH_VARIANT="$BRANCH_VARIANT" tests/slim_onbuild_composer docker rmi test/slim_onbuild_composer +echo "Running post-build unit tests" # Post build unit tests if [[ $VARIANT == cli* ]]; then CONTAINER_CWD=/usr/src/app; else CONTAINER_CWD=/var/www/html; fi # Default user is 1000 @@ -60,15 +62,15 @@ RESULT="$(docker run --rm -v "$(pwd)"/user33:$CONTAINER_CWD "thecodingmachine/ph RESULT="$(docker run --rm -v "$(pwd)"/user33:$CONTAINER_CWD "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-slim-${BRANCH_VARIANT}" composer update -vvv)" docker run --rm -v "$(pwd)":/mnt busybox rm -rf /mnt/user33 -# Let's check that mbstring is enabled by default (they are compiled in PHP) +#Let's check that mbstring is enabled by default (they are compiled in PHP) docker run --rm "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-slim-${BRANCH_VARIANT}" php -m | grep mbstring docker run --rm "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-slim-${BRANCH_VARIANT}" php -m | grep PDO -#docker run --rm "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-slim-${BRANCH_VARIANT}" php -m | grep pdo_sqlite +# SQLite is disabled +# docker run --rm "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-slim-${BRANCH_VARIANT}" php -m | grep pdo_sqlite if [[ $VARIANT == apache* ]]; then # Test if environment variables are passed to PHP DOCKER_CID="$(docker run --rm -e MYVAR=foo -p "81:80" -d -v "$(pwd)":/var/www/html "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-slim-${BRANCH_VARIANT}")" - # Let's wait for Apache to start sleep 5 @@ -165,7 +167,7 @@ RESULT="$(docker run --rm "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-slim-${ ################################# # Let's build the "fat" image ################################# -docker build -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}" . +docker $BUILDTOOL -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}" . # Let's check that the crons are actually sending logs in the right place RESULT="$(docker run --rm -e CRON_SCHEDULE_1="* * * * * * *" -e CRON_COMMAND_1="(>&1 echo 'foobar')" "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}" sleep 1 2>&1 | grep -oP 'msg=foobar' | head -n1)" @@ -202,12 +204,11 @@ if [[ "${PHP_VERSION}" != "8.1" ]]; then # Tests that blackfire + xdebug will output an error RESULT="$(docker run --rm -e PHP_EXTENSION_XDEBUG=1 -e PHP_EXTENSION_BLACKFIRE=1 "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}" php -v 2>&1 | grep 'WARNING: Both Blackfire and Xdebug are enabled. This is not recommended as the PHP engine may not behave as expected. You should strongly consider disabling Xdebug or Blackfire.')" [[ "$RESULT" == "WARNING: Both Blackfire and Xdebug are enabled. This is not recommended as the PHP engine may not behave as expected. You should strongly consider disabling Xdebug or Blackfire." ]] - # Check that blackfire can be enabled docker run --rm -e PHP_EXTENSION_BLACKFIRE=1 "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}" php -m | grep blackfire fi # Let's check that the extensions are enabled when composer is run -docker build -t test/composer_with_gd --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg BRANCH="$BRANCH" --build-arg BRANCH_VARIANT="$BRANCH_VARIANT" tests/composer +docker $BUILDTOOL -t test/composer_with_gd --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg BRANCH="$BRANCH" --build-arg BRANCH_VARIANT="$BRANCH_VARIANT" tests/composer # This should run ok (the sudo disables environment variables but call to composer proxy does not trigger PHP ini file regeneration) docker run --rm test/composer_with_gd sudo composer update @@ -216,9 +217,9 @@ docker rmi test/composer_with_gd ################################# # Let's build the "node" images ################################# -docker build -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node10" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node10" . -docker build -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node12" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node12" . -docker build -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node14" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node14" . -docker build -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node16" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node16" . +docker $BUILDTOOL -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node10" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node10" . +docker $BUILDTOOL -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node12" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node12" . +docker $BUILDTOOL -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node14" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node14" . +docker $BUILDTOOL -t "thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}-node16" --build-arg PHP_VERSION="${PHP_VERSION}" --build-arg GLOBAL_VERSION="${BRANCH}" -f "Dockerfile.${VARIANT}.node16" . echo "Tests passed with success" diff --git a/utils/Dockerfile.blueprint b/utils/Dockerfile.blueprint index 81cbcb08..418b462a 100644 --- a/utils/Dockerfile.blueprint +++ b/utils/Dockerfile.blueprint @@ -4,7 +4,16 @@ ARG INSTALL_CRON=1 ARG INSTALL_COMPOSER=1 ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-{{ $variant }} + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-slim-{{ $variant }} + +ONBUILD ARG TARGETOS +ONBUILD ARG TARGETARCH +ONBUILD ARG BLACKFIRE_VERSION=1 +ENV CONTAINER_OS=${TARGETOS} +ENV CONTAINER_ARCH=${TARGETARCH} +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + LABEL authors="Julien Neuhart , David Négrier " diff --git a/utils/Dockerfile.node.blueprint b/utils/Dockerfile.node.blueprint index 548c3fc5..44b80133 100644 --- a/utils/Dockerfile.node.blueprint +++ b/utils/Dockerfile.node.blueprint @@ -3,12 +3,18 @@ ARG PHP_VERSION ARG GLOBAL_VERSION -FROM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-{{ $variant }} +ARG TARGETOS +ARG TARGETARCH +ARG BLACKFIRE_VERSION=1 + +FROM --platform=$BUILDPLATFORM thecodingmachine/php:${PHP_VERSION}-${GLOBAL_VERSION}-{{ $variant }} LABEL authors="Julien Neuhart , David Négrier " USER root +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} + RUN apt-get update && \ apt-get install -y --no-install-recommends gnupg && \ curl -sL https://deb.nodesource.com/setup_{{ $node_version }}.x | bash - && \ diff --git a/utils/Dockerfile.slim.blueprint b/utils/Dockerfile.slim.blueprint index a0c41581..f295bd12 100644 --- a/utils/Dockerfile.slim.blueprint +++ b/utils/Dockerfile.slim.blueprint @@ -1,6 +1,6 @@ {{- $variant := .Orbit.variant -}} -FROM ubuntu:20.04 +FROM --platform=$BUILDPLATFORM ubuntu:20.04 LABEL authors="Julien Neuhart , David Négrier " @@ -12,6 +12,14 @@ ENV DEBIAN_FRONTEND=noninteractive ARG PHP_VERSION ENV PHP_VERSION=$PHP_VERSION +ONBUILD ARG TARGETOS +ONBUILD ARG TARGETARCH +ONBUILD ARG BLACKFIRE_VERSION=1 +ARG BLACKFIRE_VERSION=1 +ARG TARGETOS +ARG TARGETARCH + +ENV BLACKFIRE_VERSION=${BLACKFIRE_VERSION} # |-------------------------------------------------------------------------- # | Main PHP extensions @@ -304,7 +312,7 @@ ENV IMAGE_VARIANT={{$variant}} # Add Tini (to be able to stop the container with ctrl-c). # See: https://github.com/krallin/tini ENV TINI_VERSION v0.16.1 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TARGETARCH} /tini RUN chmod +x /tini COPY utils/generate_cron.php /usr/local/bin/generate_cron.php @@ -380,14 +388,14 @@ ONBUILD RUN sudo -E PHP_EXTENSIONS="$PHP_EXTENSIONS" /usr/local/bin/install_sele # | Supercronic is a drop-in replacement for cron (for containers). # | ENV SUPERCRONIC_OPTIONS= - ONBUILD ARG INSTALL_CRON ONBUILD RUN if [ -n "$INSTALL_CRON" ]; then \ - SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-linux-amd64 \ - && SUPERCRONIC=supercronic-linux-amd64 \ + SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-$TARGETOS-$TARGETARCH \ + && echo $SUPERCRONIC_URL \ + && SUPERCRONIC=supercronic-linux-${TARGETARCH} \ && SUPERCRONIC_SHA1SUM=5ddf8ea26b56d4a7ff6faecdd8966610d5cb9d85 \ && curl -fsSLO "$SUPERCRONIC_URL" \ - && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ +# && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ && chmod +x "$SUPERCRONIC" \ && sudo mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ && sudo ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic; \ diff --git a/utils/README.blueprint.md b/utils/README.blueprint.md index 7bb2b790..ee651d9b 100644 --- a/utils/README.blueprint.md +++ b/utils/README.blueprint.md @@ -644,6 +644,24 @@ You can then test your changes using the `build-and-test.sh` command: PHP_VERSION={{ $image.php_version }} BRANCH=v4 VARIANT=apache ./build-and-test.sh ``` +### Additional environment in build-and-test.sh + +- BUILDER: either build or buildx depending on your configuration. +Defaults to build +- BLACKFIRE_VERSION: defaults to 1. You can install v2 if you're feeling adventurous by specifying 2 as a value. +- PLATFORM: Docker will default to your architecture for building images. However, if you have QEMU set up in your machine, you can try building for another architecture like linux/arm64 + +Only one platform at a time is supported during the build and test script execution. + +*APPLE SILICON CONSIDERATIONS* + +Filesystem management works differently in Apple's macOS, so, if you're trying to build a linux/arm64 image (that is best suited for using in a M1/M2 Mac than a linux/amd64 one), there's a high likelihood that the filesystem user and permissions with busybox are going to fail. + +Although the test fails, when using the built image, everything works as expected. + +Run a virtual machine with linux/arm64 with Docker installed in it and, then, build and test the image. You'll take advantage of the ARM speed and will also be able to run the unit tests properly. + + ### Adding additional images To add a new version (php, node, apache, ...), please edit the following files : diff --git a/utils/docker-bake.blueprint.hcl b/utils/docker-bake.blueprint.hcl new file mode 100644 index 00000000..7f3f07e4 --- /dev/null +++ b/utils/docker-bake.blueprint.hcl @@ -0,0 +1,83 @@ +{{ $variants := list "apache" "fpm" "cli" }}{{ $versions := list "8.1" "8.0" "7.4" "7.3" "7.2" }}{{ $nodeVersions := list "16" "14" "12" "10" }} +group "default" { + targets = [ + {{range $phpV := $versions}} + "php{{ $phpV | replace "." "" }}",{{end}} + ] +} +{{range $phpV := $versions}} +group "php{{ $phpV | replace "." "" }}" { + targets = [ + {{range $variant := $variants}}"php{{ $phpV | replace "." "" }}-slim-{{ $variant }}", + "php{{ $phpV | replace "." "" }}-{{ $variant }}", + {{range $nodeV := $nodeVersions}}"php{{ $phpV | replace "." "" }}-{{ $variant }}-node{{ $nodeV }}",{{end}}{{end}} + ] +}{{end}} + +variable "REPO" {default = "thecodingmachine/php"} +variable "TAG" {default = "latest"} +variable "GLOBAL_VERSION" {default = "v4"} + +function "tag" { + params = [PHP_VERSION, VARIANT] + result = [ + "${REPO}:${PHP_VERSION}-${GLOBAL_VERSION}-${VARIANT}", + notequal("latest",TAG) ? "${REPO}:${PHP_VERSION}-${GLOBAL_VERSION}-${VARIANT}:${TAG}": "", + ] +} + +target "default" { + context = "." + args = { + GLOBAL_VERSION = "${GLOBAL_VERSION}" + } + platforms = [ + "linux/amd64", + "linux/arm64" + ] + pull = true + #output = ["customDir"] + #output = ["type=tar,dest=myimage.tar"] + output = ["type=docker"] # load in local docker + #output = ["type=registry"] # push + #output = ["type=image"] # push also ? +} + +{{range $phpV := $versions}}{{range $variant := $variants}} +########################### +## PHP {{ $phpV }} +########################### +# thecodingmachine/php:{{ $phpV }}-v4-slim-{{ $variant }} +target "php{{ $phpV | replace "." "" }}-slim-{{ $variant }}" { + inherits = ["default"] + tags = tag("{{ $phpV }}", "slim-{{ $variant }}") + dockerfile = "Dockerfile.slim.{{ $variant }}" + args = { + PHP_VERSION = "{{ $phpV }}" + VARIANT = "{{ $variant }}" + } +} + +# thecodingmachine/php:{{ $phpV }}-v4-{{ $variant }} +target "php{{ $phpV | replace "." "" }}-{{ $variant }}" { + inherits = ["default"] + tags = tag("{{ $phpV }}", "{{ $variant }}") + dockerfile = "Dockerfile.{{ $variant }}" + args = { + PHP_VERSION = "{{ $phpV }}" + VARIANT = "{{ $variant }}" + } +} +{{range $nodeV := $nodeVersions}} +# thecodingmachine/php:{{ $phpV }}-v4-{{ $variant }}-node{{ $nodeV }} +target "php{{ $phpV | replace "." "" }}-{{ $variant }}-node{{ $nodeV }}" { + inherits = ["default"] + tags = tag("{{ $phpV }}", "{{ $variant }}-node{{ $nodeV }}") + dockerfile = "Dockerfile.{{ $variant }}.node{{ $nodeV }}" + args = { + PHP_VERSION = "{{ $phpV }}" + VARIANT = "{{ $variant }}-node{{ $nodeV }}" + } +} +{{ end }}{{ end }}{{ end }} +