-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (33 loc) · 1.13 KB
/
Copy pathDockerfile
File metadata and controls
45 lines (33 loc) · 1.13 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Use an official Python runtime as a parent image
FROM python:3.12-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV TZ=America/Chicago
# Install cron and any other system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends cron \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory in the container
WORKDIR /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir requests
# Copy the rest of the application code
COPY activate.py .
COPY entrypoint.sh .
COPY crontab.txt .
# Give execution permissions to the entrypoint script
RUN chmod +x entrypoint.sh
# Create the directory for persistent data
RUN mkdir /data
# Add the cron job
RUN crontab crontab.txt
# Create a log file for cron and grant permissions (optional but helpful for debugging)
RUN touch /var/log/cron.log
RUN chmod 666 /var/log/cron.log
# Define the mount point for persistent data
VOLUME /data
# Run entrypoint.sh when the container launches
ENTRYPOINT ["/app/entrypoint.sh"]
# Start cron in the foreground
# CMD is passed as arguments to ENTRYPOINT
CMD ["cron", "-f"]