optimized kwalyon's container building
This commit is contained in:
26
Dockerfile
26
Dockerfile
@@ -1,16 +1,24 @@
|
|||||||
FROM python:latest
|
FROM python:latest AS build-image
|
||||||
|
|
||||||
|
RUN apt update && apt install -y libblas-dev liblapack-dev
|
||||||
|
|
||||||
RUN python -m pip install --upgrade pip
|
RUN python -m pip install --upgrade pip
|
||||||
|
|
||||||
RUN pip install pandas
|
RUN python -m venv /root/venv
|
||||||
RUN pip install nltk
|
ENV PATH="/root/venv/bin:$PATH"
|
||||||
RUN python -m nltk.downloader -d /usr/local/share/nltk_data all
|
|
||||||
RUN pip install python-dotenv
|
|
||||||
|
|
||||||
RUN pip install nextcord
|
COPY ./requirements.txt ./requirements.txt
|
||||||
|
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip pip install -r ./requirements.txt
|
||||||
|
|
||||||
RUN pip install beautifulsoup4 requests lxml
|
|
||||||
|
|
||||||
WORKDIR /usr/app/src
|
FROM python:slim
|
||||||
|
|
||||||
CMD [ "python", "main.py" ]
|
RUN apt update && apt install -y libblas-dev liblapack-dev
|
||||||
|
|
||||||
|
COPY --from=build-image /root/venv /root/venv
|
||||||
|
ENV PATH="/root/venv/bin:$PATH"
|
||||||
|
|
||||||
|
RUN python -m nltk.downloader words
|
||||||
|
|
||||||
|
WORKDIR /usr/app
|
||||||
|
CMD [ "python", "./src/main.py" ]
|
||||||
|
|||||||
@@ -4,13 +4,10 @@ services:
|
|||||||
container_name: kwaylon
|
container_name: kwaylon
|
||||||
image: kwaylon:latest
|
image: kwaylon:latest
|
||||||
build: ./
|
build: ./
|
||||||
restart: unless-stopped
|
# restart: unless-stopped
|
||||||
network_mode: host
|
network_mode: host
|
||||||
volumes:
|
volumes:
|
||||||
|
# give access to the system time as read-only
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
- /etc/timezone:/etc/timezone:ro
|
- /etc/timezone:/etc/timezone:ro
|
||||||
- /mnt/dietpi_userdata/kwaylon/src:/usr/app/src
|
- /mnt/dietpi_userdata/kwaylon:/usr/app
|
||||||
- /mnt/dietpi_userdata/kwaylon/data:/usr/app/data
|
|
||||||
# - type: bind
|
|
||||||
# source: /mnt/dietpi_userdata/kwaylon/messages.db
|
|
||||||
# target: /usr/src/app/messages.db
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ nltk
|
|||||||
python-dotenv
|
python-dotenv
|
||||||
|
|
||||||
# stockquotes
|
# stockquotes
|
||||||
# beautifulsoup4
|
beautifulsoup4
|
||||||
# requests
|
requests
|
||||||
# lxml
|
lxml
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import sqlite3
|
||||||
from datetime import timedelta, datetime
|
from datetime import timedelta, datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
@@ -23,7 +24,7 @@ class Kwaylon(Client):
|
|||||||
|
|
||||||
def __init__(self, limit: int = 5000, days: int = 30, *args, **kwargs):
|
def __init__(self, limit: int = 5000, days: int = 30, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.db_path = Path.cwd().parents[0] / 'data' / 'messages.db'
|
self.db_path = Path.cwd() / 'data' / 'messages.db'
|
||||||
|
|
||||||
self.limit, self.days = limit, days
|
self.limit, self.days = limit, days
|
||||||
self.jokes = list(jokes.collect_jokes())
|
self.jokes = list(jokes.collect_jokes())
|
||||||
@@ -54,8 +55,12 @@ class Kwaylon(Client):
|
|||||||
|
|
||||||
# await alive()
|
# await alive()
|
||||||
|
|
||||||
self.data = ReactionData(self.db_path)
|
try:
|
||||||
self.data.read_all()
|
self.data = ReactionData(self.db_path)
|
||||||
|
self.data.read_all()
|
||||||
|
except sqlite3.Error as e:
|
||||||
|
LOGGER.exception(e)
|
||||||
|
LOGGER.error(f'self.db_path: {self.db_path}')
|
||||||
|
|
||||||
async def handle_message(self, message: Message):
|
async def handle_message(self, message: Message):
|
||||||
if message.author != self.user:
|
if message.author != self.user:
|
||||||
|
|||||||
Reference in New Issue
Block a user