fix dockerfile
All checks were successful
Build, Push and Deploy / build-and-deploy (push) Successful in 2m56s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 8s

This commit is contained in:
eko
2026-03-16 09:57:31 +07:00
parent f10e4ca879
commit d8a12dbcc2

View File

@@ -33,26 +33,33 @@ COPY --chown=www-data:www-data . .
RUN mkdir -p app/Helpers && \ RUN mkdir -p app/Helpers && \
echo "<?php\n\nnamespace App\Helpers;\n\nclass Helper\n{\n // Helper functions\n}\n" > app/Helpers/Helper.php echo "<?php\n\nnamespace App\Helpers;\n\nclass Helper\n{\n // Helper functions\n}\n" > app/Helpers/Helper.php
# Install dependencies # CRITICAL: Create storage directories BEFORE composer install
RUN composer install --no-dev --no-interaction --no-progress --optimize-autoloader RUN mkdir -p storage/framework/{cache,sessions,views} \
&& mkdir -p storage/logs \
&& mkdir -p bootstrap/cache \
&& chmod -R 777 storage \
&& chmod -R 777 bootstrap/cache
# Create startup script with directory creation # Verify directories exist (debug)
RUN ls -la storage/framework/ && ls -la bootstrap/
# Install dependencies with --no-scripts first to avoid post-install commands
RUN composer install --no-dev --no-interaction --no-progress --optimize-autoloader --no-scripts
# Now run the post-install scripts (storage exists now)
RUN composer run-script post-autoload-dump || echo "Post-autoload dump skipped"
# Generate key if needed
RUN php artisan key:generate --no-interaction --force || true
# Create startup script with runtime directory creation
RUN echo '#!/bin/sh' > /start.sh && \ RUN echo '#!/bin/sh' > /start.sh && \
echo '' >> /start.sh && \ echo '' >> /start.sh && \
echo '# Create storage directories with proper permissions at runtime' >> /start.sh && \ echo '# Ensure storage directories exist at runtime' >> /start.sh && \
echo 'mkdir -p storage/framework/{cache,sessions,views}' >> /start.sh && \ echo 'mkdir -p storage/framework/{cache,sessions,views}' >> /start.sh && \
echo 'mkdir -p storage/logs' >> /start.sh && \ echo 'mkdir -p storage/logs' >> /start.sh && \
echo 'mkdir -p bootstrap/cache' >> /start.sh && \ echo 'mkdir -p bootstrap/cache' >> /start.sh && \
echo 'chmod -R 775 storage bootstrap/cache' >> /start.sh && \ echo 'chmod -R 777 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.sh && \
echo '# Start the application based on mode' >> /start.sh && \ echo '# Start the application based on mode' >> /start.sh && \
echo 'if [ "$MODE" = "dev" ]; then' >> /start.sh && \ echo 'if [ "$MODE" = "dev" ]; then' >> /start.sh && \