Skip to content

Commit 027616a

Browse files
authored
Updates php.dockerfile with permissions changes
Adds lines to pull in docker-compose arguments to env values. Adds a dynamic addgroup and adduser line to add the user/group associated with the env values, manually returns 0 on that line to always return successful (e.g. when using user root or www-data). Adds sed lines to change the group and user associated with the php service, removes the conf file originally overwriting those. Adds CMD line to start php-fpm with the -R flag, allowing root user.
1 parent 331ba93 commit 027616a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

php.dockerfile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
FROM php:7.4-fpm-alpine
22

3-
ADD ./php/www.conf /usr/local/etc/php-fpm.d/
3+
ARG PHPGROUP
4+
ARG PHPUSER
45

5-
RUN addgroup -g 1000 laravel && adduser -G laravel -g laravel -s /bin/sh -D laravel
6+
ENV PHPGROUP=${PHPGROUP}
7+
ENV PHPUSER=${PHPUSER}
68

7-
RUN mkdir -p /var/www/html
9+
RUN addgroup -g 1000 ${PHPGROUP} && adduser -g ${PHPGROUP} -s /bin/sh -D ${PHPUSER}; exit 0
810

9-
RUN chown laravel:laravel /var/www/html
11+
RUN mkdir -p /var/www/html
1012

1113
WORKDIR /var/www/html
1214

15+
RUN sed -i "s/user = www-data/user = ${PHPUSER}/g" /usr/local/etc/php-fpm.d/www.conf
16+
RUN sed -i "s/group = www-data/group = ${PHPGROUP}/g" /usr/local/etc/php-fpm.d/www.conf
17+
1318
RUN docker-php-ext-install pdo pdo_mysql
1419

1520
RUN mkdir -p /usr/src/php/ext/redis \
1621
&& curl -L https://github.com/phpredis/phpredis/archive/5.3.4.tar.gz | tar xvz -C /usr/src/php/ext/redis --strip 1 \
1722
&& echo 'redis' >> /usr/src/php-available-exts \
1823
&& docker-php-ext-install redis
24+
25+
CMD ["php-fpm", "-y", "/usr/local/etc/php-fpm.conf", "-R"]

0 commit comments

Comments
 (0)