Compare commits
5
Commits
898e42e0b7
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
565474ad1b | ||
|
|
ac0eb74551 | ||
|
|
41b25aab53 | ||
|
|
7933ee81eb | ||
|
|
cdd629cea4 |
No files matched your search
+10
-8
@@ -2,7 +2,7 @@
|
||||
FROM python:3.9-slim
|
||||
|
||||
# Install cron
|
||||
RUN apt-get update && apt-get install -y cron
|
||||
RUN apt-get update && apt-get install -y cron nano
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /usr/cta-archive/
|
||||
@@ -13,17 +13,19 @@ COPY . .
|
||||
# Install any needed packages
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Load environment variable into cron job, as these aren't automatically passed
|
||||
RUN echo ''
|
||||
# Copy the cron job file into the cron.d directory
|
||||
COPY cronjob /etc/cron.d/cronjob
|
||||
RUN echo ' */5 * * * * /usr/local/bin/python3 /usr/cta-archive/archive.py ' >> /usr/cta-archive/cronjob
|
||||
|
||||
# Give execution rights on the cron job
|
||||
RUN chmod 0644 /etc/cron.d/cronjob
|
||||
RUN chmod 0644 /usr/cta-archive/cronjob
|
||||
|
||||
# Apply the cron job
|
||||
RUN crontab /etc/cron.d/cronjob
|
||||
# Add cron job
|
||||
RUN crontab /usr/cta-archive/cronjob
|
||||
|
||||
# Create the log file to be able to run tail
|
||||
RUN touch /var/log/cron_python.log
|
||||
# Create logfile
|
||||
RUN touch /var/log/cron.log
|
||||
|
||||
# Run the command on container startup
|
||||
CMD ["cron","-f" ]
|
||||
ENTRYPOINT [ "/usr/cta-archive/entrypoint.sh" ]
|
||||
@@ -5,7 +5,18 @@ Clone this archive, build and run the image. Pass in your API_KEY and map the ou
|
||||
git clone https://gitea.iosull.com/iosullivan/cta-archive
|
||||
cd cta-archive
|
||||
docker build -t cta-archive .
|
||||
docker run cta-archive --name cta-archive -d -e API_KEY=<APIKey> -v <outputdir>/usr/cta-archive/output/
|
||||
docker run --name cta-archive -d -e API_KEY=<APIKey> -v <outputdir>:/usr/cta-archive/output/ cta-archive
|
||||
```
|
||||
|
||||
By default, the script runs every 5 minutes to write json file to the <outputdir> above. This can be modified by updating the cronjob file.
|
||||
## Configuration
|
||||
|
||||
By default, the script runs every 5 minutes to write json file to the <outputdir> above. This can be modified by updating the following line in the Dockerfile:
|
||||
```
|
||||
RUN echo ' */5 * * * * /usr/local/bin/python3 /usr/cta-archive/archive.py ' >> /usr/cta-archive/cronjob
|
||||
|
||||
# Where 5 indicates every 5th minute.
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
This script runs as root within the container. It probably shouldn't.
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
printenv >> /etc/environment
|
||||
|
||||
cron -f
|
||||
Reference in new issue
Block a user