DEV Community

Cover image for Docker(Docker-compose) + Wordpress/Bedrock

Docker(Docker-compose) + Wordpress/Bedrock

Emil Privér on August 06, 2019

Originally written at: My website This is a small article on how you can work with Docker and Wordpress(bedrock) to be able to host an wordpress s...
Collapse
 
julianfox profile image
Julian Renard

Hey, How can we manage the Wordpress permission with this template?
I tried to run this code in a sh file in a php Dockerfile without success:

!/bin/sh

This script configures WordPress file permissions based on recommendations

from codex.wordpress.org/Hardening_Word...

Author: Michael Conigliaro

WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=/var/www/html/web # <-- wordpress root directory
WS_GROUP=www-data # <-- webserver group

reset to safe defaults

find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \;
find ${WP_ROOT} -type d -exec chmod 755 {} \;
find ${WP_ROOT} -type f -exec chmod 644 {} \;

allow wordpress to manage wp-config.php (but prevent world access)

chgrp ${WS_GROUP} ${WP_ROOT}/wp-config.php
chmod 660 ${WP_ROOT}/wp-config.php

allow wordpress to manage wp-content

find ${WP_ROOT}/app -exec chgrp ${WS_GROUP} {} \;
find ${WP_ROOT}/app -type d -exec chmod 775 {} \;
find ${WP_ROOT}/app -type f -exec chmod 664 {} \;

Collapse
 
emil_priver profile image
Emil Privér

Hi,

I recommend you to create a Dockerfile inside "Website" folder which runs your script on build.

Collapse
 
julianfox profile image
Julian Renard

How can I create a Dockerfile especially for it? Should I add the php Dockerfile in the Website folder.

I tried to add the php dockerfile in website instead of php without success.

Thread Thread
 
emil_priver profile image
Emil Privér

Beat way is to create a Dockerfile inside “website” folder and add context to docker-compose which tells where the Dockerfile is. Inside of that Dockerfile will you need to build everything ans then you will be able to execute your commands

Collapse
 
emil_priver profile image
Emil Privér • Edited

My first article. Please tell me if I typed something bad or anything I should improve.

Collapse
 
pb_gbg profile image
PB

Interesting article, How do you solve media/uploads, and how do you trigger updates on the docker host of new images once you have pushed them?

Collapse
 
emil_priver profile image
Emil Privér

Hi! Media uploads do I solve via an CDN. WP offload media lite (wordpress.org/plugins/amazon-s3-an...) are my recommendation.

Mostly I am using and ci/cd with my projects. So when I push code to master on my git will the ci and cd start build and restart docker image and so on.

But you are able to restart docker with an simple pull and start aswell