Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
# user defined files
.env
docker-compose.override.yml
node_modules
2 changes: 1 addition & 1 deletion develop/bin/dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --no-deps --detach "$@"
docker compose -f docker-compose.yml -f docker-compose.dev.yml up --no-deps --detach "$@"
Copy link
Member

@AllanChain AllanChain Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是可以把针对开发环境 (dev) 的修改新开一个 PR?(下面还有很多也是一样的)

Empty file removed develop/compiles/.gitkeep
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

像是误删?

Empty file.
2 changes: 2 additions & 0 deletions develop/dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ GRACEFUL_SHUTDOWN_DELAY_SECONDS=0
HISTORY_V1_HOST=history-v1
LISTEN_ADDRESS=0.0.0.0
MONGO_HOST=mongo
LLM_HOST=llm
MONGO_URL=mongodb://mongo/sharelatex?directConnection=true
NOTIFICATIONS_HOST=notifications
PROJECT_HISTORY_HOST=project-history
REALTIME_HOST=real-time
REDIS_HOST=redis
REDIS_URL=redis://redis:6379
SPELLING_HOST=spelling
WEBPACK_HOST=webpack
WEB_API_PASSWORD=overleaf
Expand Down
43 changes: 30 additions & 13 deletions develop/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "127.0.0.1:9230:9229"
- "0.0.0.0:9230:9229"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么要这么改呢?这会有一定的安全问题

volumes:
- ../services/clsi/app:/overleaf/services/clsi/app
- ../services/clsi/app.js:/overleaf/services/clsi/app.js
Expand All @@ -15,7 +15,7 @@ services:
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "127.0.0.1:9231:9229"
- "0.0.0.0:9231:9229"
volumes:
- ../services/chat/app:/overleaf/services/chat/app
- ../services/chat/app.js:/overleaf/services/chat/app.js
Expand All @@ -26,7 +26,7 @@ services:
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "127.0.0.1:9232:9229"
- "0.0.0.0:9232:9229"
volumes:
- ../services/contacts/app:/overleaf/services/contacts/app
- ../services/contacts/app.js:/overleaf/services/contacts/app.js
Expand All @@ -37,7 +37,7 @@ services:
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "127.0.0.1:9233:9229"
- "0.0.0.0:9233:9229"
volumes:
- ../services/docstore/app:/overleaf/services/docstore/app
- ../services/docstore/app.js:/overleaf/services/docstore/app.js
Expand All @@ -48,7 +48,7 @@ services:
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "127.0.0.1:9234:9229"
- "0.0.0.0:9234:9229"
volumes:
- ../services/document-updater/app:/overleaf/services/document-updater/app
- ../services/document-updater/app.js:/overleaf/services/document-updater/app.js
Expand All @@ -59,7 +59,7 @@ services:
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "127.0.0.1:9235:9229"
- "0.0.0.0:9235:9229"
volumes:
- ../services/filestore/app:/overleaf/services/filestore/app
- ../services/filestore/app.js:/overleaf/services/filestore/app.js
Expand All @@ -70,7 +70,7 @@ services:
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "127.0.0.1:9239:9229"
- "0.0.0.0:9239:9229"
volumes:
- ../services/history-v1/api:/overleaf/services/history-v1/api
- ../services/history-v1/app.js:/overleaf/services/history-v1/app.js
Expand All @@ -84,7 +84,7 @@ services:
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "127.0.0.1:9236:9229"
- "0.0.0.0:9238:9229"
volumes:
- ../services/references/app:/overleaf/services/references/app
- ../services/references/config:/overleaf/services/references/config
Expand All @@ -95,7 +95,7 @@ services:
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "127.0.0.1:9236:9229"
- "0.0.0.0:9236:9229"
volumes:
- ../services/notifications/app:/overleaf/services/notifications/app
- ../services/notifications/app.js:/overleaf/services/notifications/app.js
Expand All @@ -106,7 +106,7 @@ services:
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "127.0.0.1:9240:9229"
- "0.0.0.0:9240:9229"
volumes:
- ../services/project-history/app:/overleaf/services/project-history/app
- ../services/project-history/app.js:/overleaf/services/project-history/app.js
Expand All @@ -117,18 +117,35 @@ services:
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "127.0.0.1:9237:9229"
- "0.0.0.0:9237:9229"
volumes:
- ../services/real-time/app:/overleaf/services/real-time/app
- ../services/real-time/app.js:/overleaf/services/real-time/app.js
- ../services/real-time/config:/overleaf/services/real-time/config

llm:
command: ["node", "--watch", "app.js"]
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
ports:
- "0.0.0.0:9241:9229"
volumes:
- ../services/llm/app.js:/overleaf/services/llm/app.js
- ../services/llm/config:/overleaf/services/llm/config
- ../services/llm/controllers:/overleaf/services/llm/controllers
- ../services/llm/models:/overleaf/services/llm/models
- ../services/llm/routes:/overleaf/services/llm/routes
- ../services/llm/services:/overleaf/services/llm/services
- ../services/llm/utils:/overleaf/services/llm/utils
- ../services/llm/package.json:/overleaf/services/llm/package.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文件目录结构是不是可以改得和其他模块一样?其他模块都是只需要挂载 app/, app.js, config/,这里分太多目录是不是没有必要

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary because when this image is built as defined in /develop/docker-compose.yml , node_modules are already installed. No need to reimport package.json here. Also, follow the order of other services is recommended, that

  • ../services/notifications/app:/overleaf/services/notifications/app
  • ../services/notifications/app.js:/overleaf/services/notifications/app.js
  • ../services/notifications/config:/overleaf/services/notifications/config


web:
command: ["node", "--watch", "app.js", "--watch-locales"]
command: ["node", "--watch", "app.mjs", "--watch-locales"]
environment:
- NODE_OPTIONS=--inspect=0.0.0.0:9229
- SESSION_SECRET=helloworld
ports:
- "127.0.0.1:9229:9229"
- "0.0.0.0:9229:9229"
volumes:
- ../services/web/app:/overleaf/services/web/app
- ../services/web/app.mjs:/overleaf/services/web/app.mjs
Expand Down
26 changes: 21 additions & 5 deletions develop/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ services:
image: mongo:5
command: --replSet overleaf
ports:
- "127.0.0.1:27017:27017" # for debugging
- "0.0.0.0:27017:27017" # for debugging
volumes:
- mongo-data:/data/db
extra_hosts:
- "host.docker.internal:host-gateway" # 添加主机网关(可选,用于容器访问宿主机)

references:
build:
Expand Down Expand Up @@ -123,11 +125,13 @@ services:
dockerfile: services/real-time/Dockerfile
env_file:
- dev.env
environment:
- SESSION_SECRET=helloworld

redis:
image: redis:5
ports:
- "127.0.0.1:6379:6379" # for debugging
- "0.0.0.0:6379:6379" # for debugging
volumes:
- redis-data:/data

Expand All @@ -139,6 +143,15 @@ services:
- dev.env
volumes:
- spelling-cache:/overleaf/services/spelling/cache
llm:
build:
context: ..
dockerfile: services/llm/Dockerfile
env_file:
- dev.env
depends_on:
- mongo
- redis

web:
build:
Expand All @@ -153,7 +166,8 @@ services:
- EMAIL_CONFIRMATION_DISABLED=true
- NODE_ENV=development
- OVERLEAF_ALLOW_PUBLIC_ACCESS=true
command: ["node", "app.js"]
- SESSION_SECRET=helloworld
command: ["node", "app.mjs"]
volumes:
- sharelatex-data:/var/lib/overleaf
- web-data:/overleaf/services/web/data
Expand All @@ -172,14 +186,16 @@ services:
- project-history
- real-time
- spelling
- llm

webpack:
user: root
build:
context: ..
dockerfile: services/web/Dockerfile
target: dev
command: ["npx", "webpack", "serve", "--config", "webpack.config.dev-env.js"]
ports:
- "127.0.0.1:80:3808"
- "0.0.0.0:80:3808"
volumes:
- ./webpack.config.dev-env.js:/overleaf/services/web/webpack.config.dev-env.js
- ./webpack.config.dev-env.js:/overleaf/services/web/webpack.config.dev-env.js
2 changes: 1 addition & 1 deletion libraries/settings/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./Settings')
module.exports = require('./Settings')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可能是编辑器配置的问题?好多文件都是最后一行没有换行 (no newline at the end of file)?

2 changes: 2 additions & 0 deletions services/llm/.vscode/settings.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS Code 的 config 不应该出现

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
129 changes: 129 additions & 0 deletions services/llm/DOCKER_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# LLM 项目 Docker 部署

本项目已配置完整的Docker部署环境,包含Node.js应用、MongoDB数据库和Redis缓存。

## 快速启动

### 构建并启动所有服务

```bash
# 构建并启动所有服务
docker-compose up -d

# 查看服务状态
docker-compose ps

# 查看应用日志
docker-compose logs -f llm-app
```

### 单独启动服务

```bash
# 仅启动数据库服务
docker-compose up -d mongodb redis

# 启动应用(确保数据库已启动)
docker-compose up -d llm-app
```

## 服务端口

- **LLM应用**: http://localhost:9241
- **MongoDB**: localhost:27017
- **Redis**: localhost:6379

## 环境变量

可以通过环境变量覆盖默认配置:

```bash
# 设置环境变量
export MONGO_URL="mongodb://custom-host:27017/mydb"
export REDIS_URL="redis://custom-host:6379"
export PORT=8080

# 使用环境变量启动
docker-compose up -d
```

## 开发模式

对于开发环境,可以挂载代码目录实现热重载:

```yaml
# 在docker-compose.yml中的llm-app服务添加:
volumes:
- .:/app
- /app/node_modules
```

## 数据持久化

- MongoDB数据存储在Docker卷 `mongodb_data` 中
- Redis数据存储在Docker卷 `redis_data` 中

## 常用命令

```bash
# 停止所有服务
docker-compose down

# 停止并删除卷(清除所有数据)
docker-compose down -v

# 重新构建应用镜像
docker-compose build llm-app

# 查看资源使用情况
docker-compose top

# 进入容器调试
docker-compose exec llm-app sh
docker-compose exec mongodb mongosh
docker-compose exec redis redis-cli
```

## 健康检查

所有服务都配置了健康检查:

- 应用健康检查:访问API端点
- MongoDB健康检查:执行ping命令
- Redis健康检查:执行ping命令

可以通过以下命令查看健康状态:

```bash
docker-compose ps
```

## 故障排除

### 端口冲突

如果端口已被占用,可以修改docker-compose.yml中的端口映射:

```yaml
ports:
- "9242:9241" # 将本地端口改为9242
```

### 数据库连接失败

确保服务启动顺序正确,应用会等待数据库健康检查通过后才启动。

### 日志查看

```bash
# 查看所有服务日志
docker-compose logs

# 查看特定服务日志
docker-compose logs llm-app
docker-compose logs mongodb
docker-compose logs redis

# 实时跟踪日志
docker-compose logs -f llm-app
```
21 changes: 21 additions & 0 deletions services/llm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:18.20.2 AS base

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider bump this version to latest lts as this service is recently written


WORKDIR /overleaf/services/llm


FROM base AS app

COPY package.json package-lock.json /overleaf/
COPY services/llm/package.json /overleaf/services/llm/
COPY libraries/ /overleaf/libraries/
COPY patches/ /overleaf/patches/

RUN cd /overleaf && npm ci

COPY services/llm/ /overleaf/services/llm/

FROM app
USER node
CMD ["node", "--expose-gc", "app.js"]


Loading