forked from danny-avila/LibreChat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile2
73 lines (58 loc) · 2.16 KB
/
Dockerfile2
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
64
65
66
67
68
69
70
71
72
73
# 基础镜像
FROM node:lts AS base
# 数据提供者构建
FROM base AS data-provider-build
WORKDIR /app/packages/data-provider
COPY ./packages/data-provider ./
RUN npm install
RUN npm run build
# React 客户端构建
FROM base AS client-build
WORKDIR /app/client
COPY ./client/ ./
# 从数据提供者构建阶段复制到客户端的 node_modules
COPY --from=data-provider-build /app/packages/data-provider /app/client/node_modules/librechat-data-provider
RUN npm install
ENV NODE_OPTIONS="--max-old-space-size=2048"
RUN npm run build
# Node.js API 设置
FROM base AS api-build
WORKDIR /app/api
COPY api/package*.json ./
COPY api/ ./
# 从数据提供者构建阶段复制到 API 的 node_modules
COPY --from=data-provider-build /app/packages/data-provider /app/api/node_modules/librechat-data-provider
RUN npm install
# 从客户端构建阶段复制构建的静态文件
COPY --from=client-build /app/client/dist /app/client/dist
# 使用 MongoDB 官方镜像
FROM mongo:latest AS mongodb
# 使用 Meilisearch 官方镜像
FROM getmeili/meilisearch:latest AS meilisearch
# 最终阶段:组合所有服务
FROM ubuntu:latest
RUN apt-get update && apt-get install -y libcurl4
# 拷贝 MongoDB 和 Meilisearch 可执行文件
COPY --from=mongodb /usr/bin/mongod /usr/bin/mongod
COPY --from=meilisearch /bin/meilisearch /usr/bin/meilisearch
# 拷贝 Node.js 和 npm
COPY --from=base /usr/local/bin/node /usr/local/bin/
COPY --from=base /usr/local/bin/npm /usr/local/bin/
COPY --from=base /usr/local/lib/node_modules /usr/local/lib/node_modules
# 创建 MongoDB 和 Meilisearch 所需的数据目录
RUN mkdir -p /data/db /meili_data
# 设置环境变量
ENV NODE_OPTIONS="--max-old-space-size=2048" \
HOST=0.0.0.0
# 设置工作目录
WORKDIR /app/api
# 复制 API 和客户端文件
COPY --from=api-build /app/api /app/api
COPY --from=client-build /app/client/dist /app/client/dist
# 暴露端口
EXPOSE 3080 27017 7700
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# 启动 MongoDB、Meilisearch 和 Node.js API
CMD mongod --fork --logpath /var/log/mongod.log --noauth --dbpath /data/db && \
meilisearch --http-addr 0.0.0.0:7700 --db-path /meili_data & \
node server/index.js