Description
Hi everyone, nice to meet you all.
I've been looking at the documents and discussions in the following order and have come up with a better alternative, so I'll post it.
- https://hub.docker.com/_/wordpress/
- Inject configuration using environment variable #142
wordpress/docker-entrypoint.sh
Lines 184 to 188 in 5c66950
- parametrization in setup-config.php will be useful #484
- Don't add WP_DEBUG=TRUE if WORDPRESS_DEBUG is set to FALSE #496
I feel that the Command line interface for WordPress | WP-CLI project is the best way to accurately, reliably, and quickly rewrite the values of variables in wp-config.php.
And it is fortunately available as a wordpress - Docker Hub official image.
MySQL is an essential part of WordPress.
Likewise, considering that WP-CLI is essential for a flexible WordPress/wp-config.php configuration, how about the following?
I think the idempotence of the configuration will be preserved.
---
version: "2.4"
services:
wp-init:
image: wordpress:cli
restart: on-failure
environment:
- WP_CONFIG_DB_CHARSET=utf8mb4
- WP_CONFIG_DB_HOST=db
- WP_CONFIG_TABLE_PREFIX=wp_
# ... other WP_CONFIG_* variables or env_file load files/variables.
volumes:
- wordpress:/var/www/html
- ./wp-config.sh:/wp-config.sh:ro
working_dir: /var/www/html
user: root
command: sh /wp-config.sh
#!/bin/sh
printenv | sed 's/^WP_CONFIG_//;t;d' | sed 's/=/ /' | while read LINE; do wp --allow-root config set $LINE; done
This is just part of my idea of how to do it.
What are your thoughts on this?
Have a great day.