-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfileLocal
More file actions
61 lines (47 loc) · 1.75 KB
/
Copy pathDockerfileLocal
File metadata and controls
61 lines (47 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# ==========================================
# DB MCP Server - Local Single Image Dockerfile
# ==========================================
# --- 阶段 1: 前端构建 ---
FROM node:22-alpine AS frontend-builder
WORKDIR /app/frontend
# 使用国内镜像源加速
RUN npm config set registry https://registry.npmmirror.com
# 安装依赖
COPY frontend/package*.json ./
RUN npm install
# 复制源码并构建
# adapter-static 会将结果输出到 ../src/static
COPY frontend/ ./
RUN npm run build
# --- 阶段 2: 运行环境 ---
FROM python:3.13-slim
WORKDIR /app
# 设置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 使用国内 APT 镜像源并安装必要系统依赖
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources && \
apt-get update && apt-get install -y --no-install-recommends \
gcc \
python3-dev \
libpq-dev \
freetds-dev \
freetds-bin \
curl \
&& rm -rf /var/lib/apt/lists/*
# 安装 Python 依赖(使用阿里源)
COPY requirements.txt .
RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ --upgrade pip && \
pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt
# 复制后端源码 (先复制源码,避免覆盖后续的前端编译结果)
COPY . .
# 复制前端编译结果到后端目录 (覆盖掉源码中可能存在的旧静态文件)
COPY --from=frontend-builder /app/src/static ./src/static
# 创建必要的目录
RUN mkdir -p data/downloads logs
# 设置环境变量
ENV PYTHONPATH=/app
# 暴露端口
EXPOSE 3000
# 启动服务
CMD ["sh", "-c", "python src/init_admin_db.py && uvicorn src.server:app --host 0.0.0.0 --port 3000 --no-access-log"]