Compare commits

...

9 Commits
0.1.2 ... main

Author SHA1 Message Date
Paolo Asperti a569e48273
added bitwarden and migrated to debian
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2022-10-20 23:30:03 +02:00
Paolo Asperti 6a63e9cd88
don't update crontab file if ENV missing 2022-10-19 22:44:42 +02:00
Paolo Asperti febac4d60f
timezone support
continuous-integration/drone/push Build is passing Details
2022-09-21 08:38:29 +02:00
Paolo Asperti 036592473b
better entrypoint, crontab in env
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2022-09-20 12:53:35 +02:00
Paolo Asperti ff52dbda78
custom crontab
continuous-integration/drone/push Build is passing Details
2022-09-20 12:18:20 +02:00
Paolo Asperti 64c6cb7e4c
added cron and branch build
continuous-integration/drone/push Build is passing Details
2022-09-20 11:56:23 +02:00
Paolo Asperti eebb72fa0f
added cron and branch build
continuous-integration/drone/push Build encountered an error Details
2022-09-20 11:55:57 +02:00
Paolo Asperti 06dec54029
added cron and branch build 2022-09-20 11:52:56 +02:00
Paolo Asperti 6468a01914
added logrotate and crond entrypoint
continuous-integration/drone/tag Build is passing Details
2022-09-20 11:23:37 +02:00
5 changed files with 79 additions and 8 deletions

View File

@ -3,7 +3,7 @@ type: docker
name: default
steps:
- name: build_and_publish
- name: build_and_publish_tag
image: plugins/docker:linux-amd64
settings:
force_tag: true
@ -23,6 +23,23 @@ steps:
event:
- tag
trigger:
event:
- tag
- name: build_and_publish
image: plugins/docker:linux-amd64
settings:
force_tag: true
password:
from_secret: docker_password
registry: docker.asperti.com
repo: docker.asperti.com/paspo/python-runner
context: docker
dockerfile: docker/Dockerfile
username:
from_secret: docker_username
tags:
- latest
when:
branch:
- main
event:
- push
- cron

View File

@ -3,3 +3,31 @@
[![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
- ./crontabs:/etc/cron.d:ro
environment:
TZ: Europe/Rome
```
```bash
mkdir scripts logs crontabs
touch scripts/test.py && chmod +x scripts/test.py
touch scripts/test2.py && chmod +x scripts/test2.py
cat <<EOF >crontabs/myscripts
*/5 7-22 * * * /scripts/test.py
*/10 7-22 * * * /scripts/test2.py
EOF
docker-compose up -d
```

View File

@ -1,5 +1,20 @@
FROM alpine:3.16
RUN \
apk -U add python3 py3-pip py3-requests py3-dateutil py3-beautifulsoup4 && \
pip3 install fdb mysql-connector-python==8.0.29 telepot caldav
FROM debian:bullseye-slim
COPY logrotate-cron /etc/logrotate.d
COPY entrypoint.sh /
RUN \
mkdir /scripts /crontabs && \
apt update && \
DEBIAN_FRONTEND=noninteractive apt -y upgrade && \
DEBIAN_FRONTEND=noninteractive apt -y install wget python3 python3-pip python3-dateutil python3-requests python3-bs4 logrotate unzip tzdata && \
pip3 install fdb mysql-connector-python==8.0.29 telepot caldav && \
wget -O /tmp/bw.zip 'https://vault.bitwarden.com/download/?app=cli&platform=linux' && \
unzip /tmp/bw.zip -d /usr/local/bin && \
chmod +x /usr/local/bin/bw && \
rm /tmp/bw.zip
ENV CRONTAB=""
ENV TZ="Europe/Rome"
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]

3
docker/entrypoint.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
/usr/sbin/cron -f -L /var/log/cron.log

8
docker/logrotate-cron Normal file
View File

@ -0,0 +1,8 @@
/var/log/cron.log {
rotate 4
compress
delaycompress
missingok
notifempty
sharedscripts
}