Skip to content

Commit ab8ac81

Browse files
committed
fix: resolve ownership
1 parent ef007b4 commit ab8ac81

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fpm-alpine/8.3/dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,15 @@ RUN apk del --no-cache \
7676
libtool && \
7777
rm -rf /var/cache/apk/* /tmp/* /var/tmp/*
7878

79-
# Create a non-root user for security
80-
RUN addgroup -S ${GROUP} && adduser -S ${USER} -G ${GROUP} && \
81-
mkdir -p /var/www/html && \
82-
chown -R ${USER}:${GROUP} /var/www/html
79+
# Set the working directory
80+
WORKDIR /var/www
8381

84-
WORKDIR /var/www/html
82+
# Create a non-root user and group
83+
RUN getent group ${GROUP} || addgroup -g 1000 ${GROUP}
84+
RUN id -u ${USER} || adduser --shell /sbin/nologin --disabled-password --no-create-home --uid 1000 --ingroup ${GROUP} ${USER}
85+
86+
# Grant write permissions to the non-root user and group
87+
RUN chown -R ${USER}:${GROUP} /var/www
8588

8689
# Expose PHP-FPM port
8790
EXPOSE 9000

0 commit comments

Comments
 (0)