I made a docker-compose.yaml for my Wordpress stack using official Wordpress image and I want to add some custom constants in wp-config.php file automatically.
By following official image instructions I end up with this:
### Web Application
wordpress:
container_name: 'wordpress'
image: 'wordpress:php7.2-fpm-alpine'
user: 1001:1001
environment:
- WORDPRESS_DB_HOST=mysql
- WORDPRESS_DB_USER=something
- WORDPRESS_DB_NAME=something
- WORDPRESS_DB_PASSWORD=xxxxxxxxxxxxxxx
- WORDPRESS_DEBUG=1
- WORDPRESS_CONFIG_EXTRA=
define( 'WP_REDIS_CLIENT', 'predis' );
define( 'WP_REDIS_SCHEME', 'tcp' );
define( 'WP_REDIS_HOST', 'redis' );
define( 'WP_REDIS_PORT', '6379' );
define( 'WP_REDIS_PASSWORD', 'xxxxxxxxxxxxxxx' );
define( 'WP_REDIS_DATABASE', '0' );
define( 'WP_REDIS_MAXTTL', '21600' );
define( 'WP_CACHE_KEY_SALT', 'xx_ ');
define( 'WP_REDIS_SELECTIVE_FLUSH', 'xx_ ');
define( 'WP_AUTO_UPDATE_CORE', false );
volumes:
- ./wordpress:/var/www/html
- ./logs/php:/var/logs/php
- ./config/php/www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
networks:
- frontend
- backend
restart: always
depends_on:
- mysql
Everything works but my OCD can't rest until I figure out why generated wp-config.php looks like this: WORDPRESS_CONFIG_EXTRA constants joined in one line:
// WORDPRESS_CONFIG_EXTRA
define('WP_REDIS_CLIENT', 'predis'); define('WP_REDIS_SCHEME', 'tcp'); define('WP_REDIS_HOST', 'redis'); define('WP_REDIS_PORT', '6379'); define('WP_REDIS_PASSWORD', 'xxxxxxxxxxxxxxx'); define('WP_REDIS_DATABASE', '0'); define('WP_REDIS_MAXTTL', '21600'); define('WP_CACHE_KEY_SALT', 'xx_'); define('WP_REDIS_SELECTIVE_FLUSH', 'xx_');
..instead of like this, formatted with each constant being on new line which is much more readable:
// WORDPRESS_CONFIG_EXTRA
define('WP_REDIS_CLIENT', 'predis');
define('WP_REDIS_SCHEME', 'tcp');
define('WP_REDIS_HOST', 'redis');
define('WP_REDIS_PORT', '6379');
define('WP_REDIS_PASSWORD', 'xxxxxxxxxxxxxxx');
define('WP_REDIS_DATABASE', '0');
define('WP_REDIS_MAXTTL', '21600');
define('WP_CACHE_KEY_SALT', 'xx_');
define('WP_REDIS_SELECTIVE_FLUSH', 'xx_');
Can anyone guide me on how multiline environment variables are handled in docker-compose file, specifically for WORDPRESS_CONFIG_EXTRA variable?
I tried WORDPRESS_CONFIG_EXTRA: |
and WORDPRESS_CONFIG_EXTRA: |-
but none worked the way I think it should.