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:
Serreau Jovann
2026-03-19 15:06:49 +01:00
parent 456e0afed8
commit ac677175d3
2 changed files with 8 additions and 0 deletions

View File

@@ -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

View File

@@ -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