mirror of
https://github.com/N0rthernL1ghts/wordpress.git
synced 2024-11-27 05:25:44 +01:00
Improve, much more efficient and reuses already build binaries
This commit is contained in:
parent
d96df7e064
commit
4473bbebfb
55
Dockerfile
55
Dockerfile
|
@ -1,52 +1,39 @@
|
||||||
ARG PHP_VERSION=7.4
|
ARG PHP_VERSION=7.4
|
||||||
ARG WP_VERSION=5.8.0
|
ARG WP_VERSION=5.8.0
|
||||||
FROM --platform=${TARGETPLATFORM} wordpress:${WP_VERSION}-php${PHP_VERSION}-fpm-alpine AS wordpress-builder
|
|
||||||
# As long as new version doesn't require changes to Dockerfile, we don't need separate files
|
|
||||||
|
|
||||||
USER root
|
|
||||||
|
|
||||||
WORKDIR /tmp/build/rootfs
|
|
||||||
|
|
||||||
# Build root filesystem structure (overlay), and copy over neccessary files
|
|
||||||
RUN mkdir -p usr/local/bin \
|
|
||||||
&& mkdir -p usr/local/etc/php/conf.d/ \
|
|
||||||
&& mv /usr/local/etc/php/conf.d/error-logging.ini usr/local/etc/php/conf.d/ \
|
|
||||||
&& mv /usr/local/etc/php/conf.d/opcache-recommended.ini usr/local/etc/php/conf.d/
|
|
||||||
|
|
||||||
|
|
||||||
################################################# APP ##################################################################
|
# Stage 1 - wordpress
|
||||||
|
FROM --platform=${TARGETPLATFORM} wordpress:${WP_VERSION}-php${PHP_VERSION}-fpm-alpine AS wordpress
|
||||||
|
|
||||||
|
|
||||||
|
# Stage 2 - Build rootfs
|
||||||
|
FROM scratch AS wordpress-rootfs
|
||||||
|
|
||||||
|
COPY --from=wordpress /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d/
|
||||||
|
COPY --from=wordpress /usr/local/etc/php-fpm.d /usr/local/etc/php-fpm.d/
|
||||||
|
COPY --from=wordpress /usr/local/include/php/ext /usr/local/include/php/ext/
|
||||||
|
COPY --from=wordpress /usr/local/lib/php/extensions /usr/local/lib/php/extensions/
|
||||||
|
COPY --from=wordpress /usr/local/lib/php/test /usr/local/lib/php/test/
|
||||||
|
|
||||||
|
|
||||||
|
# Stage 3 - Final
|
||||||
FROM --platform=${TARGETPLATFORM} nlss/php-nginx:${PHP_VERSION}
|
FROM --platform=${TARGETPLATFORM} nlss/php-nginx:${PHP_VERSION}
|
||||||
|
# As long as new version doesn't require changes to Dockerfile, we don't need separate files
|
||||||
ARG WP_VERSION
|
ARG WP_VERSION
|
||||||
ENV APK_DEPS "zlib-dev libzip-dev libpng-dev icu-dev imagemagick-dev patch"
|
|
||||||
ENV APK_BUILD_DEPS "curl-dev autoconf alpine-sdk"
|
|
||||||
ENV APK_WP_CLI_DEPS "bash less mysql-client"
|
|
||||||
|
|
||||||
RUN apk add --update --no-cache ${APK_WP_CLI_DEPS} ${APK_DEPS} ${APK_BUILD_DEPS} \
|
COPY --from=wordpress-rootfs / /
|
||||||
&& docker-php-ext-install -j "$(nproc)" \
|
|
||||||
bcmath \
|
|
||||||
exif \
|
|
||||||
gd \
|
|
||||||
mysqli \
|
|
||||||
opcache \
|
|
||||||
zip \
|
|
||||||
intl \
|
|
||||||
&& pecl install redis apcu imagick-3.4.4 \
|
|
||||||
&& docker-php-ext-enable redis apcu imagick \
|
|
||||||
&& apk del ${APK_BUILD_DEPS} \
|
|
||||||
&& rm /tmp/* -rf
|
|
||||||
# TODO: Official WordPress has upgraded imagick to 5.x
|
|
||||||
|
|
||||||
COPY --from=wordpress-builder /tmp/build/rootfs /
|
|
||||||
COPY --from=wordpress:cli-php7.4 /usr/local/bin/wp /usr/local/bin/wp-cli
|
COPY --from=wordpress:cli-php7.4 /usr/local/bin/wp /usr/local/bin/wp-cli
|
||||||
|
|
||||||
|
ENV APK_RUNTIME_DEPS "zlib-dev libzip-dev libpng-dev icu-dev imagemagick-dev patch"
|
||||||
|
ENV APK_WP_CLI_DEPS "bash less mysql-client"
|
||||||
ENV WP_VERSION ${WP_VERSION}
|
ENV WP_VERSION ${WP_VERSION}
|
||||||
ENV WP_LOCALE en_US
|
ENV WP_LOCALE en_US
|
||||||
ENV CRON_ENABLED true
|
ENV CRON_ENABLED true
|
||||||
ENV VIRTUAL_HOST your-domain.com
|
ENV VIRTUAL_HOST your-domain.com
|
||||||
|
|
||||||
ADD rootfs /
|
ADD rootfs /
|
||||||
RUN echo "*/5 * * * * /usr/local/bin/wp cron event run --due-now" >> /etc/crontabs/www-data \
|
RUN apk add --update --no-cache ${APK_WP_CLI_DEPS} ${APK_RUNTIME_DEPS} \
|
||||||
|
&& echo "*/5 * * * * /usr/local/bin/wp cron event run --due-now" >> /etc/crontabs/www-data \
|
||||||
&& chmod a+x /usr/local/bin/wp
|
&& chmod a+x /usr/local/bin/wp
|
||||||
|
|
||||||
VOLUME ["/root/.wp-cli", "/var/www/${WEB_ROOT}", "/var/www/${WEB_ROOT}/wp-content"]
|
VOLUME ["/root/.wp-cli", "/var/www/${WEB_ROOT}", "/var/www/${WEB_ROOT}/wp-content"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user