File size: 1,489 Bytes
55721ec
492836d
 
 
 
 
55721ec
 
 
492836d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55721ec
492836d
 
55721ec
492836d
 
 
55721ec
492836d
 
 
 
55721ec
1544293
 
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
# 使用Python 3.11基础镜像
FROM python:3.11-slim

# 设置工作目录
WORKDIR /app

# 创建数据和日志目录,并设置权限
RUN mkdir -p /app/data /app/logs /app/data/news && \
    chmod -R 777 /app/data /app/logs

# 设置环境变量
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1

# 更新源列表并更换为阿里云源
RUN echo 'deb http://mirrors.aliyun.com/debian/ bookworm main' > /etc/apt/sources.list && \
    echo 'deb-src http://mirrors.aliyun.com/debian/ bookworm main' >> /etc/apt/sources.list && \
    echo 'deb http://mirrors.aliyun.com/debian/ bookworm-updates main' >> /etc/apt/sources.list && \
    echo 'deb-src http://mirrors.aliyun.com/debian/ bookworm-updates main' >> /etc/apt/sources.list && \
    echo 'deb http://mirrors.aliyun.com/debian-security bookworm-security main' >> /etc/apt/sources.list && \
    echo 'deb-src http://mirrors.aliyun.com/debian-security bookworm-security main' >> /etc/apt/sources.list

# 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
    # 在这里添加你的系统依赖
    && rm -rf /var/lib/apt/lists/*

# 复制依赖文件
COPY requirements.txt .

# 安装Python依赖
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

# 复制应用代码
COPY . .

# 运行应用
#CMD ["gunicorn", "app.web.web_server:app", "-b", "0.0.0.0:8888", "--workers", "4"]
CMD ["gunicorn", "-c", "gunicorn.conf.py", "app.web.web_server:app"]