-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic Docker Compose setup with external binding. Probably should also have nginx reverse proxy to bind tellerbot on localhost, so far I just haven't managed to make dockerized nginx receive Telegram webhook updates. Signed-off-by: alfred richardsn <rchrdsn@protonmail.ch>
- Loading branch information
Showing
16 changed files
with
223 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Git | ||
.git/ | ||
.gitignore | ||
.gitattributes | ||
|
||
# Docker | ||
docker-compose.yml | ||
.dockerignore | ||
|
||
# Markdown files | ||
**/*.md | ||
|
||
# Development files | ||
.pre-commit-config.yml | ||
requirements-dev.txt | ||
setup.cfg | ||
|
||
# GitHub | ||
.github/ | ||
|
||
# Examples | ||
*.example | ||
|
||
# Logs | ||
**/*.log | ||
|
||
# Byte-compiled / optimized / DLL files | ||
**/__pycache__/ | ||
**/*.pyc | ||
|
||
# Unit test / coverage reports | ||
tests/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
**/*.mo | ||
**/*.pot | ||
|
||
# Sphinx documentation | ||
docs/ | ||
|
||
# Environments | ||
.env | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# IDEA folder | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Connection | ||
TOKEN_FILENAME=/run/secrets/tbtoken | ||
INTERNAL_HOST=0.0.0.0 | ||
SERVER_HOST=example.com | ||
SERVER_PORT=5000 | ||
WEBHOOK_PATH=/tellerbot/webhook | ||
DATABASE_NAME=tellerbot | ||
DATABASE_HOST=database | ||
|
||
# Logging | ||
LOGGER_LEVEL=INFO | ||
LOG_FILENAME=/var/log/tellerbot.log | ||
|
||
# Chat IDs | ||
SUPPORT_CHAT_ID=-123456789 | ||
EXCEPTIONS_CHAT_ID=-1234567890123 | ||
|
||
# Orders | ||
ORDERS_COUNT=10 | ||
ORDERS_LIMIT_HOURS=24 | ||
ORDERS_LIMIT_COUNT=10 | ||
|
||
# Escrow | ||
ESCROW_ENABLED=true | ||
WIF_FILENAME=/run/secrets/wif.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM python:3.8-slim-buster | ||
|
||
LABEL mantainer="alfred richardsn <rchrdsn@protonmail.ch>" | ||
|
||
ARG USER=tellerbot | ||
ARG GROUP=tellerbot | ||
|
||
ENV HOME /home/$USER | ||
|
||
RUN groupadd -g 999 $GROUP \ | ||
&& useradd -g $GROUP -u 999 -l -s /sbin/nologin -m -d $HOME $USER | ||
WORKDIR $HOME | ||
USER $USER:$GROUP | ||
|
||
COPY --chown=$USER:$GROUP requirements.txt . | ||
ENV PATH $PATH:$HOME/.local/bin | ||
RUN pip install --user --no-cache-dir --requirement requirements.txt | ||
|
||
COPY --chown=$USER:$GROUP locale/ locale/ | ||
RUN pybabel compile --directory=locale/ --domain=bot | ||
|
||
COPY --chown=$USER:$GROUP . . | ||
|
||
ENTRYPOINT ["python", "."] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: "3.7" | ||
|
||
services: | ||
tellerbot: | ||
build: . | ||
depends_on: | ||
- database | ||
env_file: | ||
- .env | ||
restart: on-failure | ||
volumes: | ||
- ${TOKEN_FILENAME}:${TOKEN_FILENAME}:ro | ||
- ${WIF_FILENAME}:${WIF_FILENAME}:ro | ||
ports: | ||
- ${SERVER_PORT}:${SERVER_PORT} | ||
|
||
database: | ||
image: mongo:4.2.1 | ||
container_name: ${DATABASE_HOST} | ||
command: mongod --quiet | ||
ports: | ||
- 27017 | ||
volumes: | ||
- ~/data/db:/data/db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,4 +50,3 @@ | |
html_static_path = ["_static"] | ||
|
||
master_doc = "index" | ||
autodoc_mock_imports = ["src.config"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ emoji | |
golos-python | ||
motor | ||
pymongo | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
000000000:ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"golos": "abcdefghijklmopqrstuABCDEFGHIJKLMNOPQRSTU1234567890" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,54 @@ | ||
from configparser import ConfigParser | ||
from pathlib import Path | ||
# Copyright (C) 2019 alfred richardsn | ||
# | ||
# This file is part of TellerBot. | ||
# | ||
# TellerBot is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with TellerBot. If not, see <https://www.gnu.org/licenses/>. | ||
from os import getenv | ||
|
||
ROOT_DIR = Path(__file__).parent.parent.resolve() | ||
|
||
parser = ConfigParser() | ||
parser.read(ROOT_DIR / "config.ini") | ||
def getenv_int(key, default=None): | ||
"""Convert the value of the environment variable key to an integer.""" | ||
env = getenv(key) | ||
try: | ||
return int(env) | ||
except (TypeError, ValueError): | ||
return default | ||
|
||
TOKEN_FILE = parser.get("Connection", "token_filename") | ||
SERVER_HOST = parser.get("Connection", "server_host") | ||
SERVER_PORT = parser.getint("Connection", "server_port") | ||
WEBHOOK_PATH = parser.get("Connection", "webhook_path") | ||
DATABASE_NAME = parser.get("Connection", "database_name") | ||
|
||
LOGGER_LEVEL = parser.get("Logging", "logger_level") | ||
LOG_FILENAME = parser.get("Logging", "log_filename") | ||
def getenv_bool(key, default=None): | ||
"""Convert the value of the environment variable key to a boolean.""" | ||
env = getenv(key) | ||
return env == "true" if env in ("true", "false") else default | ||
|
||
SUPPORT_CHAT_ID = parser.getint("Chat IDs", "support") | ||
EXCEPTIONS_CHAT_ID = parser.getint("Chat IDs", "exceptions") | ||
|
||
ORDERS_COUNT = parser.getint("Orders", "count") | ||
ORDERS_LIMIT_HOURS = parser.getint("Orders", "limit_hours") | ||
ORDERS_LIMIT_COUNT = parser.getint("Orders", "limit_count") | ||
TOKEN_FILENAME = getenv("TOKEN_FILENAME") | ||
INTERNAL_HOST = getenv("INTERNAL_HOST", "localhost") | ||
SERVER_HOST = getenv("SERVER_HOST") | ||
SERVER_PORT = getenv_int("SERVER_PORT") | ||
WEBHOOK_PATH = getenv("WEBHOOK_PATH") | ||
DATABASE_NAME = getenv("DATABASE_NAME", "tellerbot") | ||
DATABASE_HOST = getenv("DATABASE_HOST", "localhost") | ||
|
||
WIF_FILENAME = parser.get("Blockchain", "wif_filename") | ||
LOGGER_LEVEL = getenv("LOGGER_LEVEL") | ||
LOG_FILENAME = getenv("LOG_FILENAME") | ||
|
||
SUPPORT_CHAT_ID = getenv_int("SUPPORT_CHAT_ID") | ||
EXCEPTIONS_CHAT_ID = getenv_int("EXCEPTIONS_CHAT_ID") | ||
|
||
ORDERS_COUNT = getenv_int("ORDERS_COUNT") | ||
ORDERS_LIMIT_HOURS = getenv_int("ORDERS_LIMIT_HOURS") | ||
ORDERS_LIMIT_COUNT = getenv_int("ORDERS_LIMIT_COUNT") | ||
|
||
ESCROW_ENABLED = getenv_bool("WIF_FILENAME") | ||
WIF_FILENAME = getenv("WIF_FILENAME") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters