All checks were successful
continuous-integration/drone/push Build is passing
- 新增 start.sh 启动脚本,根据 WORKERS/RELOAD 环境变量自动配置 - 修改 Dockerfile 使用启动脚本,默认 WORKERS=4 - 更新 docker-compose.prod-multi.yml,所有租户使用环境变量配置 - 生产环境默认4个workers,提升并发处理能力 Co-authored-by: Cursor <cursoragent@cursor.com>
66 lines
1.7 KiB
Docker
66 lines
1.7 KiB
Docker
# 使用Python 3.11作为基础镜像,使用阿里云镜像
|
||
FROM python:3.11.9-slim
|
||
|
||
# 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 设置环境变量
|
||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||
PYTHONUNBUFFERED=1 \
|
||
PIP_NO_CACHE_DIR=1
|
||
|
||
# 配置阿里云镜像源
|
||
RUN echo "deb http://mirrors.aliyun.com/debian/ bookworm main" > /etc/apt/sources.list && \
|
||
echo "deb http://mirrors.aliyun.com/debian-security/ bookworm-security main" >> /etc/apt/sources.list && \
|
||
echo "deb http://mirrors.aliyun.com/debian/ bookworm-updates main" >> /etc/apt/sources.list
|
||
|
||
# 安装系统依赖(包括LibreOffice用于文档转换)
|
||
RUN apt-get update && apt-get install -y \
|
||
gcc \
|
||
default-libmysqlclient-dev \
|
||
pkg-config \
|
||
curl \
|
||
libreoffice-writer \
|
||
libreoffice-impress \
|
||
libreoffice-calc \
|
||
libreoffice-core \
|
||
fonts-wqy-zenhei \
|
||
fonts-wqy-microhei \
|
||
--no-install-recommends \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
# 复制依赖文件
|
||
COPY requirements.txt .
|
||
|
||
# 配置pip使用阿里云镜像
|
||
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
|
||
pip config set global.trusted-host mirrors.aliyun.com
|
||
|
||
# 安装Python依赖
|
||
RUN pip install --upgrade pip && \
|
||
pip install -r requirements.txt
|
||
|
||
# 复制应用代码
|
||
COPY app/ ./app/
|
||
|
||
# 复制启动脚本
|
||
COPY start.sh ./start.sh
|
||
RUN chmod +x ./start.sh
|
||
|
||
# 创建上传目录和日志目录
|
||
RUN mkdir -p uploads logs
|
||
|
||
# 默认环境变量(可通过docker-compose或环境变量覆盖)
|
||
ENV WORKERS=4 \
|
||
RELOAD=false \
|
||
TIMEOUT_KEEP_ALIVE=600
|
||
|
||
# 暴露端口
|
||
EXPOSE 8000
|
||
|
||
# 健康检查
|
||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||
CMD curl -f http://localhost:8000/health || exit 1
|
||
|
||
# 使用启动脚本
|
||
CMD ["./start.sh"] |