初次提交

This commit is contained in:
2025-10-14 20:05:29 +08:00
commit 6e4e48fdd2
673 changed files with 437006 additions and 0 deletions

52
backend/Dockerfile Normal file
View File

@@ -0,0 +1,52 @@
# 使用官方Python镜像
FROM python:3.12-slim
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
TZ=Asia/Shanghai
# 安装系统依赖
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
curl \
tzdata \
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
# 创建非root用户
RUN useradd --create-home --shell /bin/bash app
# 复制requirements文件
COPY requirements.txt .
# 升级pip并安装Python依赖
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY . .
# 创建必要的目录并设置权限
RUN mkdir -p /app/uploads /app/logs \
&& chown -R app:app /app
# 切换到非root用户
USER app
# 暴露端口
EXPOSE 8002
# 健康检查
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8002/api/v1/health || exit 1
# 启动命令
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8002"]