From 9bd43728115ecb0e1d0fa89bca0e1c32da2a51a1 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Mon, 7 Dec 2020 23:29:34 +0000 Subject: [PATCH 1/4] Fix Docker build-args Build args in FROM lines NEED to be before any other lines, apparently. --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6c38af4..37273ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ # syntax = docker/dockerfile:1.0-experimental -ARG nginx_version=latest -FROM nginx:${nginx_version} as nginx +ARG nginx_version +ARG php_version + +FROM nginx:${nginx_version:-latest} as nginx LABEL uk.org.kodo.maintainer = "Dom Sekotill " COPY data/nginx.conf /etc/nginx/conf.d/default.conf COPY data/fastcgi.nginx.conf /etc/nginx/fastcgi.conf @@ -9,7 +11,6 @@ COPY data/cache-bust.nginx.conf /etc/nginx/cache-bust.conf COPY data/5*.html /app/html/ -ARG php_version= FROM php:${php_version:+$php_version-}fpm-alpine as deps RUN --mount=type=bind,source=scripts/install-deps.sh,target=/stage /stage @@ -20,7 +21,6 @@ FROM deps as fastcgi LABEL uk.org.kodo.maintainer "Dom Sekotill " -ARG wp_version=latest WORKDIR /app ENV WORDPRESS_ROOT=/app @@ -28,6 +28,8 @@ COPY --from=compile /usr/local/etc/php /usr/local/etc/php COPY --from=compile /usr/local/lib/php /usr/local/lib/php COPY scripts/wp.sh /usr/local/bin/wp COPY data/composer.json /app/composer.json + +ARG wp_version=latest RUN --mount=type=bind,source=scripts/install-wp.sh,target=/stage \ /stage ${wp_version} -- GitLab From c7a99a83e0895ec78eff065b9a6e7d4a9e79ff58 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Tue, 8 Dec 2020 00:27:58 +0000 Subject: [PATCH 2/4] Compile imagick from git source --- scripts/compile.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/compile.sh b/scripts/compile.sh index bd52b78..a590176 100755 --- a/scripts/compile.sh +++ b/scripts/compile.sh @@ -5,6 +5,7 @@ set -eux BUILD_DEPS=( autoconf build-base + git gmp-dev imagemagick-dev jpeg-dev @@ -44,5 +45,9 @@ docker-php-ext-configure gd "${GD_ARGS[@]}" docker-php-ext-install -j$(nproc) "${PHP_EXT[@]}" # Download, build & install the Image Magick extension -pecl install imagick +cd $(mktemp -d) +git clone --depth 1 https://github.com/imagick/imagick.git . +phpize +./configure +make install echo "extension=imagick.so" > /usr/local/etc/php/conf.d/imagick.ini -- GitLab From 6acf81255f8d664c011b514e0c26a9dc72a0d309 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Tue, 8 Dec 2020 01:46:26 +0000 Subject: [PATCH 3/4] Split extension compile script --- Dockerfile | 4 +++- scripts/{compile.sh => compile-dist-ext.sh} | 25 --------------------- scripts/compile-imagick.sh | 11 +++++++++ scripts/install-build-deps.sh | 15 +++++++++++++ 4 files changed, 29 insertions(+), 26 deletions(-) rename scripts/{compile.sh => compile-dist-ext.sh} (53%) create mode 100755 scripts/compile-imagick.sh create mode 100755 scripts/install-build-deps.sh diff --git a/Dockerfile b/Dockerfile index 37273ad..ac6a395 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,9 @@ FROM php:${php_version:+$php_version-}fpm-alpine as deps RUN --mount=type=bind,source=scripts/install-deps.sh,target=/stage /stage FROM deps as compile -RUN --mount=type=bind,source=scripts/compile.sh,target=/stage /stage +RUN --mount=type=bind,source=scripts/install-build-deps.sh,target=/stage /stage +RUN --mount=type=bind,source=scripts/compile-dist-ext.sh,target=/stage /stage +RUN --mount=type=bind,source=scripts/compile-imagick.sh,target=/stage /stage FROM deps as fastcgi diff --git a/scripts/compile.sh b/scripts/compile-dist-ext.sh similarity index 53% rename from scripts/compile.sh rename to scripts/compile-dist-ext.sh index a590176..5317fd6 100755 --- a/scripts/compile.sh +++ b/scripts/compile-dist-ext.sh @@ -1,19 +1,6 @@ #!/bin/bash set -eux -# Packaged build dependencies -BUILD_DEPS=( - autoconf - build-base - git - gmp-dev - imagemagick-dev - jpeg-dev - libpng-dev - libwebp-dev - libzip-dev -) - # Distributed extensions PHP_EXT=( bcmath @@ -31,10 +18,6 @@ php_version() { return 1 } -# Install packaged dependencies -apk update -apk add "${BUILD_DEPS[@]}" - # Build & install distributed extensions if php_version -gt 7.4; then GD_ARGS=( --with-jpeg=/usr --with-webp=/usr ) @@ -43,11 +26,3 @@ else fi docker-php-ext-configure gd "${GD_ARGS[@]}" docker-php-ext-install -j$(nproc) "${PHP_EXT[@]}" - -# Download, build & install the Image Magick extension -cd $(mktemp -d) -git clone --depth 1 https://github.com/imagick/imagick.git . -phpize -./configure -make install -echo "extension=imagick.so" > /usr/local/etc/php/conf.d/imagick.ini diff --git a/scripts/compile-imagick.sh b/scripts/compile-imagick.sh new file mode 100755 index 0000000..fc7d164 --- /dev/null +++ b/scripts/compile-imagick.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -eux + +cd $(mktemp -d) + +git clone --depth 1 https://github.com/imagick/imagick.git . +phpize +./configure +make install + +echo "extension=imagick.so" > /usr/local/etc/php/conf.d/imagick.ini diff --git a/scripts/install-build-deps.sh b/scripts/install-build-deps.sh new file mode 100755 index 0000000..0d963e7 --- /dev/null +++ b/scripts/install-build-deps.sh @@ -0,0 +1,15 @@ +#!/bin/sh +set -eux + +# Install packaged dependencies +apk update +apk add \ + autoconf \ + build-base \ + git \ + gmp-dev \ + imagemagick-dev \ + jpeg-dev \ + libpng-dev \ + libwebp-dev \ + libzip-dev \ -- GitLab From a8ff10d1bf0ac0a231f5e9aad5fac3b5d4036da9 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Tue, 8 Dec 2020 09:19:26 +0000 Subject: [PATCH 4/4] Add a note about lack of upstream support for PHP-8 --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a3d5d8..086ac39 100644 --- a/README.md +++ b/README.md @@ -54,10 +54,14 @@ Build > **Note:** Building manually requires Docker 18.09 or later with the > [Buildkit][] feature enabled. +> **Note:** *(Dec 2020)* Currently WP-CLI does not support PHP-8. Likely various plugins and +> themes also do not work with PHP-8. Therefore until wider support is available, supply +> a PHP-7 version with a build argument. + To build the PHP-FPM image run: ```shell -DOCKER_BUILDKIT=1 docker build -t wordpress:tag . +DOCKER_BUILDKIT=1 docker build -t wordpress:tag --build-arg php_version=7.4.13 . ``` To build the Nginx companion image, run: -- GitLab