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 pip install pandas
|
||||
RUN pip install nltk
|
||||
RUN python -m nltk.downloader -d /usr/local/share/nltk_data all
|
||||
RUN pip install python-dotenv
|
||||
RUN python -m venv /root/venv
|
||||
ENV PATH="/root/venv/bin:$PATH"
|
||||
|
||||
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
|
||||
image: kwaylon:latest
|
||||
build: ./
|
||||
restart: unless-stopped
|
||||
# restart: unless-stopped
|
||||
network_mode: host
|
||||
volumes:
|
||||
# give access to the system time as read-only
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /mnt/dietpi_userdata/kwaylon/src:/usr/app/src
|
||||
- /mnt/dietpi_userdata/kwaylon/data:/usr/app/data
|
||||
# - type: bind
|
||||
# source: /mnt/dietpi_userdata/kwaylon/messages.db
|
||||
# target: /usr/src/app/messages.db
|
||||
- /mnt/dietpi_userdata/kwaylon:/usr/app
|
||||
|
||||
@@ -5,6 +5,7 @@ nltk
|
||||
python-dotenv
|
||||
|
||||
# stockquotes
|
||||
# beautifulsoup4
|
||||
# requests
|
||||
# lxml
|
||||
beautifulsoup4
|
||||
requests
|
||||
lxml
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import re
|
||||
import sqlite3
|
||||
from datetime import timedelta, datetime
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
@@ -23,7 +24,7 @@ class Kwaylon(Client):
|
||||
|
||||
def __init__(self, limit: int = 5000, days: int = 30, *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.jokes = list(jokes.collect_jokes())
|
||||
@@ -54,8 +55,12 @@ class Kwaylon(Client):
|
||||
|
||||
# await alive()
|
||||
|
||||
self.data = ReactionData(self.db_path)
|
||||
self.data.read_all()
|
||||
try:
|
||||
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):
|
||||
if message.author != self.user:
|
||||
|
||||
Reference in New Issue
Block a user