Commit 0a2c514a authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Merge branch '9-fix-builds-post-release-of-php-8' into 'master'

Resolve "Fix builds post-release of PHP-8"

Closes #9

See merge request !13
parents 6c141436 a8ff10d1
Loading
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
# 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 <dom.sekotill@kodo.org.uk>"
COPY data/nginx.conf /etc/nginx/conf.d/default.conf
COPY data/fastcgi.nginx.conf /etc/nginx/fastcgi.conf
@@ -9,18 +11,18 @@ 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

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

LABEL uk.org.kodo.maintainer "Dom Sekotill <dom.sekotill@kodo.org.uk>"

ARG wp_version=latest
WORKDIR /app
ENV WORDPRESS_ROOT=/app

@@ -28,6 +30,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}

+5 −1
Original line number Diff line number Diff line
@@ -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:
+0 −20
Original line number Diff line number Diff line
#!/bin/bash
set -eux

# Packaged build dependencies
BUILD_DEPS=(
	autoconf
	build-base
	gmp-dev
	imagemagick-dev
	jpeg-dev
	libpng-dev
	libwebp-dev
	libzip-dev
)

# Distributed extensions
PHP_EXT=(
	bcmath
@@ -30,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 )
@@ -42,7 +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
pecl install imagick
echo "extension=imagick.so" > /usr/local/etc/php/conf.d/imagick.ini
+11 −0
Original line number Diff line number Diff line
#!/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
+15 −0
Original line number Diff line number Diff line
#!/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 \