deploy docker
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# 构建阶段
|
||||
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04 AS builder
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
# 配置apt源为清华源
|
||||
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
|
||||
sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
|
||||
|
||||
# 安装系统依赖和Python
|
||||
RUN apt-get update && apt-get install -y \
|
||||
software-properties-common \
|
||||
curl \
|
||||
build-essential \
|
||||
&& add-apt-repository ppa:deadsnakes/ppa \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y python3.11 python3.11-dev python3.11-distutils \
|
||||
&& curl -sS https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
|
||||
&& python3.11 get-pip.py -i https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||
&& rm -rf /var/lib/apt/lists/* get-pip.py
|
||||
|
||||
# 设置Python 3.11为默认版本
|
||||
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
|
||||
update-alternatives --set python3 /usr/bin/python3.11
|
||||
|
||||
WORKDIR /producer
|
||||
|
||||
# 配置pip源为清华源
|
||||
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
|
||||
# 安装依赖
|
||||
COPY requirements.txt .
|
||||
RUN python3 -m pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# 最终阶段
|
||||
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
# 配置apt源为清华源
|
||||
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
|
||||
sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
|
||||
|
||||
# 安装运行时依赖
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ffmpeg \
|
||||
libgl1-mesa-glx \
|
||||
software-properties-common \
|
||||
&& add-apt-repository ppa:deadsnakes/ppa \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y python3.11 python3.11-distutils \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 设置Python 3.11为默认版本
|
||||
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
|
||||
update-alternatives --set python3 /usr/bin/python3.11
|
||||
|
||||
WORKDIR /producer
|
||||
|
||||
# 从构建阶段复制Python包
|
||||
COPY --from=builder /usr/local/lib/python3.11/dist-packages /usr/local/lib/python3.11/dist-packages
|
||||
|
||||
# 复制应用代码
|
||||
COPY . .
|
||||
|
||||
# 创建必要的目录
|
||||
RUN mkdir -p /obscura/task/upload /obscura/task/result
|
||||
|
||||
CMD ["python3", "producer.py"]
|
||||
Regular → Executable
@@ -21,16 +21,6 @@ RESULT_DIR = "/obscura/task/result"
|
||||
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
||||
os.makedirs(RESULT_DIR, exist_ok=True)
|
||||
|
||||
# 模型配置
|
||||
YOLO_MODEL_PATH = "/obscura/models/yolov11n.pt"
|
||||
POSE_MODEL_PATH = "/obscura/models/yolov11n-pose.pt"
|
||||
QWEN_MODEL_PATH = "/obscura/models/QWEN/Qwen2___5-VL-7B-Instruct"
|
||||
FALL_MODEL_PATH = "/obscura/models/yolov8n-fall.pt"
|
||||
FACE_MODEL_PATH = "/obscura/models/yolov11n-face.pt"
|
||||
MEDIAPIPE_MODEL_PATH = "/obscura/models/face_landmarker.task"
|
||||
# Ollama配置
|
||||
OLLAMA_URL = "https://ffgregevrdcfyhtnhyudvr.myfastools.com/api/generate"
|
||||
|
||||
# 各个worker的配置
|
||||
WORKER_CONFIGS = {
|
||||
"yolo": {
|
||||
|
||||
@@ -20,10 +20,6 @@ app = FastAPI()
|
||||
v1_app = FastAPI()
|
||||
app.mount("/v1", v1_app)
|
||||
|
||||
|
||||
# CORS设置
|
||||
# ALLOWED_ORIGINS = ['https://beta.obscura.work']
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
|
||||
Executable → Regular
+8
-12
@@ -1,12 +1,8 @@
|
||||
fastapi
|
||||
uvicorn
|
||||
python-multipart
|
||||
kafka-python
|
||||
redis
|
||||
pillow
|
||||
decord
|
||||
pydantic
|
||||
requests
|
||||
python-jose[cryptography]
|
||||
passlib[bcrypt]
|
||||
sqlalchemy
|
||||
fastapi==0.115.12
|
||||
uvicorn==0.34.0
|
||||
python-multipart==0.0.20
|
||||
pillow==11.1.0
|
||||
decord==0.6.0
|
||||
kafka-python==2.1.5
|
||||
redis==5.2.1
|
||||
python-dotenv==1.1.0
|
||||
Reference in New Issue
Block a user