updated api route and scraper dockerfile
Some checks failed
Build and Push Docker Images / build (push) Failing after 32s

This commit is contained in:
ChrQR 2024-05-30 00:26:09 +02:00
parent 862b625056
commit e2cda495d0
2 changed files with 8 additions and 4 deletions

View File

@ -10,7 +10,7 @@ db_file = os.path.join('scrapers', 'jobs_db.json')
# Path to db JSON file for development # Path to db JSON file for development
#db_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'scrapers', 'jobs_db.json') #db_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'scrapers', 'jobs_db.json')
@app.route('/api/jobs', methods=['GET']) @app.route('/jobs', methods=['GET'])
def get_jobs(): def get_jobs():
if os.path.exists(db_file): if os.path.exists(db_file):
with open(db_file, 'r') as file: with open(db_file, 'r') as file:

View File

@ -4,18 +4,22 @@ FROM python:3.9-slim
# Set the working directory in the container # Set the working directory in the container
WORKDIR /app WORKDIR /app
# Install cron and any needed packages specified in requirements.txt
RUN apt-get update && apt-get install -y cron \
&& pip install --no-cache-dir -r requirements.txt
# Copy the current directory contents into the container at /app # Copy the current directory contents into the container at /app
COPY . /app COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy the crontab file to the cron.d directory # Copy the crontab file to the cron.d directory
COPY crontab /etc/cron.d/scraper-cron COPY crontab /etc/cron.d/scraper-cron
# Give execution rights on the cron job # Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/scraper-cron RUN chmod 0644 /etc/cron.d/scraper-cron
# Apply cron job
RUN crontab /etc/cron.d/scraper-cron
# Create the log file to be able to run tail # Create the log file to be able to run tail
RUN touch /var/log/cron.log RUN touch /var/log/cron.log