Add non-root user to PHP Docker images for security
- Create appuser (UID 1000) in dev and prod Dockerfiles - Set USER appuser to avoid running as root Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,4 +25,8 @@ RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
RUN pecl install redis imagick \
|
||||
&& docker-php-ext-enable redis imagick
|
||||
|
||||
RUN groupadd -g 1000 appuser && useradd -u 1000 -g appuser -m appuser
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
USER appuser
|
||||
|
||||
@@ -29,4 +29,8 @@ RUN pecl install redis imagick \
|
||||
COPY php.ini /usr/local/etc/php/conf.d/app.ini
|
||||
COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini
|
||||
|
||||
RUN groupadd -g 1000 appuser && useradd -u 1000 -g appuser -m appuser
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
USER appuser
|
||||
|
||||
Reference in New Issue
Block a user