Skip to content

Commit

Permalink
Merge pull request #644 from turbo124/debian
Browse files Browse the repository at this point in the history
Fixes for permissions on container init
  • Loading branch information
turbo124 authored Nov 23, 2024
2 parents 4431abc + 1b62d86 commit d5bb90f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
23 changes: 4 additions & 19 deletions debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,9 @@ WORKDIR /var/www/html
RUN set -eux; \
DOWNLOAD_URL=$(curl -s "https://api.github.com/repos/invoiceninja/invoiceninja/releases/latest" | \
grep -o '"browser_download_url": "[^"]*invoiceninja.tar"' | cut -d '"' -f 4) && \
echo "Downloading from: $DOWNLOAD_URL" && \
# 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 && \
curl -L "$DOWNLOAD_URL" | tar -xvz -C /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
RUN composer install --no-dev --no-scripts --no-autoloader

Expand All @@ -140,8 +130,6 @@ 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

Expand All @@ -162,27 +150,24 @@ RUN mkdir -p \
/var/www/html/storage/framework/sessions \
/var/www/html/storage/framework/views \
/var/www/html/storage/logs \
/var/www/html/public/storage \
/var/www/html/public/uploads \
/var/run \
/var/log/supervisor

# Set permissions
RUN chown -R www-data:www-data \
/var/www/html/storage \
/var/www/html/bootstrap/cache \
/var/www/html/public/storage \
/var/www/html/public/uploads \
/var/run \
/var/log/supervisor \
&& chmod -R 775 \
/var/www/html/public/storage \
/var/www/html/public/uploads \
/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
Expand Down
1 change: 0 additions & 1 deletion debian/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ services:
- app_storage:/var/www/html/storage
- app_cache:/var/www/html/bootstrap/cache
- public_storage:/var/www/html/public/storage
user: www-data:www-data

networks:
- app-network
Expand Down

0 comments on commit d5bb90f

Please sign in to comment.