s21s2 commited on
Commit
6233136
·
verified ·
1 Parent(s): 9c5ff52

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -0
Dockerfile ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用 Python 3.11 作为基础镜像
2
+ FROM python:3.11-slim
3
+
4
+ # 设置为中国国内源(针对 Bookworm/Debian 12)
5
+ RUN rm -rf /etc/apt/sources.list.d/* && \
6
+ echo "deb http://mirrors.ustc.edu.cn/debian bookworm main" > /etc/apt/sources.list && \
7
+ echo "deb http://mirrors.ustc.edu.cn/debian bookworm-updates main" >> /etc/apt/sources.list && \
8
+ echo "deb http://mirrors.ustc.edu.cn/debian-security bookworm-security main" >> /etc/apt/sources.list
9
+
10
+ # 设置工作目录
11
+ WORKDIR /app
12
+
13
+ # 设置环境变量
14
+ ENV PYTHONUNBUFFERED=1 \
15
+ PYTHONDONTWRITEBYTECODE=1 \
16
+ POETRY_NO_INTERACTION=1 \
17
+ POETRY_VIRTUALENVS_IN_PROJECT=1 \
18
+ POETRY_CACHE_DIR=/tmp/poetry_cache
19
+
20
+ # 安装系统依赖
21
+ RUN apt-get update \
22
+ && apt-get install -y --no-install-recommends \
23
+ curl \
24
+ build-essential \
25
+ && rm -rf /var/lib/apt/lists/*
26
+
27
+ # 复制项目文件
28
+ COPY . .
29
+
30
+ # 安装 Python 依赖
31
+ RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
32
+
33
+ # 暴露端口
34
+ EXPOSE 8080
35
+
36
+ # 启动命令
37
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]