Since this image relies on reading empty wp-config.php options, there's no way to include additional settings without overriding wp-config.php.
For instance, because wp-config.php has this line by default,
define('DB_NAME', '');
I am allowed to set DB_NAME with an environment variable.
But since it does _not_ have,
define('ADMIN_COOKIE_PATH', '');
it is not easy for me to dynamically ADMIN_COOKIE_PATH at all.
I suppose I could create a new image based on the wordpress one, and copy in a wp-config.php with blank settings. Then it should work. But should I have to do that for every single project? It's guaranteed that I'm going to need to set SITEURL on local containers, but I actually want it to be the default in production. I also can't _unset_ a blank line with an environment variable (force it to go from an empty string to using the default). Is there a better solution?
I think it might be easier to start with a mostly empty wp-config.php and a list of all possible WordPress options. Environment variables could then be referenced against the possible config options and printed into the file if they exist.
Hi, Im not sure what the recommended way is, but I use this in my Dockerfile
ADD php.ini /usr/local/etc/php/php.ini
ADD wp-config-additions.txt /wp-config-additions.txt
RUN sed -e '1r /wp-config-additions.txt' -i /usr/src/wordpress/wp-config-sample.php
The sed command there extends the sample with custom options, which then get moved into wp-config.php.
My suggestion in #147 might be a better place to run those changes, but the above has been reliable for me so far.
FWIW the contents of my wp-config-additions.txt is
/** Memory Limits */
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
Indeed, we generally recommend either modifying /usr/src/wordpress/wp-config-sample.php or the generated wp-config.php (which is in the default VOLUME) after the initial setup is completed.
What is the recommended way of doing the modification? I'm trying to add some extra php to the wp-config.php with WP-CLI but I haven't found a way to extend the docker-entrypoint.sh because it needs the php-fpm as second parameter. My idea was to do create my own entrypoint where I could run the original like this:
bash docker-entrypoint.sh # run the original entrypoint
wp core config --extra-php ... # add some extras
#start the php-fpm here
Is there any recommended solutions for doing the modification automatically after the WordPress installation is ready as my idea is not working?
I have also tried to make a completely new Dockerfile for just the modification with entrypoint like this:
# Wait until the WordPress has been installed
until wp core version --allow-root; do
sleep 1;
done;
wp config --extra-php ... # add some extras
It works but is quite overkill for that simple job.
EDIT:
If I run the original endpoint like this:
bash docker-endpoint.sh php-fpm &
until wp core version --allow-root; do
sleep 2;
done;
wp core config --extra-php= ...
I'm able to run "both" of the scripts parallel and the latter waits for the original docker-entrypoint.sh to install the WP but then the php doesn't start and the container exits after finishing.
Take a look at #142 on that matter.
Closing in favor of https://github.com/docker-library/wordpress/pull/142. :+1:
Most helpful comment
Hi, Im not sure what the recommended way is, but I use this in my Dockerfile
The
sedcommand there extends the sample with custom options, which then get moved into wp-config.php.My suggestion in #147 might be a better place to run those changes, but the above has been reliable for me so far.