添加docker部署方式,优化目前项目结构,更新了readme文件

This commit is contained in:
赵杰
2025-09-22 16:36:50 +01:00
parent d6c88d87dd
commit 1e4376ba56
10 changed files with 850 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
# TSP智能助手Docker镜像
FROM python:3.9-slim
# TSP智能助手Docker镜像 - 优化版本
FROM python:3.11-slim
# 设置工作目录
WORKDIR /app
@@ -7,6 +7,9 @@ WORKDIR /app
# 设置环境变量
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_NO_CACHE_DIR=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
# 安装系统依赖
RUN apt-get update && apt-get install -y \
@@ -14,8 +17,15 @@ RUN apt-get update && apt-get install -y \
g++ \
git \
curl \
wget \
vim \
htop \
procps \
&& rm -rf /var/lib/apt/lists/*
# 升级pip并安装wheel
RUN pip install --upgrade pip setuptools wheel
# 复制依赖文件
COPY requirements.txt .
@@ -26,13 +36,18 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . .
# 创建必要目录
RUN mkdir -p logs data backups
RUN mkdir -p logs data backups uploads config
# 设置权限
RUN chmod +x scripts/deploy.sh
RUN chmod +x scripts/deploy.sh scripts/monitor.sh
# 创建非root用户
RUN useradd -m -u 1000 tspuser && \
chown -R tspuser:tspuser /app
USER tspuser
# 暴露端口
EXPOSE 5000
EXPOSE 5000 8765
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \