- 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.
This commit is contained in:
Ümit Tunç
2025-01-21 11:06:55 +03:00
parent 74d2e3e602
commit f860ce5e5c
Regular → Executable
+12 -5
View File
@@ -16,11 +16,13 @@ RUN apt-get update && apt-get install -y \
zip \ zip \
cron \ cron \
ntp \ ntp \
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd \ && service cron start && \
&& echo "* * * * * cd /var/www && php artisan schedule:run >> /dev/null 2>&1" >> /etc/cron.d/laravel-cron \ 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 \ && chmod 0644 /etc/cron.d/laravel-cron \
&& crontab /etc/cron.d/laravel-cron \ && crontab /etc/cron.d/laravel-cron
&& service cron start
# Composer'ı yükleyelim # Composer'ı yükleyelim
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer 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 # Laravel proje dosyalarını kopyalayalım
COPY . . COPY . .
# Gerekli dizinleri oluşturma # Gerekli dizinleri oluşturma
RUN mkdir -p /var/www/storage/app/private/scribe RUN mkdir -p /var/www/storage/app/private/scribe
@@ -66,4 +69,8 @@ RUN set -x && \
echo "Storage sembolik bağlantısı oluşturuldu" && \ echo "Storage sembolik bağlantısı oluşturuldu" && \
php artisan scribe:generate && \ php artisan scribe:generate && \
echo "API dokümantasyonu oluşturuldu" && \ echo "API dokümantasyonu oluşturuldu" && \
echo "Laravel uygulaması başarıyla başlatıldı."; echo "Laravel uygulaması başarıyla başlatıldı.";
RUN service cron start && \
echo "Cron başlatıldı"