Wordpress: Deploy and update on production

Created on 2 Aug 2019  路  4Comments  路  Source: docker-library/wordpress

Ok. It's a little addition to issue #146. I'll close it if you tell me the right way.

I have a project in which I need to perform some updates in the theme files from time to time (styles, scripts, etc.). I have a Dockerfile which consists of two parts - the first one, collects the theme project files (sass, js), the second one takes the wordpress:fpm-alpine image and puts the collected files into /usr/src/wordpress. When we deploy the project in production for the first time, everything goes fine - docker-entrypoint.sh picks up the files and copies them. Works fine.

But if I want to update some of the theme files, and make two simple commands docker-compose build wordpress && docker-compose up -d wordpress, then, of course, the files will not be copied (according to the original sh file). I have several solutions to this problem - rewrite the original docker-entrypoint.sh file or forward the template files folder through the compose file as volume. But in the second case, I need to either build the files on the host (install node and other things) or create a service to build them. Or... delete every time wordpress volume so he can copy it all over again.

Actually, I have either a question or a suggestion - how can we deploy such things in a human way? I don't want to make a bunch of files and rewrite the original .sh file. After all, this can be solved with one simple Dockerfile. Maybe should add some checks here

https://github.com/docker-library/wordpress/blob/fc7f07cb8bd12b4f4a8d30710348af0445ce46af/php7.3/fpm-alpine/docker-entrypoint.sh#L48

which would allow you to check for updates to the added user content and, if there are any, copy them. I think it should help a lot of people. It will make it easier to develop and update.

question

All 4 comments

What about copying to /var/www/html/wp-content/{themes,plugins}/?
You'll just have to ensure appropriate permissions/ownership since the entrypoint does a --owner "$user" --group "$group"

Updating theme/plugin files can be as simple as mounting /var/www/html to the host and you can add/remove files seamlessly

What about copying to /var/www/html/wp-content/{themes,plugins}/?

But /var/www/html is a volume. Is it possible without mounting it on the host?

Technically it's already mounted to the host, it's just in /var/lib/docker/volumes/. If you don't want to move that to rename and move that with a bind-mount then you can also use docker cp to transfer files/folders between the host and container.

But I think what your wanting to do is easily done with adding

volumes:
      - ./wordpress:/var/www/html

to your docker-compose.yml and then accessing themes/plugins through that folder on the host.

The entrypoint is only ever going to run once per container lifetime, so if you want to run it again then I guess you can do it manually or do a docker-compose down/up to kill and create the containers.

Yeah, that's one of the decisions I write in the message. Just mount the folder on the compose file and work with it. Then I'll do it like this.

Okay, thanks for the answer btw.

Was this page helpful?
0 / 5 - 0 ratings