From 8cd121386b3ca3e67427fd920f90cb05c311a458 Mon Sep 17 00:00:00 2001 From: Stockmind Date: Thu, 3 Jan 2019 00:19:46 +0100 Subject: [PATCH] handle a php www-user instead of nobody add a www-user and config it on php-fpm to let php permissions works correctly. The build args PUID and PGUID are useful to bind the www-user id with an host user id. --- php/Dockerfile | 10 ++++++++++ php/Dockerfile-no-stats | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/php/Dockerfile b/php/Dockerfile index d823ec5..d02b857 100644 --- a/php/Dockerfile +++ b/php/Dockerfile @@ -20,6 +20,10 @@ LABEL maintainer "Abiola Ibrahim " ARG version="0.11.1" LABEL caddy_version="$version" +# PHP www-user UID and GID +ARG PUID="1000" +ARG PGID="1000" + # Let's Encrypt Agreement ENV ACME_AGREE="false" @@ -34,6 +38,12 @@ RUN ln -sf /usr/bin/php7 /usr/bin/php # symlink php-fpm7 to php-fpm RUN ln -sf /usr/bin/php-fpm7 /usr/bin/php-fpm +# add a php www-user instead of nobody +RUN addgroup -g ${PGID} www-user && \ + adduser -D -H -u ${PUID} -G www-user www-user && \ + sed -i "s|^user = .*|user = www-user|g" /etc/php7/php-fpm.d/www.conf && \ + sed -i "s|^group = .*|group = www-user|g" /etc/php7/php-fpm.d/www.conf + # composer RUN curl --silent --show-error --fail --location \ --header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" \ diff --git a/php/Dockerfile-no-stats b/php/Dockerfile-no-stats index 6f58ddf..b604308 100644 --- a/php/Dockerfile-no-stats +++ b/php/Dockerfile-no-stats @@ -20,6 +20,10 @@ LABEL maintainer "Abiola Ibrahim " ARG version="0.11.1" LABEL caddy_version="$version" +# PHP www-user UID and GID +ARG PUID="1000" +ARG PGID="1000" + # Let's Encrypt Agreement ENV ACME_AGREE="false" @@ -37,6 +41,12 @@ RUN ln -sf /usr/bin/php7 /usr/bin/php # symlink php-fpm7 to php-fpm RUN ln -sf /usr/bin/php-fpm7 /usr/bin/php-fpm +# add a php www-user instead of nobody +RUN addgroup -g ${PGID} www-user && \ + adduser -D -H -u ${PUID} -G www-user www-user && \ + sed -i "s|^user = .*|user = www-user|g" /etc/php7/php-fpm.d/www.conf && \ + sed -i "s|^group = .*|group = www-user|g" /etc/php7/php-fpm.d/www.conf + # composer RUN curl --silent --show-error --fail --location \ --header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" \