Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
Paolo Asperti | a569e48273 | |
Paolo Asperti | 6a63e9cd88 | |
Paolo Asperti | febac4d60f | |
Paolo Asperti | 036592473b | |
Paolo Asperti | ff52dbda78 | |
Paolo Asperti | 64c6cb7e4c | |
Paolo Asperti | eebb72fa0f | |
Paolo Asperti | 06dec54029 | |
Paolo Asperti | 6468a01914 | |
Paolo Asperti | a5b5857225 |
26
.drone.yaml
26
.drone.yaml
|
@ -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
|
||||
|
@ -12,6 +12,7 @@ steps:
|
|||
registry: docker.asperti.com
|
||||
repo: docker.asperti.com/paspo/python-runner
|
||||
context: docker
|
||||
dockerfile: docker/Dockerfile
|
||||
username:
|
||||
from_secret: docker_username
|
||||
tags:
|
||||
|
@ -22,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
|
||||
|
|
28
README.md
28
README.md
|
@ -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
|
||||
```
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
/usr/sbin/cron -f -L /var/log/cron.log
|
|
@ -0,0 +1,8 @@
|
|||
/var/log/cron.log {
|
||||
rotate 4
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
sharedscripts
|
||||
}
|
Loading…
Reference in New Issue