Skip to content

Commit 3f9b888

Browse files
committed
Run php-fpm as different user (laradock#1745)
1 parent 861ea6b commit 3f9b888

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ services:
190190
- ADDITIONAL_LOCALES=${PHP_FPM_ADDITIONAL_LOCALES}
191191
- INSTALL_FFMPEG=${PHP_FPM_FFMPEG}
192192
- INSTALL_XHPROF=${PHP_FPM_INSTALL_XHPROF}
193+
- PUID=${PHP_FPM_PUID}
194+
- PGID=${PHP_FPM_PGID}
193195
- http_proxy
194196
- https_proxy
195197
- no_proxy

env-example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ PHP_FPM_INSTALL_SSHPASS=false
193193
PHP_FPM_FFMPEG=false
194194
PHP_FPM_ADDITIONAL_LOCALES="es_ES.UTF-8 fr_FR.UTF-8"
195195

196+
PHP_FPM_PUID=1000
197+
PHP_FPM_PGID=1000
198+
196199
### PHP_WORKER ############################################
197200

198201
PHP_WORKER_INSTALL_PGSQL=false

php-fpm/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,14 @@ RUN apt-get clean && \
759759
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
760760
rm /var/log/lastlog /var/log/faillog
761761

762-
RUN usermod -u 1000 www-data
762+
# Configure non-root user.
763+
ARG PUID=1000
764+
ENV PUID ${PUID}
765+
ARG PGID=1000
766+
ENV PGID ${PGID}
767+
768+
RUN groupmod -o -g ${PGID} www-data && \
769+
usermod -o -u ${PUID} -g www-data www-data
763770

764771
# Adding the faketime library to the preload file needs to be done last
765772
# otherwise it will preload it for all commands that follow in this file

0 commit comments

Comments
 (0)