Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-create "wp-content" (and subdirectories) with wide permissions for users who bind-mount directly into them #503

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Dockerfile-alpine.template
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ RUN { \
echo 'html_errors = Off'; \
} > /usr/local/etc/php/conf.d/error-logging.ini
%%VARIANT_EXTRAS%%
VOLUME /var/www/html

ENV WORDPRESS_VERSION %%WORDPRESS_VERSION%%
ENV WORDPRESS_SHA1 %%WORDPRESS_SHA1%%
Expand All @@ -79,7 +78,17 @@ RUN set -ex; \
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
tar -xzf wordpress.tar.gz -C /usr/src/; \
rm wordpress.tar.gz; \
chown -R www-data:www-data /usr/src/wordpress
chown -R www-data:www-data /usr/src/wordpress; \
# pre-create wp-content (and single-level children) for folks who want to bind-mount themes, etc so permissions are pre-created properly instead of root:root
mkdir wp-content; \
for dir in /usr/src/wordpress/wp-content/*/; do \
dir="$(basename "${dir%/}")"; \
mkdir "wp-content/$dir"; \
done; \
chown -R www-data:www-data wp-content; \
chmod -R 777 wp-content

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile-cli.template
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ RUN set -ex; \
mkdir -p /var/www/html; \
chown -R www-data:www-data /var/www/html
WORKDIR /var/www/html
VOLUME /var/www/html

# https://make.wordpress.org/cli/2018/05/31/gpg-signature-change/
# pub rsa2048 2018-05-31 [SC]
Expand Down Expand Up @@ -93,6 +92,8 @@ RUN set -ex; \
\
wp --allow-root --version

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

ENTRYPOINT ["docker-entrypoint.sh"]
Expand Down
13 changes: 11 additions & 2 deletions Dockerfile-debian.template
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ RUN { \
echo 'html_errors = Off'; \
} > /usr/local/etc/php/conf.d/error-logging.ini
%%VARIANT_EXTRAS%%
VOLUME /var/www/html

ENV WORDPRESS_VERSION %%WORDPRESS_VERSION%%
ENV WORDPRESS_SHA1 %%WORDPRESS_SHA1%%
Expand All @@ -84,7 +83,17 @@ RUN set -ex; \
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
tar -xzf wordpress.tar.gz -C /usr/src/; \
rm wordpress.tar.gz; \
chown -R www-data:www-data /usr/src/wordpress
chown -R www-data:www-data /usr/src/wordpress; \
# pre-create wp-content (and single-level children) for folks who want to bind-mount themes, etc so permissions are pre-created properly instead of root:root
mkdir wp-content; \
for dir in /usr/src/wordpress/wp-content/*/; do \
dir="$(basename "${dir%/}")"; \
mkdir "wp-content/$dir"; \
done; \
chown -R www-data:www-data wp-content; \
chmod -R 777 wp-content

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
Expand Down
13 changes: 11 additions & 2 deletions php7.2/apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ RUN set -eux; \
# (replace all instances of "%h" with "%a" in LogFormat)
find /etc/apache2 -type f -name '*.conf' -exec sed -ri 's/([[:space:]]*LogFormat[[:space:]]+"[^"]*)%h([^"]*")/\1%a\2/g' '{}' +

VOLUME /var/www/html

ENV WORDPRESS_VERSION 5.4.1
ENV WORDPRESS_SHA1 9800c231828eb5cd76ba0b8aa6c1a74dfca2daff
Expand All @@ -102,7 +101,17 @@ RUN set -ex; \
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
tar -xzf wordpress.tar.gz -C /usr/src/; \
rm wordpress.tar.gz; \
chown -R www-data:www-data /usr/src/wordpress
chown -R www-data:www-data /usr/src/wordpress; \
# pre-create wp-content (and single-level children) for folks who want to bind-mount themes, etc so permissions are pre-created properly instead of root:root
mkdir wp-content; \
for dir in /usr/src/wordpress/wp-content/*/; do \
dir="$(basename "${dir%/}")"; \
mkdir "wp-content/$dir"; \
done; \
chown -R www-data:www-data wp-content; \
chmod -R 777 wp-content

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion php7.2/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
Expand Down
3 changes: 2 additions & 1 deletion php7.2/cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ RUN set -ex; \
mkdir -p /var/www/html; \
chown -R www-data:www-data /var/www/html
WORKDIR /var/www/html
VOLUME /var/www/html

# https://make.wordpress.org/cli/2018/05/31/gpg-signature-change/
# pub rsa2048 2018-05-31 [SC]
Expand Down Expand Up @@ -92,6 +91,8 @@ RUN set -ex; \
\
wp --allow-root --version

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

ENTRYPOINT ["docker-entrypoint.sh"]
Expand Down
13 changes: 11 additions & 2 deletions php7.2/fpm-alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ RUN { \
echo 'html_errors = Off'; \
} > /usr/local/etc/php/conf.d/error-logging.ini

VOLUME /var/www/html

ENV WORDPRESS_VERSION 5.4.1
ENV WORDPRESS_SHA1 9800c231828eb5cd76ba0b8aa6c1a74dfca2daff
Expand All @@ -78,7 +77,17 @@ RUN set -ex; \
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
tar -xzf wordpress.tar.gz -C /usr/src/; \
rm wordpress.tar.gz; \
chown -R www-data:www-data /usr/src/wordpress
chown -R www-data:www-data /usr/src/wordpress; \
# pre-create wp-content (and single-level children) for folks who want to bind-mount themes, etc so permissions are pre-created properly instead of root:root
mkdir wp-content; \
for dir in /usr/src/wordpress/wp-content/*/; do \
dir="$(basename "${dir%/}")"; \
mkdir "wp-content/$dir"; \
done; \
chown -R www-data:www-data wp-content; \
chmod -R 777 wp-content

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion php7.2/fpm-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
Expand Down
13 changes: 11 additions & 2 deletions php7.2/fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ RUN { \
echo 'html_errors = Off'; \
} > /usr/local/etc/php/conf.d/error-logging.ini

VOLUME /var/www/html

ENV WORDPRESS_VERSION 5.4.1
ENV WORDPRESS_SHA1 9800c231828eb5cd76ba0b8aa6c1a74dfca2daff
Expand All @@ -83,7 +82,17 @@ RUN set -ex; \
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
tar -xzf wordpress.tar.gz -C /usr/src/; \
rm wordpress.tar.gz; \
chown -R www-data:www-data /usr/src/wordpress
chown -R www-data:www-data /usr/src/wordpress; \
# pre-create wp-content (and single-level children) for folks who want to bind-mount themes, etc so permissions are pre-created properly instead of root:root
mkdir wp-content; \
for dir in /usr/src/wordpress/wp-content/*/; do \
dir="$(basename "${dir%/}")"; \
mkdir "wp-content/$dir"; \
done; \
chown -R www-data:www-data wp-content; \
chmod -R 777 wp-content

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion php7.2/fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
Expand Down
13 changes: 11 additions & 2 deletions php7.3/apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ RUN set -eux; \
# (replace all instances of "%h" with "%a" in LogFormat)
find /etc/apache2 -type f -name '*.conf' -exec sed -ri 's/([[:space:]]*LogFormat[[:space:]]+"[^"]*)%h([^"]*")/\1%a\2/g' '{}' +

VOLUME /var/www/html

ENV WORDPRESS_VERSION 5.4.1
ENV WORDPRESS_SHA1 9800c231828eb5cd76ba0b8aa6c1a74dfca2daff
Expand All @@ -103,7 +102,17 @@ RUN set -ex; \
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
tar -xzf wordpress.tar.gz -C /usr/src/; \
rm wordpress.tar.gz; \
chown -R www-data:www-data /usr/src/wordpress
chown -R www-data:www-data /usr/src/wordpress; \
# pre-create wp-content (and single-level children) for folks who want to bind-mount themes, etc so permissions are pre-created properly instead of root:root
mkdir wp-content; \
for dir in /usr/src/wordpress/wp-content/*/; do \
dir="$(basename "${dir%/}")"; \
mkdir "wp-content/$dir"; \
done; \
chown -R www-data:www-data wp-content; \
chmod -R 777 wp-content

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion php7.3/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
Expand Down
3 changes: 2 additions & 1 deletion php7.3/cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ RUN set -ex; \
mkdir -p /var/www/html; \
chown -R www-data:www-data /var/www/html
WORKDIR /var/www/html
VOLUME /var/www/html

# https://make.wordpress.org/cli/2018/05/31/gpg-signature-change/
# pub rsa2048 2018-05-31 [SC]
Expand Down Expand Up @@ -93,6 +92,8 @@ RUN set -ex; \
\
wp --allow-root --version

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

ENTRYPOINT ["docker-entrypoint.sh"]
Expand Down
13 changes: 11 additions & 2 deletions php7.3/fpm-alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ RUN { \
echo 'html_errors = Off'; \
} > /usr/local/etc/php/conf.d/error-logging.ini

VOLUME /var/www/html

ENV WORDPRESS_VERSION 5.4.1
ENV WORDPRESS_SHA1 9800c231828eb5cd76ba0b8aa6c1a74dfca2daff
Expand All @@ -79,7 +78,17 @@ RUN set -ex; \
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
tar -xzf wordpress.tar.gz -C /usr/src/; \
rm wordpress.tar.gz; \
chown -R www-data:www-data /usr/src/wordpress
chown -R www-data:www-data /usr/src/wordpress; \
# pre-create wp-content (and single-level children) for folks who want to bind-mount themes, etc so permissions are pre-created properly instead of root:root
mkdir wp-content; \
for dir in /usr/src/wordpress/wp-content/*/; do \
dir="$(basename "${dir%/}")"; \
mkdir "wp-content/$dir"; \
done; \
chown -R www-data:www-data wp-content; \
chmod -R 777 wp-content

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion php7.3/fpm-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
Expand Down
13 changes: 11 additions & 2 deletions php7.3/fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ RUN { \
echo 'html_errors = Off'; \
} > /usr/local/etc/php/conf.d/error-logging.ini

VOLUME /var/www/html

ENV WORDPRESS_VERSION 5.4.1
ENV WORDPRESS_SHA1 9800c231828eb5cd76ba0b8aa6c1a74dfca2daff
Expand All @@ -84,7 +83,17 @@ RUN set -ex; \
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
tar -xzf wordpress.tar.gz -C /usr/src/; \
rm wordpress.tar.gz; \
chown -R www-data:www-data /usr/src/wordpress
chown -R www-data:www-data /usr/src/wordpress; \
# pre-create wp-content (and single-level children) for folks who want to bind-mount themes, etc so permissions are pre-created properly instead of root:root
mkdir wp-content; \
for dir in /usr/src/wordpress/wp-content/*/; do \
dir="$(basename "${dir%/}")"; \
mkdir "wp-content/$dir"; \
done; \
chown -R www-data:www-data wp-content; \
chmod -R 777 wp-content

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion php7.3/fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
Expand Down
13 changes: 11 additions & 2 deletions php7.4/apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ RUN set -eux; \
# (replace all instances of "%h" with "%a" in LogFormat)
find /etc/apache2 -type f -name '*.conf' -exec sed -ri 's/([[:space:]]*LogFormat[[:space:]]+"[^"]*)%h([^"]*")/\1%a\2/g' '{}' +

VOLUME /var/www/html

ENV WORDPRESS_VERSION 5.4.1
ENV WORDPRESS_SHA1 9800c231828eb5cd76ba0b8aa6c1a74dfca2daff
Expand All @@ -103,7 +102,17 @@ RUN set -ex; \
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
tar -xzf wordpress.tar.gz -C /usr/src/; \
rm wordpress.tar.gz; \
chown -R www-data:www-data /usr/src/wordpress
chown -R www-data:www-data /usr/src/wordpress; \
# pre-create wp-content (and single-level children) for folks who want to bind-mount themes, etc so permissions are pre-created properly instead of root:root
mkdir wp-content; \
for dir in /usr/src/wordpress/wp-content/*/; do \
dir="$(basename "${dir%/}")"; \
mkdir "wp-content/$dir"; \
done; \
chown -R www-data:www-data wp-content; \
chmod -R 777 wp-content

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion php7.4/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi

echo >&2 "WordPress not found in $PWD - copying now..."
if [ -n "$(ls -A)" ]; then
if [ -n "$(find -mindepth 1 -maxdepth 1 -not -name wp-content)" ]; then
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
fi
sourceTarArgs=(
Expand Down
3 changes: 2 additions & 1 deletion php7.4/cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ RUN set -ex; \
mkdir -p /var/www/html; \
chown -R www-data:www-data /var/www/html
WORKDIR /var/www/html
VOLUME /var/www/html

# https://make.wordpress.org/cli/2018/05/31/gpg-signature-change/
# pub rsa2048 2018-05-31 [SC]
Expand Down Expand Up @@ -93,6 +92,8 @@ RUN set -ex; \
\
wp --allow-root --version

VOLUME /var/www/html

COPY docker-entrypoint.sh /usr/local/bin/

ENTRYPOINT ["docker-entrypoint.sh"]
Expand Down
Loading