# 如何重新编译插件而不重新编译 Discourse？

**URL:** <https://meta.discourse.org/t/how-to-recompile-plugins-and-not-to-recompile-discourse/159503>\
**Category:** Support\
**Created:** [2020年八月1日 07:08 UTC](https://meta.discourse.org/t/how-to-recompile-plugins-and-not-to-recompile-discourse/159503 "2020-08-01T07:08:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)\
**Post date:** [2020年八月1日 08:01 UTC](https://meta.discourse.org/t/how-to-recompile-plugins-and-not-to-recompile-discourse/159503/2 "2020-08-01T08:01:48Z")

</div>

亲爱的 @Ed_Bobkov，

如果您确实认为必须如此，可以通过“不受支持的方式”实现您想要的“核心功能”，即：(1) 使用您自己的基础 Discourse Docker 镜像，以及 (2) 使用分叉后的 Discourse GitHub 代码库来构建 Discourse，方法是运行 Discourse 源代码的分叉版本。

在这种情况下，您需要执行以下操作：

- 编辑 Dockerfile，并添加您分叉的 [Discourse 源代码仓库](https://github.com/discourse/discourse_docker/blob/5f7f09539cac22ee995eb394bccf7369b8646efa/image/base/Dockerfile#L138)
- 编辑启动脚本，并添加一个 [替代的基础 Docker 镜像](https://github.com/discourse/discourse_docker/blob/5f7f09539cac22ee995eb394bccf7369b8646efa/launcher#L91)

请参阅 Discourse Dockerfile 中的这一行：

```plaintext
git clone https://github.com/discourse/discourse.git &&\

```

以及启动脚本中的这一行：

```plaintext
image="discourse/base:2.0.20200512-1735"

```

如果您运行的是私有 Docker 注册表，可以将您选择的 Discourse 基础镜像推送到您的私有注册表中，例如：

```plaintext
image="localhost:5000/base:2.0.20200512-1735"

```

同样，如果您分叉了 Discourse，可以在上述 `Dockerfile` 中使用该分叉版本，例如：

```plaintext
git clone https://github.com/your_git_account/discourse.git &&\

```

这将帮助您管理基础 Docker 镜像和构建代码。

当然，我们不推荐这样做，因为您将无法受益于 Discourse 提供的所有错误修复、安全（和功能）更新；而且这种方法既不受支持，也不被推荐。

希望这对您有所帮助，@Ed_Bobkov

注意：采用此方法时，您仍然需要重新构建 Discourse；但您可以控制 (1) 基础 Docker 镜像的版本和 (2) Discourse GitHub 仓库的代码。由于此方法完全不受支持（据我所知），您需“自行承担风险”。

另请参阅：

> [@How can I customized my own site](https://meta.discourse.org/t/how-can-i-customized-my-own-site/157004/5):
>
> If you absolutely have to run a fork of the source code (which is definitely not recommended, you can accomplish almost everything with a [plugin](https://meta.discourse.org/t/beginners-guide-to-creating-discourse-plugins-part-1/30515)), then you will need to: build a new base image with a [different source repository](https://github.com/discourse/discourse_docker/blob/5f7f09539cac22ee995eb394bccf7369b8646efa/image/base/Dockerfile#L138) pass the launcher a [different --run-image parameter](https://github.com/discourse/discourse_docker/blob/5f7f09539cac22ee995eb394bccf7369b8646efa/launcher#L91)

---

_[View the full topic](https://meta.discourse.org/t/how-to-recompile-plugins-and-not-to-recompile-discourse/159503)._
