Service-Checker/Dockerfile

30 lines
863 B
Docker

# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy the current directory contents into the container at /usr/src/app
COPY . .
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Install cron
RUN apt-get update && apt-get install -y cron
# Add the cron job to run the Python script weekly (every Sunday at 3 AM)
RUN echo "*/5 * * * * /usr/local/bin/python /usr/src/app/main.py >> /var/log/cron.log 2>&1" > /etc/cron.d/weekly_job
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/weekly_job
# Apply cron job
RUN crontab /etc/cron.d/weekly_job
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# Run the cron job
CMD cron && tail -f /var/log/cron.log
#0 11 * * 0