From 8cbb77be3c77d786e091cb145120a5f52de9a3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=A9o=20=27Nebulo9=27=20DESSAUVAGES?= Date: Sun, 20 Sep 2026 00:33:10 +0200 Subject: [PATCH] feat: Reimplement the deployment process through Docker --- .dockerignore | 11 + Dockerfile | 35 +- compose.yaml | 17 +- config/hltv.html | 6778 --------------------------------------- config/insults.txt | 27 - config/intern.json | 1 - config/intern_takes.csv | 22 - setup/config.py | 8 - setup/logger.py | 29 +- 9 files changed, 78 insertions(+), 6850 deletions(-) create mode 100644 .dockerignore delete mode 100644 config/hltv.html delete mode 100644 config/insults.txt delete mode 100644 config/intern.json delete mode 100644 config/intern_takes.csv diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e2f4db1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +venv/ +.venv/ +__pycache__/ +*.pyc +.git/ +tests/ +*.log +.env +config/ +/.vscode/ +*.log \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8b5b41d..f52b850 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,36 @@ FROM python:3.13.14-alpine +RUN apk add --no-cache \ + build-base \ + libffi-dev \ + musl-dev \ + openssl-dev \ + python3-dev \ + geckodriver \ + firefox-esr + WORKDIR /app -COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt && \ - apk add --no-cache firefox geckodriver - -COPY . . - ENV TOKEN="" -ENV URL="" ENV CONFIG_PATH="/config" -ENV COGS="" ENV GECKODRIVER_PATH="/usr/bin/geckodriver" -RUN mkdir ${CONFIG_PATH} +RUN adduser -D bot && \ + mkdir /logs && \ + chown -R bot:bot /logs && \ + chmod 755 /logs && \ + mkdir -p ${CONFIG_PATH} && \ + chown -R bot:bot ${CONFIG_PATH} && \ + chmod 755 ${CONFIG_PATH} + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . +RUN chown -R bot:bot /app && \ + chmod -R 755 /app && \ + chmod +x /app/main.py + +USER bot ENTRYPOINT ["python", "main.py"] \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index 02f519f..c1c3de5 100644 --- a/compose.yaml +++ b/compose.yaml @@ -6,15 +6,30 @@ networks: services: botmafieux: + build: + context: . + dockerfile: Dockerfile image: nebulo9/botmafieux:latest container_name: botmafieux restart: unless-stopped networks: - internal - outbound - env_file: ./.env + env_file: + - ./.env volumes: - ./config:/config + healthcheck: + test: ["CMD", "pgrep", "-f", "main.py"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 30s + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" deploy: resources: limits: diff --git a/config/hltv.html b/config/hltv.html deleted file mode 100644 index fc7ae8e..0000000 --- a/config/hltv.html +++ /dev/null @@ -1,6778 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - Counter-Strike Matches & livescore | HLTV.org - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
-
- -
-
-
- -
- -
-
-
- -
- - -
- -
-
-
-
-
-
-
-
-
-
JULY
-
-
-
-
-
Mon
-
Tue
-
Wed
-
Thu
-
Fri
-
Sat
-
Sun
-
-
-
-
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
-
-
-
-
-
- -
- -
-
-
-
Star
-
Clear
-
-
-
-
-
-
Ranked
-
Clear
-
-
-
-
-
-
-
Region
-
Clear
-
-
-
-
-
-
-
-
Tournament
-
Clear
-
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Set filters
-
-
-
-
-
-
- -
-
-
-
-

Live Counter-Strike matches

-
-
Sort by: -
-
Event
-
Time
-
-
- -
-
-
-
-
-
-
- - - - - - - - - - -
-
-
- -
-
-
-
Matches for you -
-
Why am I seeing these matches?this?
- -
-
-
-
-
No matches for you yet.
Click the icon next to a match to pin them for easier access, or check back later
-
-
-
-
-
-

Upcoming Counter-Strike matches

-
-
-
-
-
Sunday - 2026-07-12 -
- - - - - - - - - - - - - - - - - - -
-
-
Monday - 2026-07-13 -
- - - - - - - - - - - - - - - -
-
- - -
Thursday - 2026-07-16 -
- - - - - - - - - - - - - - - - - - -
-
-
Friday - 2026-07-17 -
- - - - - - - - - - - - - - - - - - - - - - - - -
-
-
Saturday - 2026-07-18 -
- - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - -
-
-
-
-
-
-
-
-
-
- - -
- - - -
- - - -
- - -
- - -
-
-
-
-
- -
-
-
-
-
-
Now playing
-
Thumbnail for stream
- -
Russia -
strogo
-
14733 viewers
-
-
-
-
-
Top streams
-
-
All(60)
-
Casters(37)
-
Streamers(15)
-
Organizers(8)
-
-
-
-
Russia -
strogo
-
(14733)
-
-
Ukraine -
inkmate0
-
(4241)
-
-
Vietnam -
500Bros
-
(2869)
-
-
Poland -
Hyper
-
(1344)
-
-
Russia -
Sashacheer
-
(948)
-
-
Czech Republic -
Bladeito
-
(911)
-
-
Ukraine -
aidstar
-
(846)
-
-
Ukraine -
leniniw
-
(813)
-
-
Russia -
almazer
-
(761)
-
-
Other -
tweeday
-
(741)
-
-
Netherlands -
D0cC
-
(651)
-
-
Other -
donaCS
-
(633)
-
-
Canada -
MrHBatt
-
(615)
-
-
Poland -
byali
-
(611)
-
-
Russia -
BreeL
-
(566)
-
-
Russia -
OverDrive
-
(550)
-
-
United Kingdom -
ESL TV
-
(456)
-
-
Russia -
FpSSS
-
(432)
-
-
Russia -
Mikotohero
-
(380)
-
-
France -
KRL
-
(331)
-
-
Ukraine -
leniniw
-
(325)
-
-
Ukraine -
1mpala
-
(299)
-
-
Russia -
floppya
-
(275)
-
-
Czech Republic -
zur1s
-
(272)
-
-
Other -
VanFanTV
-
(204)
-
-
France -
maleK
-
(202)
-
-
United States -
sh1n
-
(193)
-
-
Turkey -
spyhiddentv
-
(177)
-
-
Ukraine -
guthriee
-
(173)
-
-
United Kingdom -
ESL TV
-
(167)
-
-
Poland -
martynkalandrynka
-
(152)
-
-
Sweden -
GeT_RiGhT
-
(147)
-
-
Finland -
p3kko
-
(131)
-
-
France -
NAGU
-
(112)
-
-
Slovakia -
STYKO
-
(106)
-
-
Bulgaria -
Niku
-
(82)
-
-
Czech Republic -
oskar
-
(76)
-
-
United States -
Fragadelphia
-
(77)
-
-
Germany -
kRYSTAL
-
(75)
-
-
Brazil -
mch
-
(74)
-
-
Ukraine -
Maincast
-
(73)
-
-
Romania -
CHANKY
-
(61)
-
-
Poland -
Majki
-
(62)
-
-
United States -
iamfusiion
-
(53)
-
-
United States -
Frag
-
(51)
-
-
Mongolia -
ESN
-
(40)
-
-
Australia -
viridian
-
(29)
-
-
Other -
kleverr
-
(25)
-
-
United States -
blakert
-
(24)
-
-
Ukraine -
Maincast
-
(19)
-
-
United States -
NuTorious
-
(14)
-
-
Other -
Exort 2
-
(14)
-
-
Hungary -
Esport1 TV
-
(11)
-
-
United States -
Floofys
-
(10)
-
-
Russia -
BetBoom
-
(7)
-
-
Ukraine -
Edward
-
(9)
-
-
Kazakhstan -
BRO
-
(5)
-
-
France -
ArthurrrTV
-
(4)
-
-
United Kingdom -
BARDOLPH
-
(3)
-
-
United States -
Frag 2
-
(2)
-
-
-
-
-
- -
-
-
- - - - - -
- - - - - - - \ No newline at end of file diff --git a/config/insults.txt b/config/insults.txt deleted file mode 100644 index 71fe0ff..0000000 --- a/config/insults.txt +++ /dev/null @@ -1,27 +0,0 @@ -Ta gueule. -Qui a demandé ? -Mais tais-toi! -zZzZzZzZ...... -Tout ça ? -On peut se passer du message je pense. -C'est chiant le message là. -Mdr on s'en fout. -Pas lu. -Trop long j'ai décroché. -Il faut quitter le serveur, vous gênez l'espace s'il vous plaît. -Gênant... -Si je devais noter la pertinence du message ce serait genre 1/10. -Tu es ridicule, arrête d'écrire. -Ça a intéréssé quelqu'un ? -Franchement c'était nécessaire d'écrire ça ? -Honestly the most useless thing I read today. -Dommage que les hommes soient cons… -Ta mère mérite la prison pour avoir mis au monde un HOMME. -T'as pas beaucoup de neurones. -Arrêtons de normaliser les hommes svp. -🚮🚮 -Ton message me donne envie de vomir. -J'ai pas ri perso. -Tiens tiens encore une raison de détester les hommes ! -Y'a moyen ton père c'est Macron. -Tu préfères devenir un être humain sympa ou rester un homme ? diff --git a/config/intern.json b/config/intern.json deleted file mode 100644 index 00b9506..0000000 --- a/config/intern.json +++ /dev/null @@ -1 +0,0 @@ -[{"mentor_id": 264189554582355969, "guild_id": 897157935006900254, "next_roll": "2026-07-22T00:00:00"}] \ No newline at end of file diff --git a/config/intern_takes.csv b/config/intern_takes.csv deleted file mode 100644 index 80772b8..0000000 --- a/config/intern_takes.csv +++ /dev/null @@ -1,22 +0,0 @@ -target;weight;take -any;1.0;Tu as besoin d'un café ? -any;1.0;Je peux te faire un café si tu veux ? -any;1.0;Tu as besoin d'un thé ? -any;1.0;Je peux te faire un thé si tu veux ? -any;1.0;Tu as besoin d'un matcha latte? -any;1.0;Je peux te faire un matcha latte si tu veux ? -any;1.0;Tu peux m'aider sur un truc ? -any;1.0;Désolé, j'ai pas compris. -any;1.0;Attends, tu peux réexpliquer ? -any;1.0;J'ai fait une bêtise je crois... -nebulo;2.0;J'ai un bug dans mon code tu peux regarder ? -bluebro;2.0;J'ai un bug dans mon code tu peux regarder ? -viebah;2.0;J'ai un bug dans mon code tu peux regarder ? -merdix;2.0;Mon modèle 3D est cassé, je fais quoi ? -goupzy;2.0;Mon modèle 3D est cassé, je fais quoi ? -viebah;2.0;Mon modèle 3D est cassé, je fais quoi ? -goupzy;2.0;Mon modèle 3D est cassé, je fais quoi ? -nino274;2.0;Mon modèle 3D est cassé, je fais quoi ? -cemesah;2.0;J'ai fait une erreur, il faut réimprimer les cartes... -cemesah;2.0;J'ai pas sauvegardé et InDesign a planté... -cemesah;2.0;Tu veux du bouillon ? \ No newline at end of file diff --git a/setup/config.py b/setup/config.py index a8ba049..f698513 100644 --- a/setup/config.py +++ b/setup/config.py @@ -7,19 +7,11 @@ class Config: TOKEN = str(os.getenv("TOKEN", "")) CONFIG_PATH = str(os.getenv("CONFIG_PATH")) - COGS = os.getenv("COGS", "") GUILDS_IDS:list[int] = [] GUILD_CONFIGS:dict[int,dict] = {} - @classmethod - def get_cogs(cls): - raw_value = cls.COGS.strip() - if not raw_value: - return None - return [item.strip().lower() for item in raw_value.split(",") if item.strip()] - @classmethod def load_guilds_configs(cls): with os.scandir(cls.CONFIG_PATH) as d: diff --git a/setup/logger.py b/setup/logger.py index 3abf1f3..e952805 100644 --- a/setup/logger.py +++ b/setup/logger.py @@ -1,5 +1,7 @@ import logging import os +import tempfile +import sys # Determine log level from environment variable `LOG_LEVEL` (e.g. DEBUG, INFO) raw_level = os.getenv("LOG_LEVEL", "INFO").upper() @@ -15,7 +17,26 @@ else: logging.basicConfig(level=level, format='[%(levelname)s] %(asctime)s: %(name)s: %(message)s') LOGGER = logging.getLogger('botmafieux') LOGGER.setLevel(level) -# File handler (append) -handler = logging.FileHandler(filename='botmafieux.log', encoding='utf-8', mode='a') -handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) -LOGGER.addHandler(handler) \ No newline at end of file + +# Decide log file path: prefer LOG_FILE, then CONFIG_PATH/botmafieux.log, then /tmp +preferred = os.getenv('LOG_FILE') +if not preferred: + cfg_path = "/logs" + if cfg_path: + preferred = os.path.join(cfg_path, 'botmafieux.log') + else: + preferred = os.path.join(tempfile.gettempdir(), 'botmafieux.log') + +formatter = logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s') + +try: + handler = logging.FileHandler(filename=preferred, encoding='utf-8', mode='a') + handler.setFormatter(formatter) + LOGGER.addHandler(handler) +except (PermissionError, OSError) as e: + # Fall back to console logging if file cannot be opened + stream_handler = logging.StreamHandler(sys.stdout) + stream_handler.setFormatter(formatter) + LOGGER.addHandler(stream_handler) + # Print a warning directly to stderr in case logging isn't yet configured elsewhere + print(f"[WARN] Could not open log file '{preferred}' for writing: {e}. Falling back to stdout.", file=sys.stderr) \ No newline at end of file -- 2.49.1