Skip to content

Commit 6f6ea03

Browse files
akolnoochenkotianon
authored andcommitted
Use tar based solution to manage permissions of WP copied files
1 parent 91b3d08 commit 6f6ea03

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docker-entrypoint.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,22 @@ file_env() {
2424
}
2525

2626
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
27+
: "${APACHE_RUN_USER:-www-data}"
28+
: "${APACHE_RUN_GROUP:-www-data}"
29+
export APACHE_RUN_USER APACHE_RUN_GROUP
30+
2731
if ! [ -e index.php -a -e wp-includes/version.php ]; then
2832
echo >&2 "WordPress not found in $PWD - copying now..."
2933
if [ "$(ls -A)" ]; then
3034
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
3135
( set -x; ls -A; sleep 10 )
3236
fi
33-
tar cf - --one-file-system -C /usr/src/wordpress . | tar xf -
34-
chown -R ${APACHE_RUN_USER:-www-data}:${APACHE_RUN_GROUP:-www-data} $PWD
37+
tar --create \
38+
--file - \
39+
--one-file-system \
40+
--directory /usr/src/wordpress \
41+
--owner "${APACHE_RUN_USER}" --group "${APACHE_RUN_GROUP}" \
42+
. | tar --extract --file -
3543
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
3644
if [ ! -e .htaccess ]; then
3745
# NOTE: The "Indexes" option is disabled in the php:apache base image
@@ -47,7 +55,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
4755
</IfModule>
4856
# END WordPress
4957
EOF
50-
chown ${APACHE_RUN_USER:-www-data}:${APACHE_RUN_GROUP:-www-data} .htaccess
58+
chown ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} .htaccess
5159
fi
5260
fi
5361

@@ -116,7 +124,7 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROT
116124
}
117125
118126
EOPHP
119-
chown ${APACHE_RUN_USER:-www-data}:${APACHE_RUN_GROUP:-www-data} wp-config.php
127+
chown ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} wp-config.php
120128
fi
121129

122130
# see http://stackoverflow.com/a/2705678/433558

0 commit comments

Comments
 (0)