> 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-tw/wei-hu/docker-compose.yml-to-toolkit-migration.md).

# 從 docker-compose.yml 遷移到 Toolkit

如果您目前是透過一個 `docker-compose.yml` 檔案使用 Docker Compose，遷移到 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` 以使用 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-tw/she-ding/overleaf-toolkit/environment-variables.md) 檔案。
{% endstep %}

{% step %}

### 環境變數遷移

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

```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://ayakaleaf-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.
