diff --git a/README.md b/README.md index 3b51cbc..5cc66ba 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,28 @@ [![Build Status](https://drone.asperti.com/api/badges/paspo/docker-python-runner/status.svg)](https://drone.asperti.com/paspo/docker-python-runner) Base docker container for running python scripts. + +## usage + +```yaml +version: '3.6' +services: + runner: + image: docker.asperti.com/paspo/python-runner:latest + container_name: python-scripts + restart: unless-stopped + volumes: + - ./scripts:/scripts + - ./logs:/var/log + environment: + CRONTAB: > + */5 7-22 * * * /scripts/test.py + */10 7-22 * * * /scripts/test2.py +``` + +```bash +mkdir scripts logs +touch scripts/test.py && chmod +x scripts/test.py +touch scripts/test2.py && chmod +x scripts/test2.py +docker-compose up -d +``` diff --git a/docker/Dockerfile b/docker/Dockerfile index c420eeb..92829ca 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,10 +1,13 @@ FROM alpine:3.16 COPY logrotate-cron /etc/logrotate.d +COPY entrypoint.sh / RUN \ mkdir /scripts /crontabs && \ apk -U add python3 py3-pip py3-requests py3-dateutil py3-beautifulsoup4 logrotate && \ pip3 install fdb mysql-connector-python==8.0.29 telepot caldav -ENTRYPOINT ["/usr/sbin/crond", "-f", "-d8", "-L", "/var/log/cron.log", "-c", "/crontabs"] +ENV CRONTAB="" + +ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..cc337f0 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "${CRONTAB}" > /crontabs/root + +/usr/sbin/crond -f -d8 -L /var/log/cron.log -c /crontabs