From 574635bf096f8cde0a7b825f300c326157e8e6ca Mon Sep 17 00:00:00 2001 From: jwansek Date: Tue, 25 May 2021 12:18:25 +0100 Subject: dockerised the program --- Dockerfile | 10 ++++++++++ bot.py | 2 +- crontab | 1 + docker-compose.yml | 9 +++++++++ readme.md | 8 ++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 crontab create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fb7d715 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM debian:latest +MAINTAINER Eden Attenborough "eddie.atten.ea29@gmail.com" +RUN apt-get update -y +RUN apt-get install -y tzdata python3-pip python-dev build-essential pkg-config cron +COPY . /app +WORKDIR /app +COPY crontab /etc/cron.d/oad-crontab +RUN chmod 0644 /etc/cron.d/oad-crontab && crontab /etc/cron.d/oad-crontab +RUN pip3 install -r requirements.txt +ENTRYPOINT ["cron", "-f"] \ No newline at end of file diff --git a/bot.py b/bot.py index 5ed95eb..1148b93 100755 --- a/bot.py +++ b/bot.py @@ -1,5 +1,5 @@ import os -os.chdir("/home/eden/yaoi-communism") +os.chdir("/app") from twython import Twython import get_images diff --git a/crontab b/crontab new file mode 100644 index 0000000..5ef7b80 --- /dev/null +++ b/crontab @@ -0,0 +1 @@ +0 */3 * * * python3 /app/bot.py \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..03b3bc7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: '3' + +services: + cron: + build: + context: . + dockerfile: Dockerfile + image: jwansek/yaoi-communism + network_mode: host diff --git a/readme.md b/readme.md index 2eff7ae..879b8f3 100755 --- a/readme.md +++ b/readme.md @@ -18,4 +18,12 @@ Designed to be run once an hour using a cron job. - `python3 bot.py` +## running in docker + +- `sudo docker-compose build` + +- `sudo docker-compose up -d` + +Should do everything by itself if you set the config file correctly + ![Example image](https://pbs.twimg.com/media/EgSA-hVXoAIXLbB?format=jpg&name=large) -- cgit v1.2.3