From f0aff65ba1d61197a2b644b5098b7a45c8cebbf3 Mon Sep 17 00:00:00 2001 From: christian Date: Sat, 1 Jun 2024 17:56:06 +0200 Subject: [PATCH] scraper dockerfile and cronjob to run when container starts --- scrapers/Dockerfile | 12 ++++++------ scrapers/cronjob | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scrapers/Dockerfile b/scrapers/Dockerfile index 626418e..e970416 100644 --- a/scrapers/Dockerfile +++ b/scrapers/Dockerfile @@ -4,14 +4,14 @@ FROM python:3.9-slim # Set the working directory inside the container WORKDIR /app -# Copy the current directory contents into the container at /app -COPY . /app +# Copy the script and requirements.txt into the container at /app +COPY jobindex.py /app/ +COPY requirements.txt /app/ -# Install cron and the required Python packages -RUN apt-get update && apt-get install -y cron && \ - pip install requests beautifulsoup4 +# Install the required Python packages +RUN pip install -r requirements.txt -# Copy and add a cron job to run the script every hour +# Copy the cron job file into the cron directory COPY cronjob /etc/cron.d/jobindex-cron # Give execution rights on the cron job diff --git a/scrapers/cronjob b/scrapers/cronjob index 49ea0eb..b66c13e 100644 --- a/scrapers/cronjob +++ b/scrapers/cronjob @@ -1,2 +1,2 @@ # Run the jobindex.py script every hour -0 * * * * root python /app/jobindex.py >> /var/log/cron.log 2>&1 +0 * * * * python /app/jobindex.py >> /var/log/cron.log 2>&1