diff --git a/Dockerfile b/Dockerfile index b213492..d0e0e74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,40 +1,27 @@ FROM php:8.3-fpm -# Install system dependencies & PHP extensions +# Install dependencies & extensions RUN apt-get update && apt-get install -y \ - libzip-dev \ - unzip \ - git \ - libpq-dev \ - libicu-dev \ - zip \ - curl \ - && docker-php-ext-install \ - intl \ - zip \ - pdo_pgsql \ - bcmath + libzip-dev unzip git libpq-dev libicu-dev zip curl \ + && docker-php-ext-install intl zip pdo_pgsql bcmath # Install Composer COPY --from=composer:2 /usr/bin/composer /usr/bin/composer -# Set working directory WORKDIR /var/www -# Copy source +# Copy project files including entrypoint.sh COPY . . -COPY .env.example .env -# Install dependencies -RUN composer install --no-interaction --prefer-dist --optimize-autoloader +# Beri permission executable ke entrypoint.sh +RUN chmod +x /var/www/entrypoint.sh -# Generate app key -RUN php artisan key:generate - -# Set permissions -RUN chown -R www-data:www-data /var/www \ - && chmod -R 775 storage bootstrap/cache \ - && chown -R www-data:www-data storage bootstrap/cache +# Set permissions folder storage dan cache +RUN mkdir -p storage/framework/{cache,sessions,views} bootstrap/cache && \ + chown -R www-data:www-data storage bootstrap/cache && \ + chmod -R 775 storage bootstrap/cache EXPOSE 9000 -CMD ["php-fpm"] \ No newline at end of file + +# Set entrypoint +ENTRYPOINT ["/var/www/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..ee13346 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Install dependencies via composer (non-interactive) +composer install --no-interaction --prefer-dist --optimize-autoloader + +# Cache config, routes, views +php artisan config:cache +php artisan route:cache +php artisan view:cache + +# Jalankan migration otomatis dengan force (untuk production) +php artisan migrate --force + +# Jalankan php-fpm (foreground) +exec php-fpm -F