From f10e4ca879a0ab90afeedf9b713a7992631bbdff Mon Sep 17 00:00:00 2001 From: eko Date: Mon, 16 Mar 2026 09:29:36 +0700 Subject: [PATCH] fix dockerfile --- Dockerfile | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0feea3f..a2ef153 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,39 +26,35 @@ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer WORKDIR /var/www/html -# Copy all application files (including your .env) +# Copy all application files COPY --chown=www-data:www-data . . # Create the missing Helper file RUN mkdir -p app/Helpers && \ - echo " app/Helpers/Helper.php + echo " app/Helpers/Helper.php -# Create ALL Laravel storage directories with proper permissions -RUN mkdir -p storage/framework/{cache,sessions,views} \ - && mkdir -p storage/logs \ - && mkdir -p bootstrap/cache \ - && chown -R www-data:www-data storage bootstrap/cache \ - && chmod -R 775 storage bootstrap/cache \ - && chmod -R 777 storage/framework/sessions \ - && chmod -R 777 storage/logs +# Install dependencies +RUN composer install --no-dev --no-interaction --no-progress --optimize-autoloader -# Verify directories exist (debug step) -RUN ls -la storage/framework/ && ls -la bootstrap/ - -# Install dependencies with --no-scripts first -RUN composer install --no-dev --no-interaction --no-progress --optimize-autoloader --no-scripts - -# Run post-install scripts separately -RUN composer run-script post-autoload-dump || echo "Post-autoload dump skipped" - -# Generate key if not set in .env -RUN php artisan key:generate --no-interaction --force || true - -# Final permission check -RUN chmod -R 775 storage bootstrap/cache - -# Create startup script +# Create startup script with directory creation RUN echo '#!/bin/sh' > /start.sh && \ + echo '' >> /start.sh && \ + echo '# Create storage directories with proper permissions at runtime' >> /start.sh && \ + echo 'mkdir -p storage/framework/{cache,sessions,views}' >> /start.sh && \ + echo 'mkdir -p storage/logs' >> /start.sh && \ + echo 'mkdir -p bootstrap/cache' >> /start.sh && \ + echo 'chmod -R 775 storage bootstrap/cache' >> /start.sh && \ + echo 'chmod -R 777 storage/framework/sessions storage/logs' >> /start.sh && \ + echo 'chown -R www-data:www-data storage bootstrap/cache' >> /start.sh && \ + echo '' >> /start.sh && \ + echo '# Generate key if not set' >> /start.sh && \ + echo 'php artisan key:generate --no-interaction --force || true' >> /start.sh && \ + echo '' >> /start.sh && \ + echo '# Clear cache' >> /start.sh && \ + echo 'php artisan config:clear || true' >> /start.sh && \ + echo 'php artisan cache:clear || true' >> /start.sh && \ + echo '' >> /start.sh && \ + echo '# Start the application based on mode' >> /start.sh && \ echo 'if [ "$MODE" = "dev" ]; then' >> /start.sh && \ echo ' echo "Starting in DEV mode with PHP built-in server on port 8000..."' >> /start.sh && \ echo ' php artisan serve --host=0.0.0.0 --port=8000' >> /start.sh && \