Updates for permission handling in the container

This commit is contained in:
David Bomba
2024-11-23 20:58:56 +11:00
parent 6f92d1c155
commit d05e55a24e
2 changed files with 18 additions and 12 deletions

14
debian/Dockerfile vendored
View File

@@ -127,6 +127,9 @@ RUN set -eux; \
rm -f /tmp/ninja.tar && \
chown -R www-data:www-data /var/www/html
# After setting permissions, switch to www-data for remaining operations
USER www-data
# Install dependencies
RUN composer install --no-dev --no-scripts --no-autoloader
@@ -137,6 +140,8 @@ RUN composer dump-autoload --optimize \
&& php artisan config:cache \
&& php artisan route:cache
USER root
# Setup supervisor
COPY supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
@@ -157,7 +162,7 @@ RUN mkdir -p \
/var/www/html/storage/framework/sessions \
/var/www/html/storage/framework/views \
/var/www/html/storage/logs \
/var/www/html/public/uploads \
/var/www/html/public/storage \
/var/run \
/var/log/supervisor
@@ -165,16 +170,19 @@ RUN mkdir -p \
RUN chown -R www-data:www-data \
/var/www/html/storage \
/var/www/html/bootstrap/cache \
/var/www/html/public/uploads \
/var/www/html/public/storage \
/var/run \
/var/log/supervisor \
&& chmod -R 775 \
/var/www/html/public/uploads \
/var/www/html/public/storage \
/var/www/html/storage \
/var/www/html/bootstrap/cache \
/var/run \
/var/log/supervisor
# Switch to www-data for runtime
USER www-data
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD php -v || exit 1