Added Dockerfile and docker-compose config

pull/6/head
Michael D.M. Dryden 2021-08-01 19:10:05 -04:00
rodzic efd9d67a67
commit e199158632
3 zmienionych plików z 55 dodań i 0 usunięć

17
Dockerfile 100644
Wyświetl plik

@ -0,0 +1,17 @@
FROM python:3.9
WORKDIR /usr/src/app
COPY . .
RUN pip install --no-cache-dir poetry
RUN poetry install
ENV TZ="America/Toronto" \
BOT_TOKEN=-1 \
CHAT_ID=0 \
POSTGRES_USER=postgres \
POSTGRES_PASSWORD=password \
POSTGRES_HOST=db \
POSTGRES_DB=telegram_bot
CMD [ "sh", "-c", "poetry run python -m telegram_stats_bot.main --tz=$TZ $BOT_TOKEN $CHAT_ID postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB" ]

Wyświetl plik

@ -35,6 +35,8 @@ Table of contents
- `Installation`_
- `Docker`_
- `Setup`_
- `Fetching Stats`_
@ -133,6 +135,13 @@ Or you can install the latest git version using `poetry <https://python-poetry.o
Installing directly with ``setup.py`` should also work from the Pypi sdist (but why?).
------
Docker
------
A Docker image is available under ``mkdryden/telegram-stats-bot`` and a sample ``docker-compose.yml`` is in the root of the repository including database setup.
Be sure to set the ``TZ``, ``BOT_TOKEN``, and ``CHAT_ID`` environment variable appropriately in your ``docker-run`` command or the ``docker-compose.yml`` file.
-----
Setup
-----

29
docker-compose.yml 100644
Wyświetl plik

@ -0,0 +1,29 @@
version: "3.8"
services:
telegram-stats-bot:
# Uncomment to use local version
# build:
# context: .
image: mkdryden/telegram-stats-bot:latest
depends_on:
- db
environment:
TZ: "America/Toronto"
BOT_TOKEN: 111111111:AAA-MpBVQ7i2cIRfwedfsfesdg6webc0r-Y
CHAT_ID: 0
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_HOST: db
POSTGRES_DB: telegram_bot
db:
image: postgres:12
restart: always
volumes:
- db-data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password
POSTGRES_DB: telegram_bot
volumes:
db-data: