-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inject configuration using environment variable #142
Conversation
I really hope this PR would be merged. I don't see any point in making new images just for config changes, especially since this PR would let me do the same without any overhead or major impact. What is stopping this PR from being merged?? |
Great idea, why not merge it? |
Yeah it could be nice to add some extra config that way. I want to force and set the https. |
ping @tianon @marsjaninzmarsa ... or, at least, allow to bind mount
|
Just rebased this branch in the hope of a timely merge, and wrapped the |
Hi, I`ve tested your change, and it works but for php5.6 you need to update this file |
Right! It's just a copy though, so it was an easy thing to do 😄 I also updated the other entrypoint files. |
This error raises when
To fix this you need to change to |
d'uh! Thanks for the tipp @luiscoms 👍 |
Looking forward to this! |
Nice addition! Is this going to be approved and merged soon? |
rebased to keep this branch fresh and ready to be merged |
Much needed feature. What prevents it from being merged? |
@tianon Can we have a decision? I'd like to strike this off my list of open things ;-) |
Need to get a setup a multisite instance using docker for internal development - really need this merged! Pretty please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long delay -- we've oscillated a lot on how to resolve the issue of users providing additional configuration to this image specifically because it's a bit complicated and everyone seems to have a slightly different opinion on how they'd like that to work.
I think this PR provides the best compromise, so I'd like to move forward on it. 👍
docker-entrypoint.sh
Outdated
@@ -128,14 +128,15 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then | |||
sed -ri -e 's/\r$//' wp-config* | |||
|
|||
if [ ! -e wp-config.php ]; then | |||
awk '/^\/\*.*stop editing.*\*\/$/ && c == 0 { c = 1; system("cat") } { print }' wp-config-sample.php > wp-config.php <<'EOPHP' | |||
awk '/^\/\*.*stop editing.*\*\/$/ && c == 0 { c = 1; system("cat") } { print }' wp-config-sample.php > wp-config.php <<'EOPHP' <<EOBASH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This multi-heredoc syntax seemed too good to be true, so I tested and it does appear to be too good to be true: 😞
$ cat <<EOF1 <<EOF2
> hi
> EOF1
> hi2u
> EOF2
hi2u
It appears the second overwrites the first. However, all three implementations of awk
that I tested (busybox, mawk
, and gawk
) include an ENVIRON
variable which we can use. Here's my suggested modification:
awk '
/^\/\*.*stop editing.*\*\/$/ && c == 0 {
c = 1
system("cat")
if (ENVIRON["WORDPRESS_ADDITIONAL_CONFIG"]) {
print ENVIRON["WORDPRESS_ADDITIONAL_CONFIG"]
}
}
{ print }
' wp-config-sample.php > wp-config.php <<'EOPHP'
...
EOPHP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, the actual implementation works for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im using different heredoc styles, maybe that’s why 🤔
proof:
squashed my commits. edit: my proof is only working in |
Any update? Seems multiple feature requests have been closed in favour of this then it all went quiet. |
I am using the following to autodetect whether the wordpress site url has changed and automatically modify it in the Dockerfile:
I had to copy the
|
Rather than writing a configurable option to pass in any number of wordpress env variables (even though it makes more sense), does it not make sense to just hardcode the It seems daft I can only use a bare minimum of env variables, otherwise I'm faced with creating my own image and entrypoint which takes away the reason for using this image in the first place, ease of use. |
When this PR is going to be merged ? |
This could work for a wide range of needs, but it's not a proper full solution unless you hard-code 100% of all possible environment variables. And as WP introduces new variables, this would need to be kept up-to-date. Personally, I'm all for the solution proposed in this PR. |
Since the README on the Docker hub page links to this issue for more context, it would be nice to edit the top-level description here to reference the final name, |
@reidab it's been updated by @wglambert |
This comment has been minimized.
This comment has been minimized.
I had a similar problem with To reproduce my problem (an, update docker-compose.yml scenario)
Now the My solution was
Now the |
For cases where this doesn't seem to be taking effect, if you check your container logs you'll likely see the warning that was added in #342. 👍 The solutions are either to not mount a previous install (let the script provide the initial If you'd like a solution that will update dynamically from an environment variable, see the |
If anyone gets an database error when trying to configure multisite with: WORDPRESS_CONFIG_EXTRA: |
/* Multisite */
define('WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'localhost'); // TODO: change to actual domain when deploying
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1); use this instead WORDPRESS_CONFIG_EXTRA: |
/* Multisite */
define('WP_ALLOW_MULTISITE', true ); then manualy go via Tools -> Network setup If anyone interested in stacktrace:
|
HI, all. here got bug about this feature , If I set the cofig. below. the
IN
SO, when I access the website, It will redirect to array/path/to/wp |
@quartz010 you've got something else swallowing your For further help, please try the Docker Community Forums, the Docker Community Slack, or Stack Overflow (these issues are not a support forum and this feature is confirmed to be working properly for other users). |
You can scape |
☆⌒(*^-゜)v THX!! Solved! |
I get database error "Error establishing a database connection"
|
What am I missing here? When trying to setup a multisite docker wordpress instance I get the following error after hitting http://localhost:8080
docker-compose.yaml version: '3.7'
services:
wordpress-cli:
image: wordpress:cli
container_name: wordpress-cli
depends_on:
- wordpress
volumes:
- wordpress:/var/www/html
wordpress:
image: wordpress
container_name: wordpress
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST:-db:3306}
WORDPRESS_DB_USER: ${WORDPRESS_DB_USER:-wp_admin}
WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}
WORDPRESS_CONFIG_EXTRA: |
/* Multisite */
define('WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'localhost');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
depends_on:
- db
volumes:
- wordpress:/var/www/html
db:
image: mysql:8.0.18
container_name: db
command: --default-authentication-plugin=mysql_native_password
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: wordpress
MYSQL_USER: ${WORDPRESS_DB_USER:-wp_admin}
MYSQL_PASSWORD: ${WORDPRESS_DB_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
volumes:
- wordpress-db:/var/lib/mysql
- ./data/mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
volumes:
wordpress-db:
name: wordpress-db
wordpress:
name: wordpress .env WORDPRESS_DB_PASSWORD=whatever-you-want
MYSQL_ROOT_PASSWORD=whatever-root-pwd-you-want Why is it trying to access the db before going through the setup process? mysql> use wordpress;
Database changed
mysql> show tables;
Empty set (0.01 sec) If I remove the @lwille, any ideas? |
@spencerdcarlson I had the same issue, and used successfully the workarround proposed above by @SloCompTech |
Hey, is there a solution now outside of the workaround mentioned above? Such that all config could be done in the compose file? Thanks in advance |
Alternative solution to #8. Not passing in
WORDPRESS_CONFIG_EXTRA
won't break anything.Here's an excerpt from my multisite docker-compose.yaml with
WORDPRESS_CONFIG_EXTRA
:The generated wp-config.php looks like this (excerpt):