sw-jobs-api/scrapers/Dockerfile

28 lines
709 B
Docker
Raw Normal View History

2024-06-01 14:58:39 +00:00
# Use the official Python image from the Docker Hub
FROM python:3.9-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
# Copy the script and requirements.txt into the container at /app
COPY jobindex.py /app/
COPY requirements.txt /app/
2024-05-29 22:38:46 +00:00
# Install the required Python packages
RUN pip install -r requirements.txt
2024-06-01 14:58:39 +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
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# Run the command on container startup
2024-06-01 15:02:24 +00:00
CMD cron && tail -f /var/log/cron.log