Commit 321e04ea authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Convert wordpress/Dockerfile for multi-stage builds

parent 86776a7a
Loading
Loading
Loading
Loading
+30 −27
Original line number Diff line number Diff line
FROM php:7.3-fpm
FROM php:7.3-fpm as deps

LABEL uk.org.kodo.maintainer "Dom Sekotill <dom.sekotill@kodo.org.uk>"
RUN apt-get update \
 && apt-get install -y \
	libgmp10 \
	libjpeg62 \
	libpng16-16 \
    libzip4 \
 &&:


FROM deps as compile

# From the official wordpress docker file (modified):
# ----
# install the PHP extensions we need
RUN apt-get update && apt-get install -y \
RUN apt-get update \
 && apt-get install -y \
	libgmp-dev \
	libjpeg-dev \
	libpng-dev \
	&& rm -rf /var/lib/apt/lists/* \
    libzip-dev \
 && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
	&& docker-php-ext-install gd mysqli opcache gmp

# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
		echo 'opcache.memory_consumption=128'; \
		echo 'opcache.interned_strings_buffer=8'; \
		echo 'opcache.max_accelerated_files=4000'; \
		echo 'opcache.revalidate_freq=60'; \
		echo 'opcache.fast_shutdown=1'; \
		echo 'opcache.enable_cli=1'; \
	} > /usr/local/etc/php/conf.d/opcache-recommended.ini
# ----

ARG wp_version
ARG wp_sha1=
ENV WORDPRESS_VERSION=${wp_version}
 && docker-php-ext-install gd mysqli opcache gmp zip \
 &&:


FROM deps

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

COPY --from=compile /usr/local/etc/php /usr/local/etc/php
COPY --from=compile /usr/local/lib/php /usr/local/lib/php

WORKDIR /app
VOLUME /app/wp-content
ENV WORDPRESS_ROOT=/app

ARG wp_version=latest
ARG wp_sha1=
ADD install.sh /install.sh
RUN /install.sh "${wp_version}" "${wp_sha1}" && rm /install.sh

COPY opcache.ini /usr/local/etc/php/conf.d/opcache-recommended.ini
COPY entrypoint.sh /bin/entrypoint

ENTRYPOINT ["/bin/entrypoint"]
+9 −0
Original line number Diff line number Diff line
@@ -10,6 +10,15 @@ get_version() {
}

build() {
	# Get cached version of compile stage from registry if available
	docker_pull ${DOCKER_REPOSITORY}/compile:latest

	# Build compile stage cache, from last cached version if available
	docker_build \
		--target compile \
		--tag ${DOCKER_REPOSITORY}/compile:latest
	docker_push ${DOCKER_REPOSITORY}/compile:latest

	docker_build \
		--build-arg wp_version="${UPSTREAM_VERSION}" \
		--tag $1

opcache.ini

0 → 100644
+9 −0
Original line number Diff line number Diff line
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php

opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1