chore: Add cron service and crontab for Laravel cron jobs

This commit is contained in:
2024-07-03 20:36:21 +02:00
parent e95066416f
commit 13cd0e1ea2
3 changed files with 10 additions and 0 deletions
+6
View File
@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \
libpq-dev \ libpq-dev \
zip \ zip \
fish \ fish \
cron \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd mbstring zip pdo pdo_mysql pdo_pgsql && docker-php-ext-install gd mbstring zip pdo pdo_mysql pdo_pgsql
@@ -43,6 +44,11 @@ RUN mkdir -p /root/.ssh
COPY entrypoint.sh /usr/local/bin/entrypoint.sh COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh RUN chmod +x /usr/local/bin/entrypoint.sh
# Copy the crontab file into the container
COPY crontab /etc/cron.d/laravel-cron
RUN chmod 0644 /etc/cron.d/laravel-cron
RUN crontab /etc/cron.d/laravel-cron
# Expose ports # Expose ports
EXPOSE 8000 EXPOSE 8000
+1
View File
@@ -0,0 +1 @@
* * * * * root /usr/local/bin/php /workspace/artisan schedule:run >> /var/log/cron.log 2>&1
+3
View File
@@ -47,5 +47,8 @@ if [ -f /environment/.env ]; then
cp /environment/.env /workspace/.env cp /environment/.env /workspace/.env
fi fi
# Start the cron service
service cron start
# Start the application with pm2 # Start the application with pm2
exec pm2-runtime "php artisan serve --host=0.0.0.0 --port=8000" exec pm2-runtime "php artisan serve --host=0.0.0.0 --port=8000"