Closed Nickous closed 4 years ago
Two ways to configure docker container.
1) The image has a mechanism for this. Typically it's an env variable. You go to https://hub.docker.com/_/wordpress Read the doc and guess that "-e WORDPRESS_CONFIG_EXTRA=... (defaults to nothing, non-empty value will be embedded verbatim inside wp-config.php -- especially useful for applying extra configuration" will do the trick.
To check this you go to https://github.com/docker-library/wordpress to look in the Dockerfile or the docker-entrypoint.sh
And in line 151 you see that the content of WORDPRESS_CONFIG_EXTRA is copied into wp-config.php https://github.com/docker-library/wordpress/blob/0df5de06a4f43f2790dfc3be92554a7e229115d9/php7.3/fpm-alpine/docker-entrypoint.sh#L151
Looks good. For me.
So I would define a variable app_php_config in https://github.com/ReinerNippes/selfhosted_on_docker/blob/master/group_vars/wordpress.yml And add to the docker task https://github.com/ReinerNippes/selfhosted_on_docker/blob/master/roles/docker_wordpress/tasks/wordpress.yml#L5 an env: parameter https://docs.ansible.com/ansible/latest/modules/docker_container_module.html#parameter-env You may test it without the variable definition.
2) If that doesn't work. You have to find the place of the php config files in the container. Dockerfile/docker-entrypoint.sh are again a good start. Seems that /usr/local/etc/php is the path you have to look for. https://github.com/docker-library/wordpress/blob/0df5de06a4f43f2790dfc3be92554a7e229115d9/php7.3/fpm-alpine/Dockerfile#L53
You may log into the container with a command like this docker exec -it app-wordpress /bin/sh
and examine how the php is read. I guess there is a include /usr/local/etc/php/conf.d/*.php
somewhere. To get your config inside the container you create a file on the host and add this as a volume to the container.
The syntax you can find here: https://github.com/ReinerNippes/selfhosted_on_docker/blob/658ae339044622934836c00a19584ae34f844cf2/roles/docker_nextcloud/tasks/nextcloud.yml#L41
Waouhh!! very well documented. Thank you for your very helpful help.
I choose option 2 and add the php.ini file in /usr/local/etc/php/conf.d/
with a volume command.
https://github.com/Nickous/selfhosted_on_docker/commit/5bea4a358ceab8f2a401f738cd0cae6d6e07fd8e
Wordpress upload file is limited to 2M. How to increase it? Is the the php.ini file https://github.com/ReinerNippes/selfhosted_on_docker/blob/master/roles/docker_wordpress/files/php.ini used? I changed the value
upload_max_filesize
but no way. I'm really noob in docker.... How to change a php configuration after container is built. How to apply changed?Thank you by advance for any help