From 64877e4e48f0e6737b22a6bb733df72e2df5028e Mon Sep 17 00:00:00 2001 From: JuniorJPDJ Date: Mon, 3 Aug 2020 10:08:59 +0000 Subject: [PATCH 1/4] Basic docker support --- Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..445170b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:alpine + +RUN apk add --no-cache gettext + +WORKDIR /app/ +COPY . . + +RUN cd locales && find . -maxdepth 2 -type d -name 'LC_MESSAGES' -exec ash -c 'msgfmt {}/unobot.po -o {}/unobot.mo' \; + +RUN pip install -r requirements.txt + +ENTRYPOINT python3 ./bot.py From 46bc6c4dbe93a75548037b53bd715bf1b30d4d5a Mon Sep 17 00:00:00 2001 From: JuniorJPDJ Date: Wed, 23 Dec 2020 16:59:12 +0100 Subject: [PATCH 2/4] Changable db path --- shared_vars.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared_vars.py b/shared_vars.py index ad47c50..a2e1993 100644 --- a/shared_vars.py +++ b/shared_vars.py @@ -20,12 +20,13 @@ from config import TOKEN, WORKERS import logging +import os from telegram.ext import Updater from game_manager import GameManager from database import db -db.bind('sqlite', 'uno.sqlite3', create_db=True) +db.bind('sqlite', os.getenv('UNO_DB', 'uno.sqlite3'), create_db=True) db.generate_mapping(create_tables=True) gm = GameManager() From e5dae6db990cd334ad68490d40d60fa56d85d6d7 Mon Sep 17 00:00:00 2001 From: JuniorJPDJ Date: Wed, 23 Dec 2020 17:05:36 +0100 Subject: [PATCH 3/4] Persistent db in docker --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 445170b..5217d0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,4 +9,7 @@ RUN cd locales && find . -maxdepth 2 -type d -name 'LC_MESSAGES' -exec ash -c 'm RUN pip install -r requirements.txt +VOLUME /app/data +ENV UNO_DB /app/data/uno.sqlite3 + ENTRYPOINT python3 ./bot.py From 6712b5c3628cfdf2dd63f32dc55cca18d85f2df1 Mon Sep 17 00:00:00 2001 From: JuniorJPDJ Date: Fri, 25 Dec 2020 17:41:15 +0100 Subject: [PATCH 4/4] Dockerfile with better caching thanks @divadsn --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 5217d0d..55bc0d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,9 @@ FROM python:alpine RUN apk add --no-cache gettext WORKDIR /app/ +COPY requirements.txt . +RUN pip install -r requirements.txt + COPY . . RUN cd locales && find . -maxdepth 2 -type d -name 'LC_MESSAGES' -exec ash -c 'msgfmt {}/unobot.po -o {}/unobot.mo' \;