Run container as unprivileged www-data user and simplify entrypoint

- Remove root-only FPM user configuration from entrypoint.sh (moved to Dockerfile build time)
- Remove Redis session configuration from entrypoint.sh (handled by Symfony services)
- Remove cache directory permission adjustments (unnecessary with proper ownership)
- Set file ownership to www-data:www-data at build time using COPY --chown
- Create required directories and set ownership in single RUN layer
- Switch to www-data USER before CMD
- Remove PHP_FPM_USER, PHP_FPM_GROUP, SESSION_LIFETIME environment variables
- Add docker/ directory to .dockerignore
This commit is contained in:
julielenaerts committed 2026-10-26 11:02:05 +01:00
1 parent b1eb46f902
commit 0e6ec94ae4
3 files changed
+27 -39

No files matched your search

-19
View File
@@ -16,23 +16,6 @@ else
echo "we assume the database is ready";
fi
if [ $(id -u) = "0" ]; then
{ \
echo "[www]"; \
echo ""; \
echo "user=${PHP_FPM_USER}"; \
echo "group=${PHP_FPM_GROUP}"; \
} > /usr/local/etc/php-fpm.d/zz-user.conf
fi
{ \
echo ""; \
echo "session.save_handler = redis" ; \
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_PORT}?db=10\"" ; \
echo "session.gc_maxlifetime = ${SESSION_LIFETIME}" ; \
} >> /usr/local/etc/php/conf.d/custom.ini
if [ "${APP_ENV}" = "prod" ]; then
composer dump-env "${APP_ENV}"
chmod +r /var/www/app/.env.local.php
@@ -48,8 +31,6 @@ fi
if [ "${CLEAR_CACHE}" != "false" ]; then
#prepare cache
php /var/www/app/bin/console cache:clear --no-warmup
chgrp ${PHP_FPM_GROUP} /var/www/app/var/cache -R && chmod g+rw /var/www/app/var/cache -R
chgrp ${PHP_FPM_GROUP} /var/www/app/var/log -R && chmod g+rw /var/www/app/var/log -R
fi
exec "${@}"