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:
parent
2a968f3528
commit
5388901294
17
Dockerfile
Normal file
17
Dockerfile
Normal 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
2
crontab
Normal file
@ -0,0 +1,2 @@
|
||||
@reboot cd /app && python3 /app/main.py
|
||||
*/10 * * * * cd /app && python3 /app/main.py
|
9
main.py
9
main.py
@ -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
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
requests
|
||||
beautifulsoup4
|
Loading…
x
Reference in New Issue
Block a user