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

This commit is contained in:
eko
2026-03-16 07:30:56 +07:00
parent 12ae42442c
commit 231618e561

View File

@@ -26,33 +26,36 @@ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /var/www/html WORKDIR /var/www/html
# Copy all application files # Copy all application files (including your .env)
COPY --chown=www-data:www-data . . COPY --chown=www-data:www-data . .
# Create the missing Helper file # Create the missing Helper file
RUN mkdir -p app/Helpers && \ RUN mkdir -p app/Helpers && \
echo "<?php\n\nnamespace App\Helpers;\n\nclass Helper\n{\n public static function formatCurrency(\$amount, \$currency = 'INR')\n {\n return \$currency . ' ' . number_format(\$amount, 2);\n }\n\n public static function generateRandomString(\$length = 10)\n {\n return substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, \$length);\n }\n}\n" > app/Helpers/Helper.php echo "<?php\n\nnamespace App\Helpers;\n\nclass Helper\n{\n public static function formatCurrency(\$amount, \$currency = 'INR')\n {\n return \$currency . ' ' . number_format(\$amount, 2);\n }\n\n public static function generateRandomString(\$length = 10)\n {\n return substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, \$length);\n }\n}\n" > app/Helpers/Helper.php
# Create ALL Laravel required directories with proper permissions # Create ALL Laravel storage directories with proper permissions
RUN mkdir -p storage/framework/{cache,sessions,views} \ RUN mkdir -p storage/framework/{cache,sessions,views} \
&& mkdir -p storage/framework/testing \
&& mkdir -p storage/logs \ && mkdir -p storage/logs \
&& mkdir -p storage/app/public \
&& mkdir -p bootstrap/cache \ && mkdir -p bootstrap/cache \
&& mkdir -p public/storage \ && chown -R www-data:www-data storage bootstrap/cache \
&& chown -R www-data:www-data storage bootstrap/cache public/storage \
&& chmod -R 775 storage bootstrap/cache \ && chmod -R 775 storage bootstrap/cache \
&& chmod -R 777 storage/framework/sessions \ && chmod -R 777 storage/framework/sessions \
&& chmod -R 777 storage/logs && chmod -R 777 storage/logs
# Create .env file if it doesn't exist (required for Laravel) # Verify directories exist (debug step)
RUN if [ ! -f .env ]; then cp .env.example .env 2>/dev/null || echo "APP_ENV=production\nAPP_DEBUG=false\nAPP_URL=https://kode.sadateknologi.site" > .env; fi RUN ls -la storage/framework/ && ls -la bootstrap/
# Generate key if .env exists (but don't fail if it doesn't) # 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 RUN php artisan key:generate --no-interaction --force || true
# Install dependencies # Final permission check
RUN composer install --no-dev --no-interaction --no-progress --optimize-autoloader RUN chmod -R 775 storage bootstrap/cache
# Create startup script # Create startup script
RUN echo '#!/bin/sh' > /start.sh && \ RUN echo '#!/bin/sh' > /start.sh && \