-
Notifications
You must be signed in to change notification settings - Fork 168
Expand file tree
/
Copy pathDockerfile_react_app
More file actions
45 lines (34 loc) · 1.31 KB
/
Dockerfile_react_app
File metadata and controls
45 lines (34 loc) · 1.31 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
# ================================
# 阶段 1: 构建 React 应用
# ================================
ARG BASE_IMAGE=dify-chat-base
FROM ${BASE_IMAGE} AS builder
# 设置工作目录
WORKDIR /app
# 设置环境变量(可在构建时通过 --build-arg 传入)
ARG PUBLIC_DEBUG_MODE=false
ARG PUBLIC_APP_API_BASE=http://localhost:5300/api/client
ARG PUBLIC_DIFY_PROXY_API_BASE=http://localhost:5300/api/client/dify
ENV PUBLIC_DEBUG_MODE=${PUBLIC_DEBUG_MODE}
ENV PUBLIC_APP_API_BASE=${PUBLIC_APP_API_BASE}
ENV PUBLIC_DIFY_PROXY_API_BASE=${PUBLIC_DIFY_PROXY_API_BASE}
# 确保使用最新的 react-app 源码
COPY packages/react-app ./packages/react-app
# 构建 React 应用
RUN pnpm --filter dify-chat-app-react build
# ================================
# 阶段 2: 运行时
# ================================
FROM nginx:alpine-slim AS runtime
# 复制自定义 nginx 配置
COPY packages/react-app/docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY packages/react-app/docker/replace_env.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
# 复制构建产物到 nginx 静态文件目录(优化权限)
COPY --from=builder /app/packages/react-app/dist /usr/share/nginx/html/dify-chat
# 暴露端口
EXPOSE 80
# 入口脚本
ENTRYPOINT ["/docker-entrypoint.sh"]
# 启动 nginx
CMD ["nginx", "-g", "daemon off;"]