diff --git a/.gitignore b/.gitignore index bcb11895..12b5f767 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,10 @@ venv/ **/.DS_Store # windows Thumbs.db -# linux \ No newline at end of file +# linux + +# development +.env +.env.* +plugins/ +data/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e69de29b..b67ddfe7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/docker-compose.yaml b/Makefile similarity index 100% rename from docker-compose.yaml rename to Makefile diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml new file mode 100644 index 00000000..00fbccc3 --- /dev/null +++ b/docker-compose-dev.yaml @@ -0,0 +1,10 @@ +services: + server: + container_name: liteyukibot + image: liteyukibot:v7 + restart: always + volumes: + - ./plugins:/liteyukibot/plugins + - ./data:/liteyukibot/data + ports: + - "8090:8080" \ No newline at end of file diff --git a/docker-compose-example.yaml b/docker-compose-example.yaml new file mode 100644 index 00000000..43747b3f --- /dev/null +++ b/docker-compose-example.yaml @@ -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" \ No newline at end of file diff --git a/main.py b/main.py index aaac274c..e0ca4994 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,6 @@ -def main(): - print("Hello from liteyukibot!") - +from fastapi import FastAPI +import uvicorn if __name__ == "__main__": - main() \ No newline at end of file + app = FastAPI() + uvicorn.run(app, host="0.0.0.0", port=8080) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 4781a77a..2d63338e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,4 +7,5 @@ requires-python = ">=3.12" dependencies = [ "fastapi>=0.115.12", "pydantic>=2.11.3", + "uvicorn>=0.34.2", ] diff --git a/uv.lock b/uv.lock index 1113e41e..0b9be883 100644 --- a/uv.lock +++ b/uv.lock @@ -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 }, ] +[[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]] name = "fastapi" 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 }, ] +[[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]] name = "idna" version = "3.10" @@ -55,12 +85,14 @@ source = { virtual = "." } dependencies = [ { name = "fastapi" }, { name = "pydantic" }, + { name = "uvicorn" }, ] [package.metadata] requires-dist = [ { name = "fastapi", specifier = ">=0.115.12" }, { name = "pydantic", specifier = ">=2.11.3" }, + { name = "uvicorn", specifier = ">=0.34.2" }, ] [[package]] @@ -161,3 +193,16 @@ sdist = { url = "https://files.pythonhosted.org/packages/82/5c/e6082df02e215b846 wheels = [ { 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 }, +]