Skip to content

Commit e10beab

Browse files
committed
*Allow new HOST_UID and HOST_GID env vars to set up ownership permissions for www-data user to prevent access issues
1 parent dafda7f commit e10beab

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ RUN echo "zend_extension = /usr/local/lib/php/extensions/$(ls /usr/local/lib/php
1919
COPY php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
2020

2121
COPY php/mailcatcher.ini /usr/local/etc/php/conf.d/mailcatcher.ini
22+
23+
COPY bootstrap.sh /bootstrap.sh
24+
25+
CMD ["/bootstrap.sh","apache2-foreground"]

bootstrap.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# If HOST_UID is passed, change the permissions
6+
if [ ! -z "$HOST_UID" ]; then
7+
usermod -u ${HOST_UID} www-data
8+
groupmod -g ${HOST_GID} www-data
9+
chown -R www-data:www-data .
10+
fi
11+
12+
exec "$@"

docker-compose-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ wordpress:
33
environment:
44
WORDPRESS_DB_PASSWORD: wpstack
55
MYSQL_PORT_3306_TCP: 1
6+
HOST_UID: 1000
7+
HOST_GID: 1000
68
links:
79
- db:mysql
810
ports:

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ wordpress:
44
environment:
55
WORDPRESS_DB_PASSWORD: wpstack
66
MYSQL_PORT_3306_TCP: 1
7+
HOST_UID: 1000
8+
HOST_GID: 1000
79
links:
810
- db:mysql
911
ports:

0 commit comments

Comments
 (0)