sw-jobs-api/scrapers/Dockerfile

30 lines
742 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.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
# 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
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
# 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"]