Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Housekeeping – add .dockerignore, add INFO level logging, slim dependencies in Dockerfile #304

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/mongodb
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ ENV PIP_NO_CACHE_DIR=off
ENV PIP_DISABLE_PIP_VERSION_CHECK=on
ENV PIP_DEFAULT_TIMEOUT=100

RUN apt-get update
RUN apt-get install -y python3 python3-pip python-dev build-essential python3-venv ffmpeg
RUN apt-get update && \
apt-get install -y \
# required by the bot
python3-yaml python3-pymongo ffmpeg \
# debugging helpers
nano ripgrep && \
rm -rf /var/lib/apt/lists/*

RUN mkdir -p /code
ADD . /code
WORKDIR /code

RUN pip3 install -r requirements.txt
COPY requirements.txt /code/requirements.txt
RUN pip3 install --no-cache-dir -r requirements.txt

ADD . /code

CMD ["bash"]
CMD ["bash"]
3 changes: 2 additions & 1 deletion bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

# setup
db = database.Database()
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

user_semaphores = {}
Expand Down Expand Up @@ -703,4 +704,4 @@ def run_bot() -> None:


if __name__ == "__main__":
run_bot()
run_bot()
9 changes: 6 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
mongo:
container_name: mongo
image: mongo:latest
restart: always
restart: unless-stopped
ports:
- 127.0.0.1:${MONGODB_PORT:-27017}:${MONGODB_PORT:-27017}
volumes:
Expand All @@ -14,17 +14,20 @@ services:
chatgpt_telegram_bot:
container_name: chatgpt_telegram_bot
command: python3 bot/bot.py
restart: always
restart: unless-stopped
build:
context: "."
dockerfile: Dockerfile
volumes:
- ./bot:/code/bot
- ./config:/code/config
depends_on:
- mongo

mongo_express:
container_name: mongo-express
image: mongo-express:latest
restart: always
restart: unless-stopped
ports:
- 127.0.0.1:${MONGO_EXPRESS_PORT:-8081}:${MONGO_EXPRESS_PORT:-8081}
environment:
Expand Down