wordpress icon indicating copy to clipboard operation
wordpress copied to clipboard

Provide a php dependency only image without wordpress specific files

Open jooola opened this issue 2 years ago • 4 comments

Could it be possible for the WordPress docker image to provide a php dependency only tag variant ?

The regular image currently provides a zip with a version of WordPress and a custom entry point. But you sometimes do not need thoses files and they might also mess your custom setup (for example extracting WP while it shouldn't).

It would be great if this current image is split into 2 stages, one for the php dependencies, and the next one for the wordpress specific files. This should allow me to reuse the wordpress image to build my own docker image ?

I would see maybe a stage around here: https://github.com/docker-library/wordpress/blob/67e960d91c547417cd879adddf9c1cf0f1dc7a95/latest/php7.4/apache/Dockerfile#L123

We could then have for example:

FROM wordpress:apache-bare

COPY . /var/www/html

jooola avatar Oct 08 '22 14:10 jooola

Something like https://github.com/docker-library/docs/tree/master/php#phpversion-apache?

wglambert avatar Oct 11 '22 15:10 wglambert

I guess that's the idea, but including all the php extensions and settings required/recommended by wordpress.

jooola avatar Oct 11 '22 15:10 jooola

My goal is to bring my Wordpress based application under version control. I'm using PHP Composer and roots/bedrock to compose my webroot directory and I use a .env file for the settings and secrets. Next, I want to create a docker image from this webroot directory with a volume for the upload directory and a docker secret for the .env file. The ultimate goal is to setup a DTAP cycle to deliver my application.

I prefer to use an official docker image from Wordpress so that I don't have to do the maintenance of PHP configuration and extensions myself. I can replace the /usr/src/wordpress/ with my webroot and I found a workaround for the Entrypoint. But I can't 'undo' the volume of the official image. Hence my support for this request.

Workarounds I can think off:

  1. Make a copy of the official Docker file, watch for changes and manually apply patches if needed.
  2. Copy operating system files from the official image to my own image.

Both are not very attractive.

gerwinjansen avatar Nov 12 '22 13:11 gerwinjansen

I used a dirty workaround for now (feel free to propose some improvement):

FROM wordpress:6.1-php8.0-apache as wordpress

RUN set -eux; \
    rm -Rf \
    /usr/local/bin/docker-entrypoint.sh \
    /usr/src/wordpress \
    /var/www/html/*

FROM scratch
COPY --from=wordpress / /

CMD ["apache2-foreground"]

jooola avatar Jan 27 '23 21:01 jooola