aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2021-04-19 21:41:50 +0100
committerjwansek <eddie.atten.ea29@gmail.com>2021-04-19 21:41:50 +0100
commit6f29d39a9727688f7f4b25670614abbe66baa957 (patch)
tree660b46805d3e52113f38a4a41bedfa8ea8c03bda
parentb37b71c5209c44a02679b14eca4215f9ec0824f2 (diff)
downloadSmallYTChannelBot-6f29d39a9727688f7f4b25670614abbe66baa957.tar.gz
SmallYTChannelBot-6f29d39a9727688f7f4b25670614abbe66baa957.zip
added cron docker container, added docker-compose
-rwxr-xr-x.gitignore1
-rwxr-xr-xSmallYTChannelDatabase.dbbin27417600 -> 0 bytes
-rw-r--r--docker-compose.yml14
-rw-r--r--onceaday/Dockerfile10
-rw-r--r--onceaday/crontab1
-rw-r--r--[-rwxr-xr-x]onceaday/onceaday.py (renamed from onceaday.py)7
-rw-r--r--onceaday/requirements.txt (renamed from oadrequirements.txt)0
-rwxr-xr-xreadme.md8
8 files changed, 35 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index c838c6a..09dcb3e 100755
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ chblacklist.txt
api.log
config.json
*.log
+*.db
# Byte-compiled / optimized / DLL files
__pycache__/
diff --git a/SmallYTChannelDatabase.db b/SmallYTChannelDatabase.db
deleted file mode 100755
index aa102d9..0000000
--- a/SmallYTChannelDatabase.db
+++ /dev/null
Binary files differ
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..171539e
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,14 @@
+version: '3'
+
+services:
+ sytc:
+ build:
+ context: .
+ dockerfile: Dockerfile
+ image: jwansek/smallytchannelbot
+ network_mode: host
+ cron:
+ build:
+ context: .
+ dockerfile: ./onceaday/Dockerfile
+ network_mode: host \ No newline at end of file
diff --git a/onceaday/Dockerfile b/onceaday/Dockerfile
new file mode 100644
index 0000000..b737d90
--- /dev/null
+++ b/onceaday/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 onceaday/crontab /etc/cron.d/oad-crontab
+RUN chmod 0644 /etc/cron.d/oad-crontab && crontab /etc/cron.d/oad-crontab
+RUN pip3 install -r onceaday/requirements.txt
+ENTRYPOINT ["cron", "-f"] \ No newline at end of file
diff --git a/onceaday/crontab b/onceaday/crontab
new file mode 100644
index 0000000..c8ce32a
--- /dev/null
+++ b/onceaday/crontab
@@ -0,0 +1 @@
+@daily python3 /app/onceaday/onceaday.py /app/onceaday
diff --git a/onceaday.py b/onceaday/onceaday.py
index 1570c9a..97705c7 100755..100644
--- a/onceaday.py
+++ b/onceaday/onceaday.py
@@ -1,7 +1,10 @@
import os
-from operator import itemgetter
-os.chdir("/home/eden/SmallYTChannelBotSubmissions")
+import sys
+
+os.chdir(sys.argv[1])
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
+from operator import itemgetter
import subreddit
import database
import datetime
diff --git a/oadrequirements.txt b/onceaday/requirements.txt
index 23c2cef..23c2cef 100644
--- a/oadrequirements.txt
+++ b/onceaday/requirements.txt
diff --git a/readme.md b/readme.md
index b826e5a..8737117 100755
--- a/readme.md
+++ b/readme.md
@@ -8,13 +8,13 @@ The source code for /u/SmallYTChannelBot.
- Edit the configuration file and rename
-- Build the image:
+- Build the images:
-`sudo docker build -t smallytchannelbot:latest .`
+`sudo docker-compose build`
-- Start the container:
+- Start the containers:
-`sudo docker run --name smallytchannelbot --net=host -d smallytchannelbot`
+`sudo docker-compose up -d`
# TODOs