- 从服务器拉取完整代码 - 按框架规范整理项目结构 - 配置 Drone CI 测试环境部署 - 包含后端(FastAPI)、前端(Vue3)、管理端 技术栈: Vue3 + TypeScript + FastAPI + MySQL
60 lines
1.8 KiB
Docker
60 lines
1.8 KiB
Docker
# 后端开发环境 Dockerfile(支持热重载)
|
||
FROM python:3.11.9-slim
|
||
|
||
# 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 设置环境变量
|
||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||
PYTHONUNBUFFERED=1 \
|
||
PIP_NO_CACHE_DIR=1 \
|
||
PYTHONPATH=/app
|
||
|
||
# 配置阿里云镜像源
|
||
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
|
||
|
||
# 复制应用代码(开发时会被volume覆盖)
|
||
COPY . .
|
||
|
||
# 创建必要的目录
|
||
RUN mkdir -p uploads logs
|
||
|
||
# 暴露端口
|
||
EXPOSE 8000
|
||
|
||
# 健康检查
|
||
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
||
CMD curl -f http://localhost:8000/health || exit 1
|
||
|
||
# 启动开发服务器(支持热重载)
|
||
# 设置超时为10分钟(600秒),以支持AI试题生成等长时间处理
|
||
CMD ["uvicorn", "app.main:app", "--reload", "--host", "0.0.0.0", "--port", "8000", "--reload-dir", "/app/app", "--timeout-keep-alive", "600"]
|