1
0
mirror of https://github.com/serega404/VodokanalBot.git synced 2025-04-20 14:00:45 +03:00

Add Docker support

This commit is contained in:
Sergey Karmanov 2023-03-25 14:08:16 +03:00
parent 2a968f3528
commit 5388901294
Signed by: serega404
GPG Key ID: 97CADD982D88DF68
4 changed files with 27 additions and 3 deletions

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM python:3.11.2-alpine3.17
LABEL Maintainer="serega404"
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
# Setting up crontab
COPY crontab /tmp/crontab
RUN cat /tmp/crontab > /etc/crontabs/root
COPY main.py main.py
# run crond as main process of container
CMD ["crond", "-f", "-l", "2"]

2
crontab Normal file
View File

@ -0,0 +1,2 @@
@reboot cd /app && python3 /app/main.py
*/10 * * * * cd /app && python3 /app/main.py

View File

@ -20,8 +20,8 @@ if TELEGRAM_CHANNEL == '':
# Load database
db = None
if (os.path.isfile('db.json')):
with open('db.json', 'r', encoding='utf-8') as f:
if (os.path.isfile('data/db.json')):
with open('data/db.json', 'r', encoding='utf-8') as f:
db = json.load(f)
else:
print("Database not loaded")
@ -71,6 +71,9 @@ else:
# Save database
with open('db.json', 'w', encoding='utf-8') as f:
if not os.path.exists("data"):
os.makedirs("data")
with open('data/db.json', 'w', encoding='utf-8') as f:
json.dump(elements, f, ensure_ascii=False)
print("Database updated")

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
requests
beautifulsoup4