Skip to content

Commit 8aeb64e

Browse files
authored
Merge pull request laradock#2305 from ubc/1745-php-fpm-uid-gid
Run php-fpm as different user (laradock#1745)
2 parents 3cdc771 + 3f9b888 commit 8aeb64e

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
@@ -198,6 +198,8 @@ services:
198198
- ADDITIONAL_LOCALES=${PHP_FPM_ADDITIONAL_LOCALES}
199199
- INSTALL_FFMPEG=${PHP_FPM_FFMPEG}
200200
- INSTALL_XHPROF=${PHP_FPM_INSTALL_XHPROF}
201+
- PUID=${PHP_FPM_PUID}
202+
- PGID=${PHP_FPM_PGID}
201203
- http_proxy
202204
- https_proxy
203205
- no_proxy

env-example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ PHP_FPM_INSTALL_MAILPARSE=false
198198
PHP_FPM_FFMPEG=false
199199
PHP_FPM_ADDITIONAL_LOCALES="es_ES.UTF-8 fr_FR.UTF-8"
200200

201+
PHP_FPM_PUID=1000
202+
PHP_FPM_PGID=1000
203+
201204
### PHP_WORKER ############################################
202205

203206
PHP_WORKER_INSTALL_PGSQL=false

php-fpm/Dockerfile

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

792-
RUN usermod -u 1000 www-data
792+
# Configure non-root user.
793+
ARG PUID=1000
794+
ENV PUID ${PUID}
795+
ARG PGID=1000
796+
ENV PGID ${PGID}
797+
798+
RUN groupmod -o -g ${PGID} www-data && \
799+
usermod -o -u ${PUID} -g www-data www-data
793800

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

0 commit comments

Comments
 (0)