From 4eac493de47cffdcf7d1df2a9ef9cddd2fae1505 Mon Sep 17 00:00:00 2001 From: passthem Date: Thu, 9 Oct 2025 20:25:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=BB=A4=E4=BA=BA=E8=B4=B9?= =?UTF-8?q?=E8=A7=A3=E7=9A=84=20requirements.txt=20=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 24 ------------- .vscode/tasks.json | 30 ---------------- Dockerfile | 30 ++++++++++++++-- README.md | 4 +-- requirements.txt | 84 --------------------------------------------- 5 files changed, 29 insertions(+), 143 deletions(-) delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/tasks.json delete mode 100644 requirements.txt diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 81ddfb6..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "运行 Bot 并调试(自动重载)", - "type": "debugpy", - "request": "launch", - "module": "watchfiles", - "args": [ - "bot.main" - ], - "console": "integratedTerminal", - "justMyCode": true, - "env": { - "PYTHONPATH": "${workspaceFolder}" - }, - "cwd": "${workspaceFolder}", - "presentation": { - "hidden": false, - "group": "bot" - } - } - ] -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 6222a90..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Poetry: Export requirements.txt (Production)", - "type": "shell", - "command": "poetry export -f requirements.txt --output requirements.txt --without-hashes", - "group": "build", - "presentation": { - "reveal": "always", - "panel": "new" - }, - "problemMatcher": [], - "detail": "导出生产环境依赖到 requirements.txt" - }, - { - "label": "Bot: Run with Auto-reload", - "type": "shell", - "command": "poetry run watchfiles bot.main", - "group": "build", - "isBackground": true, - "presentation": { - "reveal": "always", - "panel": "new" - }, - "problemMatcher": [], - "detail": "运行 bot 并启用自动重载功能" - } - ] -} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 63a9e1c..6295d8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,32 @@ -FROM python:3.13-slim +# copied from https://www.martinrichards.me/post/python_poetry_docker/ +FROM python:3.13-slim AS base + +ENV VIRTUAL_ENV=/app/.venv \ + PATH="/app/.venv/bin:$PATH" + + + +FROM base AS builder + +ENV POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_IN_PROJECT=1 \ + POETRY_VIRTUALENVS_CREATE=1 \ + POETRY_CACHE_DIR=/tmp/poetry_cache + +WORKDIR /app + +RUN pip install poetry + +COPY pyproject.toml poetry.lock ./ +RUN python -m poetry install --no-root && rm -rf $POETRY_CACHE_DIR + + + +FROM base AS runtime + +COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} WORKDIR /app -COPY requirements.txt ./ -RUN pip install -r requirements.txt --no-deps COPY bot.py pyproject.toml .env.prod .env.test ./ COPY assets ./assets diff --git a/README.md b/README.md index cc68e66..4abe6bd 100644 --- a/README.md +++ b/README.md @@ -65,10 +65,10 @@ code . ### 运行 -你可以在 VSCode 的「运行与调试」窗口,启动 `运行 Bot 并调试(自动重载)` 任务来启动 Bot,也可以使用命令行手动启动 Bot: +使用命令行手动启动 Bot: ```bash -poetry run watchfiles bot.main +poetry run watchfiles bot.main konabot ``` 如果你不希望自动重载,只是想运行 Bot,可以直接运行: diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 97a917a..0000000 --- a/requirements.txt +++ /dev/null @@ -1,84 +0,0 @@ -aio-mc-rcon==3.4.1 ; python_version >= "3.12" and python_version < "4.0" -aiodns==3.5.0 ; python_version >= "3.12" and python_version < "4.0" -aiohappyeyeballs==2.6.1 ; python_version >= "3.12" and python_version < "4.0" -aiohttp==3.12.15 ; python_version >= "3.12" and python_version < "4.0" -aiosignal==1.4.0 ; python_version >= "3.12" and python_version < "4.0" -annotated-types==0.7.0 ; python_version >= "3.12" and python_version < "4.0" -anyio==4.11.0 ; python_version >= "3.12" and python_version < "4.0" -apscheduler==3.11.0 ; python_version >= "3.12" and python_version < "4.0" -arclet-alconna-tools==0.7.11 ; python_version >= "3.12" and python_version < "4.0" -arclet-alconna==1.8.40 ; python_version >= "3.12" and python_version < "4.0" -attrs==25.3.0 ; python_version >= "3.12" and python_version < "4.0" -beautifulsoup4==4.13.5 ; python_version >= "3.12" and python_version < "4.0" -brotli==1.1.0 ; python_version >= "3.12" and python_version < "4.0" and platform_python_implementation == "CPython" -brotlicffi==1.1.0.0 ; python_version >= "3.12" and python_version < "4.0" and platform_python_implementation != "CPython" -certifi==2025.8.3 ; python_version >= "3.12" and python_version < "4.0" -cffi==2.0.0 ; python_version >= "3.12" and python_version < "4.0" -charset-normalizer==3.4.3 ; python_version >= "3.12" and python_version < "4.0" -click==8.3.0 ; python_version >= "3.12" and python_version < "4.0" -colorama==0.4.6 ; python_version >= "3.12" and python_version < "4.0" and (sys_platform == "win32" or platform_system == "Windows") -exceptiongroup==1.3.0 ; python_version >= "3.12" and python_version < "4.0" -fastapi==0.117.1 ; python_version >= "3.12" and python_version < "4.0" -frozenlist==1.7.0 ; python_version >= "3.12" and python_version < "4.0" -h11==0.16.0 ; python_version >= "3.12" and python_version < "4.0" -h2==4.3.0 ; python_version >= "3.12" and python_version < "4.0" -hpack==4.1.0 ; python_version >= "3.12" and python_version < "4.0" -httpcore==1.0.9 ; python_version >= "3.12" and python_version < "4.0" -httptools==0.6.4 ; python_version >= "3.12" and python_version < "4.0" -httpx==0.28.1 ; python_version >= "3.12" and python_version < "4.0" -hyperframe==6.1.0 ; python_version >= "3.12" and python_version < "4.0" -idna==3.10 ; python_version >= "3.12" and python_version < "4.0" -imagetext-py==2.2.0 ; python_version >= "3.12" and python_version < "4.0" -importlib-metadata==8.7.0 ; python_version >= "3.12" and python_version < "4.0" -linkify-it-py==2.0.3 ; python_version >= "3.12" and python_version < "4.0" -loguru==0.7.3 ; python_version >= "3.12" and python_version < "4.0" -lxml==6.0.2 ; python_version >= "3.12" and python_version < "4.0" -markdown-it-py==4.0.0 ; python_version >= "3.12" and python_version < "4.0" -mdit-py-plugins==0.5.0 ; python_version >= "3.12" and python_version < "4.0" -mdurl==0.1.2 ; python_version >= "3.12" and python_version < "4.0" -msgpack==1.1.1 ; python_version >= "3.12" and python_version < "4.0" -multidict==6.6.4 ; python_version >= "3.12" and python_version < "4.0" -nepattern==0.7.7 ; python_version >= "3.12" and python_version < "4.0" -nonebot-adapter-console==0.9.0 ; python_version >= "3.12" and python_version < "4.0" -nonebot-adapter-discord==0.1.8 ; python_version >= "3.12" and python_version < "4.0" -nonebot-adapter-minecraft==1.5.2 ; python_version >= "3.12" and python_version < "4.0" -nonebot-adapter-onebot==2.4.6 ; python_version >= "3.12" and python_version < "4.0" -nonebot-plugin-alconna==0.59.4 ; python_version >= "3.12" and python_version < "4.0" -nonebot-plugin-apscheduler==0.5.0 ; python_version >= "3.12" and python_version < "4.0" -nonebot-plugin-waiter==0.8.1 ; python_version >= "3.12" and python_version < "4.0" -nonebot2==2.4.3 ; python_version >= "3.12" and python_version < "4.0" -nonechat==0.6.1 ; python_version >= "3.12" and python_version < "4.0" -numpy==2.2.6 ; python_version >= "3.12" and python_version < "4.0" -opencv-python-headless==4.12.0.88 ; python_version >= "3.12" and python_version < "4.0" -pillow==11.3.0 ; python_version >= "3.12" and python_version < "4.0" -platformdirs==4.4.0 ; python_version >= "3.12" and python_version < "4.0" -propcache==0.3.2 ; python_version >= "3.12" and python_version < "4.0" -pycares==4.11.0 ; python_version >= "3.12" and python_version < "4.0" -pycparser==2.23 ; python_version >= "3.12" and python_version < "4.0" and implementation_name != "PyPy" -pydantic-core==2.33.2 ; python_version >= "3.12" and python_version < "4.0" -pydantic==2.11.9 ; python_version >= "3.12" and python_version < "4.0" -pygments==2.19.2 ; python_version >= "3.12" and python_version < "4.0" -pygtrie==2.5.0 ; python_version >= "3.12" and python_version < "4.0" -python-dotenv==1.1.1 ; python_version >= "3.12" and python_version < "4.0" -pyyaml==6.0.3 ; python_version >= "3.12" and python_version < "4.0" -requests==2.32.5 ; python_version >= "3.12" and python_version < "4.0" -returns==0.26.0 ; python_version >= "3.12" and python_version < "4.0" -rich==14.1.0 ; python_version >= "3.12" and python_version < "4.0" -sniffio==1.3.1 ; python_version >= "3.12" and python_version < "4.0" -soupsieve==2.8 ; python_version >= "3.12" and python_version < "4.0" -starlette==0.48.0 ; python_version >= "3.12" and python_version < "4.0" -tarina==0.6.8 ; python_version >= "3.12" and python_version < "4.0" -textual==3.7.1 ; python_version >= "3.12" and python_version < "4.0" -typing-extensions==4.15.0 ; python_version >= "3.12" and python_version < "4.0" -typing-inspection==0.4.1 ; python_version >= "3.12" and python_version < "4.0" -tzdata==2025.2 ; python_version >= "3.12" and python_version < "4.0" and platform_system == "Windows" -tzlocal==5.3.1 ; python_version >= "3.12" and python_version < "4.0" -uc-micro-py==1.0.3 ; python_version >= "3.12" and python_version < "4.0" -urllib3==2.5.0 ; python_version >= "3.12" and python_version < "4.0" -uvicorn==0.37.0 ; python_version >= "3.12" and python_version < "4.0" -uvloop==0.21.0 ; python_version >= "3.12" and python_version < "4.0" and sys_platform != "win32" and sys_platform != "cygwin" and platform_python_implementation != "PyPy" -watchfiles==1.1.0 ; python_version >= "3.12" and python_version < "4.0" -websockets==15.0.1 ; python_version >= "3.12" and python_version < "4.0" -win32-setctime==1.2.0 ; python_version >= "3.12" and python_version < "4.0" and sys_platform == "win32" -yarl==1.20.1 ; python_version >= "3.12" and python_version < "4.0" -zipp==3.23.0 ; python_version >= "3.12" and python_version < "4.0"