xueyiming 2 дней назад
Родитель
Сommit
7e3b40442b
2 измененных файлов с 22 добавлено и 0 удалено
  1. 21 0
      Dockerfile
  2. 1 0
      requirements.txt

+ 21 - 0
Dockerfile

@@ -0,0 +1,21 @@
+FROM registry.cn-hangzhou.aliyuncs.com/stuuudy/python:3.11-slim AS base
+
+
+WORKDIR /app
+
+ENV PYTHONDONTWRITEBYTECODE=1 \
+    PYTHONUNBUFFERED=1
+
+# 1) 安装依赖(利用 Docker layer 缓存)
+COPY requirements.txt /app/requirements.txt
+RUN pip install --no-cache-dir --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple/
+RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
+
+# 2) 复制源码
+COPY . /app
+
+EXPOSE 7000
+
+# demand Web API
+CMD ["uvicorn", "examples.demand.web_api:app", "--host", "0.0.0.0", "--port", "7000"]
+

+ 1 - 0
requirements.txt

@@ -24,3 +24,4 @@ pymysql==1.1.2
 requests==2.33.0
 pandas==3.0.1
 pyfim==6.28
+loguru>=0.7.0