封装成docker

This commit is contained in:
2025-12-30 09:12:42 +00:00
parent 32294ebec1
commit df74a5414b
3 changed files with 129 additions and 0 deletions

38
Dockerfile Normal file
View File

@@ -0,0 +1,38 @@
# 使用官方Python运行时作为基础镜像
FROM python:3.11-slim
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
FLASK_APP=app.py
# 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# 复制依赖文件
COPY backend/requirements.txt /app/backend/requirements.txt
# 安装Python依赖
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /app/backend/requirements.txt
# 复制项目文件
COPY backend/ /app/backend/
COPY frontend/ /app/frontend/
# 创建数据目录
RUN mkdir -p /app/data
# 暴露端口
EXPOSE 5000
# 设置工作目录为backend
WORKDIR /app/backend
# 启动应用
CMD ["python", "app.py"]