DEV Community

Discussion on: Docker(Docker-compose) + Wordpress/Bedrock

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