2024-06-01 14:58:39 +00:00
|
|
|
# Use the official Python image from the Docker Hub
|
2024-06-01 16:04:51 +00:00
|
|
|
FROM python:3.12-slim
|
2024-05-29 21:28:58 +00:00
|
|
|
|
2024-06-01 14:58:39 +00:00
|
|
|
# Set the working directory inside the container
|
2024-05-29 21:28:58 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
2024-06-01 15:56:06 +00:00
|
|
|
# Copy the script and requirements.txt into the container at /app
|
2024-06-01 16:07:45 +00:00
|
|
|
COPY jobindex.py .
|
|
|
|
COPY requirements.txt .
|
2024-05-29 22:38:46 +00:00
|
|
|
|
2024-06-01 15:56:06 +00:00
|
|
|
# Install the required Python packages
|
|
|
|
RUN pip install -r requirements.txt
|
2024-06-01 14:58:39 +00:00
|
|
|
|
2024-06-01 15:59:08 +00:00
|
|
|
# Install cron and create log file
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get -y install cron \
|
|
|
|
&& touch /var/log/cron.log
|
|
|
|
|
2024-06-01 15:56:06 +00:00
|
|
|
# Copy the cron job file into the cron directory
|
2024-06-01 14:58:39 +00:00
|
|
|
COPY cronjob /etc/cron.d/jobindex-cron
|
2024-05-29 21:28:58 +00:00
|
|
|
|
|
|
|
# Give execution rights on the cron job
|
2024-06-01 14:58:39 +00:00
|
|
|
RUN chmod 0644 /etc/cron.d/jobindex-cron
|
2024-05-29 21:28:58 +00:00
|
|
|
|
2024-05-29 22:38:46 +00:00
|
|
|
# Apply cron job
|
2024-06-01 14:58:39 +00:00
|
|
|
RUN crontab /etc/cron.d/jobindex-cron
|
2024-05-29 22:38:46 +00:00
|
|
|
|
2024-05-29 21:28:58 +00:00
|
|
|
# Run the command on container startup
|
2024-06-01 15:59:08 +00:00
|
|
|
CMD ["cron", "-f"]
|