-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (45 loc) · 2.01 KB
/
Dockerfile
File metadata and controls
63 lines (45 loc) · 2.01 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
62
63
# ============================================================
# MCPHubs - Unified Dockerfile (Frontend + Backend)
# ============================================================
# ── Stage 1: Build Frontend (Debian-based, glibc 兼容 Ubuntu) ─
FROM node:22-slim AS frontend-builder
WORKDIR /app/web
COPY web/package.json web/package-lock.json ./
RUN npm ci
COPY web/ .
ENV NEXT_PUBLIC_API_URL=http://127.0.0.1:8000
RUN npm run build
# ── Stage 2: Final Image ─────────────────────────────────────
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /app
# 安装系统依赖 + NodeSource Node 22(含 npm)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 python3-pip python3-venv \
gcc libpq-dev curl git unzip \
ca-certificates bash vim nano net-tools iputils-ping && \
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get install -y nodejs && \
ln -sf /usr/bin/python3 /usr/bin/python && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/*
# File Manager 工作目录
RUN mkdir -p /app/installed
# Python 依赖(--break-system-packages 适配 Ubuntu 24.04 PEP 668)
COPY requirements.txt .
RUN pip install --no-cache-dir --break-system-packages \
--retries 3 --timeout 60 \
-r requirements.txt
# 后端源码(web/ 已在 .dockerignore 中排除)
COPY . .
# 前端构建产物(只复制 standalone 输出,不带 node_modules)
COPY --from=frontend-builder /app/web/.next/standalone/ /app/web-standalone/
COPY --from=frontend-builder /app/web/.next/static /app/web-standalone/.next/static
COPY --from=frontend-builder /app/web/public /app/web-standalone/public
RUN chmod +x /app/start.sh
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD curl -sf http://127.0.0.1:8000/api/health || exit 1
EXPOSE 8000 3000
CMD ["/app/start.sh"]