Skip to content
This repository was archived by the owner on Dec 27, 2025. It is now read-only.

Commit 670290c

Browse files
Merge pull request #9 from MasterGroosha/dev
Some improvements to Docker build and code
2 parents 140da4e + 6a15619 commit 670290c

File tree

6 files changed

+38
-8
lines changed

6 files changed

+38
-8
lines changed

.gitlab-ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include:
2+
- project: "groosha/ci_configurations"
3+
file: "my-id-bot.yml"

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
FROM python:3.8-slim-buster
22
WORKDIR /app
3-
RUN mkdir /logs
3+
RUN mkdir /app/logs
4+
COPY start.sh /app/
5+
RUN chmod +x /app/start.sh
46
COPY requirements.txt /app/requirements.txt
5-
RUN pip install -r /app/requirements.txt
7+
RUN pip install --no-cache-dir --upgrade pip \
8+
&& pip install --no-cache-dir -r /app/requirements.txt
69
COPY *.py /app/
7-
CMD ["python", "bot.py"]
10+
CMD ["/app/start.sh"]

bot.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,11 @@ async def setup_bot_commands(dispatcher: Dispatcher):
194194
"""
195195
Here we setup bot commands to make them visible in Telegram UI
196196
"""
197-
await bot.set_my_commands([
197+
bot_commands = [
198198
types.BotCommand(command="/id", description="Tell your ID or group's ID"),
199-
types.BotCommand(command="/help", description="Help and source code"),
200-
])
199+
types.BotCommand(command="/help", description="Help and source code")
200+
]
201+
await bot.set_my_commands(bot_commands)
201202

202203

203204
if __name__ == "__main__":
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
version: "3.8"
22
services:
33
bot:
4-
build: .
4+
build:
5+
context: $BUILD_PATH
6+
dockerfile: Dockerfile
7+
image: my-id-bot:dev
58
container_name: "my-id-bot-dev"
69
volumes:
710
- "/tmp/my_id_bot_dev_logs:/logs"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
aiogram>=2.9.2
1+
aiogram==2.11

start.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# cd to script directory
4+
cd "$(dirname "$0")" || exit 1
5+
6+
LOGS_DIR="/app/logs"
7+
8+
# If log files don't exist, create them
9+
LOG_NORMAL="$LOGS_DIR/my_id_bot.log"
10+
if [ ! -f "$LOG_NORMAL" ]; then
11+
touch "$LOG_NORMAL"
12+
fi
13+
14+
LOG_ERRORS="$LOGS_DIR/err.log"
15+
if [ ! -f "$LOG_ERRORS" ]; then
16+
touch "$LOG_ERRORS"
17+
fi
18+
19+
# start bot
20+
python bot.py

0 commit comments

Comments
 (0)