forked from startrekor/ragflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.frontend.optimized
More file actions
54 lines (42 loc) · 1.25 KB
/
Copy pathDockerfile.frontend.optimized
File metadata and controls
54 lines (42 loc) · 1.25 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
# 优化的前端Dockerfile - 减少网络依赖
# 专门用于构建前端镜像,可以连接到独立的后端容器
# 使用Node.js 20作为基础镜像
FROM node:20-alpine AS base
# 设置工作目录
WORKDIR /ragflow
# 安装必要的系统依赖(减少依赖包)
RUN apk add --no-cache \
git \
python3 \
make \
&& rm -rf /var/cache/apk/*
# 复制package.json和package-lock.json
COPY web/package*.json ./web/
# 安装前端依赖
WORKDIR /ragflow/web
# 安装所有依赖(包括开发依赖),因为构建时需要
RUN npm ci --ignore-scripts
# 复制前端源代码
COPY web/src ./src
COPY web/public ./public
COPY web/.umirc.ts ./
COPY web/jest.config.ts ./
COPY web/jest-setup.ts ./
COPY web/tsconfig.json ./
COPY web/tailwind.config.js ./
COPY web/tailwind.css ./
COPY web/externals.d.ts ./
COPY web/typings.d.ts ./
# 复制docs目录,因为前端代码中引用了docs文件
# 确保docs目录在正确的位置,与@parent别名对应
COPY docs ../docs
# 构建前端
RUN npm run build
# 使用nginx作为生产服务器
FROM nginx:alpine
# 复制构建好的前端文件到nginx目录
COPY --from=base /ragflow/web/dist /usr/share/nginx/html
# 暴露端口
EXPOSE 80
# 设置启动命令
CMD ["nginx", "-g", "daemon off;"]