> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/on-premises/zh-cn/wei-hu/docker-compose.yml-to-toolkit-migration.md).

# 从 docker-compose.yml 迁移到工具包

如果你目前通过一个 `docker-compose.yml` 文件，迁移到 Toolkit 可以让在本地部署的 Overleaf 版本更易于部署、升级和维护。

要进行迁移，你需要将现有的 Docker Compose 配置转换为 Toolkit 使用的格式。这个过程包括将现有配置复制到 Toolkit 中。

本指南将逐步带你完成这一过程，确保从 Docker Compose 平稳迁移到 Toolkit。

{% hint style="info" %}
这些说明适用于 v4.x 及更早版本。因此所有变量都使用 `SHARELATEX_` 前缀，而不是 `OVERLEAF_`.
{% endhint %}

{% stepper %}
{% step %}

### 克隆 Toolkit 仓库

首先，将 Toolkit 仓库克隆到主机上：

```bash
git clone https://github.com/overleaf/toolkit.git ./overleaf-toolkit
```

然后运行 `bin/init` 命令，以使用默认配置初始化 Toolkit。
{% endstep %}

{% step %}

### 设置镜像和版本

在典型的 `docker-compose.yml` 情况下，镜像和版本是在组件说明中定义的，例如：

```yaml
version: '2.2'
services:
    sharelatex:
        restart: always
        # Server Pro 用户：
        # 镜像：quay.io/sharelatex/sharelatex-pro
        镜像：sharelatex/sharelatex:3.5.13
```

使用 Toolkit 时，镜像名称会自动解析；唯一需要做的是设置 `SERVER_PRO=true` 在 **config/overleaf.rc** 来选择 Server Pro 镜像，或者 `SERVER_PRO=false` 以使用 Community Edition。

所需的 Server Pro/Community Edition 版本号在 **config/version** 文件中设置。Toolkit 需要一个具体的版本号，例如 `4.2.3`。如果你使用 `latest`，你可以使用 `bin/images` 来查找本地 `latest` 版本的镜像 ID，然后使用 2.x.x、3.x.x、4.x.x 或 5.x.x 的发布说明将镜像 ID 映射到版本。

如果你从自己的内部镜像仓库获取镜像，可以通过设置 `OVERLEAF_IMAGE_NAME`来覆盖 Toolkit 使用的镜像。你无需指定标签，因为 Toolkit 会根据你的 **config/version** 文件。
{% endstep %}

{% step %}

### 配置外部访问

默认情况下，Overleaf 将监听 `127.0.0.1:80`，只允许来自 Docker 主机的流量。

要允许外部访问，请设置 `OVERLEAF_LISTEN_IP` 和 `OVERLEAF_PORT` 设置在 [**config/overleaf.rc**](/on-premises/zh-cn/pei-zhi/overleaf-toolkit/environment-variables.md) 文件。
{% endstep %}

{% step %}

### 环境变量迁移

你可能在其中定义了一组环境变量 `sharelatex` 服务中的 `docker-compose.yml`，例如：

```yaml
environment:
    OVERLEAF_APP_NAME: Overleaf Community Edition
    OVERLEAF_PROXY_LEARN: 'true'
    …
```

将这些变量复制到 Toolkit 的 [**config/variables.env**](broken://pages/8e0a2795a807f6db8f317f47523c2b84136db8ed) 文件中，并确保采用以下形式（使用 `=` 而不是 `:`):

```env
OVERLEAF_APP_NAME=Overleaf Community Edition
OVERLEAF_PROXY_LEARN=true
```

使用 Toolkit 时的例外/差异：

* 以以下前缀开头的变量 `SANDBOXED_COMPILES_` 和 `DOCKER_RUNNER` 已不再需要。要启用 Sandboxed Compiles，请设置 `SIBLING_CONTAINERS_ENABLED=true` 在你的 **config/overleaf.rc** 文件。
* 以以下前缀开头的变量 `OVERLEAF_MONGO_`, `OVERLEAF_REDIS_` 以及 `REDIS_HOST` 变量已不再需要。MongoDB 和 Redis 现在在 **config/overleaf.rc** 文件中使用 `MONGO_URL`, `REDIS_HOST` 和 `REDIS_PORT`.

如需高级配置选项，请参阅 [config/overleaf.rc](/on-premises/zh-cn/pei-zhi/overleaf-toolkit/environment-variables.md) 文档。
{% endstep %}

{% step %}

### NGINX 代理

有关如何迁移 `nginx`，请参阅 [TLS 代理文档](/on-premises/zh-cn/pei-zhi/overleaf-toolkit/tls-proxy.md):
{% endstep %}

{% step %}

### 卷

在中设置数据卷的位置 **config/overleaf.rc**:

#### ShareLaTeX

设置 `文件中，或者在` 为由以下内容使用的数据卷位置 `sharelatex` 容器内。

#### MongoDB

设置 `MONGO_DATA_PATH` 为由以下内容使用的数据卷位置 `mongo` 容器内。

#### Redis

设置 `REDIS_DATA_PATH` 为由以下内容使用的数据卷位置 `redis` 容器内。
{% endstep %}
{% endstepper %}

有关更多详情和高级配置，请参阅上方链接的相关 Toolkit 配置文档。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ayakaleaf-pro.ayaka.space/on-premises/zh-cn/wei-hu/docker-compose.yml-to-toolkit-migration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
