From f860ce5e5c75e6d923c48152b4c2e9a96cf283b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Tue, 21 Jan 2025 11:06:55 +0300 Subject: [PATCH] - Enhanced Dockerfile for Laravel application by updating file permissions and improving cron job configuration. - Added NTP service initialization to ensure accurate time synchronization within the container. - Modified cron job command to run all fetch tasks, improving scheduled task management. - Included additional echo statements for better logging during the setup process. These changes improve the Docker environment's reliability and enhance the functionality of scheduled tasks in the Laravel application. --- dockerfile | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) mode change 100644 => 100755 dockerfile diff --git a/dockerfile b/dockerfile old mode 100644 new mode 100755 index 2e3deb5..f140fe9 --- a/dockerfile +++ b/dockerfile @@ -16,11 +16,13 @@ RUN apt-get update && apt-get install -y \ zip \ cron \ ntp \ - && docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd \ - && echo "* * * * * cd /var/www && php artisan schedule:run >> /dev/null 2>&1" >> /etc/cron.d/laravel-cron \ + && service cron start && \ + ntpd -gq && \ + ntpd && \ + docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd \ + && echo "* * * * * cd /var/www && php /var/www/artisan run-all-fetchs >> /dev/null 2>&1" >> /etc/cron.d/laravel-cron \ && chmod 0644 /etc/cron.d/laravel-cron \ - && crontab /etc/cron.d/laravel-cron \ - && service cron start + && crontab /etc/cron.d/laravel-cron # Composer'ı yükleyelim COPY --from=composer:latest /usr/bin/composer /usr/bin/composer @@ -28,6 +30,7 @@ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer # Laravel proje dosyalarını kopyalayalım COPY . . + # Gerekli dizinleri oluşturma RUN mkdir -p /var/www/storage/app/private/scribe @@ -66,4 +69,8 @@ RUN set -x && \ echo "Storage sembolik bağlantısı oluşturuldu" && \ php artisan scribe:generate && \ echo "API dokümantasyonu oluşturuldu" && \ - echo "Laravel uygulaması başarıyla başlatıldı."; \ No newline at end of file + echo "Laravel uygulaması başarıyla başlatıldı."; + + +RUN service cron start && \ + echo "Cron başlatıldı"