update: add common

This commit is contained in:
tao.chen
2026-07-27 15:37:58 +08:00
parent e56bf0e56b
commit 1c03a32298
8 changed files with 91 additions and 9 deletions
+22
View File
@@ -0,0 +1,22 @@
# backend/Dockerfile
FROM python:3.12-slim
WORKDIR /app
# 安装 uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# 1. 拷贝根目录配置与 lock 文件
COPY pyproject.toml uv.lock ./
# 2. 拷贝 common 模块与 backend 模块
COPY common ./common
COPY backend ./backend
# 3. 安装 backend 及其所有依赖 (包括本地 common)
RUN uv sync --frozen --no-dev --package backend
EXPOSE 8000
# 4. 启动服务 (通过 uv run 指定运行 backend 包)
CMD ["uv", "run", "--package", "backend", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
+6 -2
View File
@@ -21,6 +21,10 @@ backend = "backend:main"
url = "https://pypi.tuna.tsinghua.edu.cn/simple/"
default = true
[tool.uv.sources]
common = { workspace = true }
[build-system]
requires = ["uv_build>=0.11.31,<0.12.0"]
build-backend = "uv_build"
requires = ["hatchling"]
build-backend = "hatchling.build"
+6 -5
View File
@@ -9,9 +9,10 @@ authors = [
requires-python = ">=3.12"
dependencies = []
[project.scripts]
common = "common:main"
[build-system]
requires = ["uv_build>=0.11.31,<0.12.0"]
build-backend = "uv_build"
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/common"]
+7
View File
@@ -0,0 +1,7 @@
# coding=utf-8
"""
@Time :2026/7/27
@Author :tao.chen
"""
def hello_world():
return 'Hello World!'
+20
View File
@@ -0,0 +1,20 @@
version: '3.8'
services:
backend:
build:
context: .
dockerfile: backend/Dockerfile
ports:
- "8000:8000"
environment:
- RUNTIME_BASE_URL=http://runtime:8001
depends_on:
- runtime
runtime:
build:
context: .
dockerfile: runtime/Dockerfile
ports:
- "8001:8001"
+19
View File
@@ -0,0 +1,19 @@
# runtime/Dockerfile
FROM python:3.12-slim
WORKDIR /app
# 安装 uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
COPY pyproject.toml uv.lock ./
COPY common ./common
COPY runtime ./runtime
RUN uv sync --frozen --no-dev --package backend
EXPOSE 8001
CMD ["uv", "run", "--package", "runtime", "uvicorn", "runtime.main:app", "--host", "0.0.0.0", "--port", "8001"]
+5 -2
View File
@@ -19,6 +19,9 @@ dependencies = [
url = "https://pypi.tuna.tsinghua.edu.cn/simple/"
default = true
[tool.uv.sources]
common = { workspace = true }
[build-system]
requires = ["uv_build>=0.11.31,<0.12.0"]
build-backend = "uv_build"
requires = ["hatchling"]
build-backend = "hatchling.build"
Generated
+6
View File
@@ -9,6 +9,7 @@ resolution-markers = [
[manifest]
members = [
"backend",
"common",
"model-platform",
"runtime",
]
@@ -379,6 +380,11 @@ wheels = [
{ url = "https://pypi.tuna.tsinghua.edu.cn/packages/60/97/891a0971e1e4a8c5d2b20bbe0e524dc04548d2307fee33cdeba148fd4fc7/comm-0.2.3-py3-none-any.whl", hash = "sha256:c615d91d75f7f04f095b30d1c1711babd43bdc6419c1be9886a85f2f4e489417", size = 7294, upload-time = "2025-07-25T14:02:02.896Z" },
]
[[package]]
name = "common"
version = "0.1.0"
source = { editable = "common" }
[[package]]
name = "debugpy"
version = "1.8.21"