forked from lxf746/any-auto-register
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (40 loc) · 1.27 KB
/
Dockerfile
File metadata and controls
50 lines (40 loc) · 1.27 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
# Stage 1: 构建前端
FROM node:20-slim AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# Stage 2: Python 后端 + 运行环境
FROM python:3.12-slim
# 系统依赖:Chromium、Xvfb、x11vnc、noVNC
RUN apt-get update && apt-get install -y --no-install-recommends \
# 浏览器运行依赖
chromium chromium-driver \
# 虚拟显示 + VNC
xvfb x11vnc \
# noVNC 依赖
novnc websockify \
# 其他
curl ca-certificates fonts-liberation libnss3 libatk-bridge2.0-0 \
libdrm2 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libxkbcommon0 \
libasound2 libpango-1.0-0 libcairo2 libgtk-3-0 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# 安装 Python 依赖
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# 安装 Playwright 浏览器
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN playwright install chromium --with-deps || true
# 复制后端代码
COPY . .
# 不需要 .venv 和 frontend 源码
RUN rm -rf .venv frontend
# 复制前端构建产物
COPY --from=frontend-builder /app/static ./static
# 启动脚本
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
EXPOSE 8000 6080
ENTRYPOINT ["/docker-entrypoint.sh"]