-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
30 lines (23 loc) · 818 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Using a base Python image
FROM python:3.9-slim
# Setting the working directory
WORKDIR /app
# Installing MySQL client, cron, and other system dependencies
RUN apt-get update && apt-get install -y \
default-mysql-client \
cron \
&& rm -rf /var/lib/apt/lists/*
# Copying requirements.txt and installing Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copying the Python script and cron configuration file to the container
COPY backup_script.py .
COPY crontab /etc/cron.d/backup-cron
# Setting correct permissions for the cron file
RUN chmod 0644 /etc/cron.d/backup-cron
RUN chmod +x /app/backup_script.py
# Applying the cron configuration
RUN crontab /etc/cron.d/backup-cron
RUN touch /var/log/cron.log
# Starting cron in the foreground
CMD ["cron", "-f"]