Fixes for permissions on container init

This commit is contained in:
David Bomba
2024-11-24 08:43:50 +11:00
parent d05e55a24e
commit 1b62d86659
2 changed files with 4 additions and 20 deletions

23
debian/Dockerfile vendored
View File

@@ -117,19 +117,9 @@ WORKDIR /var/www/html
RUN set -eux; \ RUN set -eux; \
DOWNLOAD_URL=$(curl -s "https://api.github.com/repos/invoiceninja/invoiceninja/releases/latest" | \ DOWNLOAD_URL=$(curl -s "https://api.github.com/repos/invoiceninja/invoiceninja/releases/latest" | \
grep -o '"browser_download_url": "[^"]*invoiceninja.tar"' | cut -d '"' -f 4) && \ grep -o '"browser_download_url": "[^"]*invoiceninja.tar"' | cut -d '"' -f 4) && \
echo "Downloading from: $DOWNLOAD_URL" && \ curl -L "$DOWNLOAD_URL" | tar -xvz -C /var/www/html && \
# Download and save the tar
curl -L "$DOWNLOAD_URL" -o /tmp/ninja.tar && \
# Try extraction
cd /var/www/html && \
tar -xf /tmp/ninja.tar && \
# List what was extracted
rm -f /tmp/ninja.tar && \
chown -R www-data:www-data /var/www/html chown -R www-data:www-data /var/www/html
# After setting permissions, switch to www-data for remaining operations
USER www-data
# Install dependencies # Install dependencies
RUN composer install --no-dev --no-scripts --no-autoloader RUN composer install --no-dev --no-scripts --no-autoloader
@@ -140,8 +130,6 @@ RUN composer dump-autoload --optimize \
&& php artisan config:cache \ && php artisan config:cache \
&& php artisan route:cache && php artisan route:cache
USER root
# Setup supervisor # Setup supervisor
COPY supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
@@ -162,7 +150,7 @@ RUN mkdir -p \
/var/www/html/storage/framework/sessions \ /var/www/html/storage/framework/sessions \
/var/www/html/storage/framework/views \ /var/www/html/storage/framework/views \
/var/www/html/storage/logs \ /var/www/html/storage/logs \
/var/www/html/public/storage \ /var/www/html/public/uploads \
/var/run \ /var/run \
/var/log/supervisor /var/log/supervisor
@@ -170,19 +158,16 @@ RUN mkdir -p \
RUN chown -R www-data:www-data \ RUN chown -R www-data:www-data \
/var/www/html/storage \ /var/www/html/storage \
/var/www/html/bootstrap/cache \ /var/www/html/bootstrap/cache \
/var/www/html/public/storage \ /var/www/html/public/uploads \
/var/run \ /var/run \
/var/log/supervisor \ /var/log/supervisor \
&& chmod -R 775 \ && chmod -R 775 \
/var/www/html/public/storage \ /var/www/html/public/uploads \
/var/www/html/storage \ /var/www/html/storage \
/var/www/html/bootstrap/cache \ /var/www/html/bootstrap/cache \
/var/run \ /var/run \
/var/log/supervisor /var/log/supervisor
# Switch to www-data for runtime
USER www-data
# Health check # Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \ HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD php -v || exit 1 CMD php -v || exit 1

View File

@@ -17,7 +17,6 @@ services:
- app_storage:/var/www/html/storage - app_storage:/var/www/html/storage
- app_cache:/var/www/html/bootstrap/cache - app_cache:/var/www/html/bootstrap/cache
- public_storage:/var/www/html/public/storage - public_storage:/var/www/html/public/storage
user: www-data:www-data
networks: networks:
- app-network - app-network