> For the complete documentation index, see [llms.txt](https://overleaf-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://overleaf-pro.ayaka.space/on-premises/zh-tw/wei-hu/docker-compose.yml-to-toolkit-migration.md).

# 從 docker-compose.yml 遷移至 Toolkit

如果您目前是透過一個 Docker Compose `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 使用者：
        # image: quay.io/sharelatex/sharelatex-pro
        image: sharelatex/sharelatex:3.5.13
```

使用 Toolkit 時，映像檔名稱會自動解析；唯一的要求是設定 `SERVER_PRO=true` 在 **config/overleaf.rc** 以選擇 Server Pro 映像檔，或 `SERVER_PRO=false` 以使用社群版。

所需的 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 對應到版本。

如果您是從自己的內部登錄來源取得映像檔，可以透過設定以下項目來覆寫 Toolkit 使用的映像檔： `OVERLEAF_IMAGE_NAME`。您不需要指定標籤，因為 Toolkit 會根據您的 **config/version** 檔案。
{% endstep %}

{% step %}

### 設定外部存取

預設情況下，Overleaf 會監聽 `127.0.0.1:80`，且只允許來自 Docker 主機的流量。

若要允許外部存取，請設定 `OVERLEAF_LISTEN_IP` 以及 `OVERLEAF_PORT` 在 [**config/overleaf.rc**](/on-premises/zh-tw/she-ding/overleaf-toolkit/environment-variables.md) 檔案。
{% endstep %}

{% step %}

### 環境變數遷移

您很可能會有一組環境變數定義於 `sharelatex` 您的 service 中 `docker-compose.yml`，例如：

```yaml
environment:
    OVERLEAF_APP_NAME: Overleaf 社群版
    OVERLEAF_PROXY_LEARN: 'true'
    …
```

將這些變數複製到 Toolkit 的 [**config/variables.env**](broken://pages/bee4c82a30586f16dd4f9e8e432de3ea2df074eb) 檔案中，並確保使用下列格式（使用 `=` 而不是 `:`):

```env
OVERLEAF_APP_NAME=Overleaf 社群版
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-tw/she-ding/overleaf-toolkit/environment-variables.md) 說明文件。
{% endstep %}

{% step %}

### NGINX Proxy

如需遷移 `nginx`，請參閱 [TLS Proxy 說明文件](/on-premises/zh-tw/she-ding/overleaf-toolkit/tls-proxy.md):
{% endstep %}

{% step %}

### 磁碟區

設定資料磁碟區的位置於 **config/overleaf.rc**:

#### ShareLaTeX

將 `OVERLEAF_DATA_PATH` 設定為下列資料磁碟區所使用的位置： `sharelatex` 容器內的 .log 檔案。

#### MongoDB

將 `MONGO_DATA_PATH` 設定為下列資料磁碟區所使用的位置： `mongo` 容器內的 .log 檔案。

#### Redis

將 `REDIS_DATA_PATH` 設定為下列資料磁碟區所使用的位置： `redis` 容器內的 .log 檔案。
{% 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://overleaf-pro.ayaka.space/on-premises/zh-tw/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.
