Added cronjob to Dockerfile

This commit is contained in:
Keannu Christian Bernasol 2023-10-02 01:32:03 +08:00
parent a970c4c925
commit 9515b25a7b
2 changed files with 23 additions and 1 deletions

View file

@ -17,7 +17,9 @@ RUN apt-get update && apt-get install -y \
libminizip-dev \
libspatialite-dev \
gdal-bin \
libsqlite3-mod-spatialite
libsqlite3-mod-spatialite \
cron \
vim
# Create directory
RUN mkdir /code
@ -40,5 +42,23 @@ RUN python stude/manage.py custom_migrate
# Generate DRF Spectacular Documentation
RUN python stude/manage.py spectacular --color --file stude/schema.yml
# Copy the cronjob file
COPY cronjob /etc/cron.d/cronjob
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/cronjob
# Apply cron job
RUN crontab /etc/cron.d/cronjob
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# Set editor as VIM
RUN export EDITOR=vim
# Run the command on container startup
CMD cron
# Expose port 8000 for the web server
EXPOSE 8000