feat: update env configs and add team canvas endpoint

This commit is contained in:
2025-11-10 11:09:22 +08:00
parent b2053760be
commit 81fa34669a
19 changed files with 220 additions and 55 deletions

View File

@@ -3,39 +3,38 @@ FROM node:20-alpine AS builder
# 接受构建参数
ARG BUILD_MODE=production
ARG RAGFLOW_BASE=/ragflow/
ENV RAGFLOW_BASE=${RAGFLOW_BASE}
WORKDIR /app
# 复制包管理文件
COPY package.json pnpm-lock.yaml ./
# 安装 pnpm 和依赖
# 安装 pnpm 和依赖(工作空间)
RUN npm install -g pnpm && pnpm install
# 复制源代码
COPY . .
# 根据构建模式复制对应的环境文件
# 设置环境文件(用于根应用的构建)
RUN if [ "$BUILD_MODE" = "flask" ]; then \
cp .env.flask .env; \
else \
cp .env.production .env; \
fi
# 根据构建模式执行对应的构建命令
RUN if [ "$BUILD_MODE" = "flask" ]; then \
pnpm build:flask; \
else \
pnpm build; \
fi
# 同时构建两个前端(根 Vite 应用 + ragflow_web Umi 应用)
RUN pnpm -r --filter ./ --filter ragflow_web run build
# 生产阶段 - nginx
FROM nginx:alpine AS production
# 接受端口参数默认为5173
# 接受端口与子路径参数
ARG PORT=5173
ARG RAGFLOW_BASE=/ragflow/
# 复制自定义 nginx 配置
# 复制自定义 nginx 配置,分别部署两个前端
RUN cat > /etc/nginx/conf.d/default.conf << EOF
server {
listen ${PORT};
@@ -43,11 +42,17 @@ server {
root /usr/share/nginx/html;
index index.html;
# 处理 SPA 路由
# 根应用ViteSPA 路由
location / {
try_files \$uri \$uri/ /index.html;
}
# ragflow_webUmi部署在子路径支持 SPA 路由
location ${RAGFLOW_BASE} {
alias /usr/share/nginx/html/ragflow/;
try_files \$uri \$uri/ /index.html;
}
# 静态资源缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
@@ -67,10 +72,11 @@ server {
}
EOF
# 从构建阶段复制构建产物
# 从构建阶段复制构建产物:根应用与 ragflow_web
COPY --from=builder /app/dist /usr/share/nginx/html
COPY --from=builder /app/ragflow_web/dist /usr/share/nginx/html/ragflow
# 暴露端口(使用构建时指定的端口)
# 暴露端口
EXPOSE ${PORT}
# 启动 nginx