sw-jobs-api/scrapers/Dockerfile

28 lines
739 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
2024-05-29 22:38:46 +00:00
# Copy the current directory contents into the container at /app
COPY . /app
2024-06-01 15:02:24 +00:00
# Install cron and the required Python packages
RUN apt-get update && apt-get install -y cron && \
pip install requests beautifulsoup4
2024-06-01 14:58:39 +00:00
# Copy and add a cron job to run the script every hour
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