-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (37 loc) · 1.35 KB
/
Copy pathDockerfile
File metadata and controls
47 lines (37 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 使用官方 Python 3.11 镜像
FROM python:3.11-slim
# 设置工作目录
WORKDIR /app
# 安装系统依赖(已替换为国内镜像源)
RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list.d/debian.sources && \
apt-get update && apt-get install -y --no-install-recommends \
git \
build-essential \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/* && \
# 关键的Git网络配置
git config --global http.version HTTP/1.1 && \
git config --global http.postBuffer 524288000 && \
git config --global http.sslVerify true && \
git config --global http.timeout 300 && \
update-ca-certificates
# 复制依赖文件
COPY requirements.txt .
# 安装 Python 依赖(已添加国内镜像源加速)
RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ || \
pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/ || \
pip install --no-cache-dir -r requirements.txt -i https://pypi.doubanio.com/simple/
# 复制应用代码
COPY . .
# 创建必要的目录
RUN mkdir -p /repo_clones /app/logs
# 设置权限
RUN chmod -R 755 /app
# 暴露端口
EXPOSE 8000
# 设置环境变量
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# 默认命令
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]