📝 更新 .gitignore 文件以包含开发相关的忽略项;更新 Dockerfile 以支持 uvicorn 和虚拟环境;删除不再使用的 docker-compose 文件;重构 main.py 以使用 FastAPI;更新 pyproject.toml 和 uv.lock 文件以添加 uvicorn 依赖;创建 Makefile 和 docker-compose-dev.yaml 示例文件。

This commit is contained in:
远野千束 2025-04-27 23:30:39 +08:00
parent 7d755581cb
commit 4cbf043547
8 changed files with 97 additions and 5 deletions

8
.gitignore vendored
View File

@ -13,4 +13,10 @@ venv/
**/.DS_Store **/.DS_Store
# windows # windows
Thumbs.db Thumbs.db
# linux # linux
# development
.env
.env.*
plugins/
data/

View File

@ -0,0 +1,16 @@
FROM python:3.12-alpine
WORKDIR /liteyukibot
COPY main.py .
COPY pyproject.toml .
COPY liteyukibot/ .
COPY uv.lock .
RUN pip install uv
ENV UV_COMPILE_BYTECODE=1
RUN uv venv --python 3.12 && uv sync
CMD [".venv/bin/python3", "main.py"]

10
docker-compose-dev.yaml Normal file
View File

@ -0,0 +1,10 @@
services:
server:
container_name: liteyukibot
image: liteyukibot:v7
restart: always
volumes:
- ./plugins:/liteyukibot/plugins
- ./data:/liteyukibot/data
ports:
- "8090:8080"

View File

@ -0,0 +1,14 @@
services:
liteyukibot:
container_name: bot
# Liteyuki latest: reg.liteyuki.icu/bot/app:latest
# Liteyuki nightly: reg.liteyuki.icu/bot/app:nightly
# GHCR latest: ghcr.io/liteyukistudio/bot-app:latest 暂未发布
# Docker Hub latest: docker.io/liteyukistudio/bot-app:latest 暂未发布
image: reg.liteyuki.icu/bot/app:latest
restart: always
volumes:
- ./plugins:/liteyukibot/plugins # 外部插件目录,插件开发者可用
- ./data:/liteyukibot/data # 数据目录,包含下载器安装的插件目录
ports:
- "8090:8080"

View File

@ -1,6 +1,6 @@
def main(): from fastapi import FastAPI
print("Hello from liteyukibot!") import uvicorn
if __name__ == "__main__": if __name__ == "__main__":
main() app = FastAPI()
uvicorn.run(app, host="0.0.0.0", port=8080)

View File

@ -7,4 +7,5 @@ requires-python = ">=3.12"
dependencies = [ dependencies = [
"fastapi>=0.115.12", "fastapi>=0.115.12",
"pydantic>=2.11.3", "pydantic>=2.11.3",
"uvicorn>=0.34.2",
] ]

45
uv.lock generated
View File

@ -25,6 +25,27 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/a1/ee/48ca1a7c89ffec8b6a0c5d02b89c305671d5ffd8d3c94acf8b8c408575bb/anyio-4.9.0-py3-none-any.whl", hash = "sha256:9f76d541cad6e36af7beb62e978876f3b41e3e04f2c1fbf0884604c0a9c4d93c", size = 100916 }, { url = "https://files.pythonhosted.org/packages/a1/ee/48ca1a7c89ffec8b6a0c5d02b89c305671d5ffd8d3c94acf8b8c408575bb/anyio-4.9.0-py3-none-any.whl", hash = "sha256:9f76d541cad6e36af7beb62e978876f3b41e3e04f2c1fbf0884604c0a9c4d93c", size = 100916 },
] ]
[[package]]
name = "click"
version = "8.1.8"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "colorama", marker = "sys_platform == 'win32'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a", size = 226593 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2", size = 98188 },
]
[[package]]
name = "colorama"
version = "0.4.6"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335 },
]
[[package]] [[package]]
name = "fastapi" name = "fastapi"
version = "0.115.12" version = "0.115.12"
@ -39,6 +60,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/50/b3/b51f09c2ba432a576fe63758bddc81f78f0c6309d9e5c10d194313bf021e/fastapi-0.115.12-py3-none-any.whl", hash = "sha256:e94613d6c05e27be7ffebdd6ea5f388112e5e430c8f7d6494a9d1d88d43e814d", size = 95164 }, { url = "https://files.pythonhosted.org/packages/50/b3/b51f09c2ba432a576fe63758bddc81f78f0c6309d9e5c10d194313bf021e/fastapi-0.115.12-py3-none-any.whl", hash = "sha256:e94613d6c05e27be7ffebdd6ea5f388112e5e430c8f7d6494a9d1d88d43e814d", size = 95164 },
] ]
[[package]]
name = "h11"
version = "0.16.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515 },
]
[[package]] [[package]]
name = "idna" name = "idna"
version = "3.10" version = "3.10"
@ -55,12 +85,14 @@ source = { virtual = "." }
dependencies = [ dependencies = [
{ name = "fastapi" }, { name = "fastapi" },
{ name = "pydantic" }, { name = "pydantic" },
{ name = "uvicorn" },
] ]
[package.metadata] [package.metadata]
requires-dist = [ requires-dist = [
{ name = "fastapi", specifier = ">=0.115.12" }, { name = "fastapi", specifier = ">=0.115.12" },
{ name = "pydantic", specifier = ">=2.11.3" }, { name = "pydantic", specifier = ">=2.11.3" },
{ name = "uvicorn", specifier = ">=0.34.2" },
] ]
[[package]] [[package]]
@ -161,3 +193,16 @@ sdist = { url = "https://files.pythonhosted.org/packages/82/5c/e6082df02e215b846
wheels = [ wheels = [
{ url = "https://files.pythonhosted.org/packages/31/08/aa4fdfb71f7de5176385bd9e90852eaf6b5d622735020ad600f2bab54385/typing_inspection-0.4.0-py3-none-any.whl", hash = "sha256:50e72559fcd2a6367a19f7a7e610e6afcb9fac940c650290eed893d61386832f", size = 14125 }, { url = "https://files.pythonhosted.org/packages/31/08/aa4fdfb71f7de5176385bd9e90852eaf6b5d622735020ad600f2bab54385/typing_inspection-0.4.0-py3-none-any.whl", hash = "sha256:50e72559fcd2a6367a19f7a7e610e6afcb9fac940c650290eed893d61386832f", size = 14125 },
] ]
[[package]]
name = "uvicorn"
version = "0.34.2"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "click" },
{ name = "h11" },
]
sdist = { url = "https://files.pythonhosted.org/packages/a6/ae/9bbb19b9e1c450cf9ecaef06463e40234d98d95bf572fab11b4f19ae5ded/uvicorn-0.34.2.tar.gz", hash = "sha256:0e929828f6186353a80b58ea719861d2629d766293b6d19baf086ba31d4f3328", size = 76815 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/b1/4b/4cef6ce21a2aaca9d852a6e84ef4f135d99fcd74fa75105e2fc0c8308acd/uvicorn-0.34.2-py3-none-any.whl", hash = "sha256:deb49af569084536d269fe0a6d67e3754f104cf03aba7c11c40f01aadf33c403", size = 62483 },
]