# 哪个命令/进程构建了包含的资源？

**URL:** <https://meta.discourse.org/t/what-command-process-builds-the-included-assets/242335>\
**Category:** Self-hosting\
**Tags:** unsupported-install, docker\
**Created:** [2022年十月19日 10:04 UTC](https://meta.discourse.org/t/what-command-process-builds-the-included-assets/242335 "2022-10-19T10:04:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [2022年十月19日 10:04 UTC](https://meta.discourse.org/t/what-command-process-builds-the-included-assets/242335/1 "2022-10-19T10:04:45Z")

</div>

构建过程中创建样式表资产（例如 `/stylesheets/color_definitions_dark_1_1_603243e2b6c0b7xydx234the00538538bd705.css`）的流程是什么？

我猜这是打包（bundling）的过程？

如果这些文件丢失，可能是什么原因？

这些文件应该在启动 ember-cli 或 rails 服务器时就开始存在吗？

我应该采取什么方法来从标准的 discourse 镜像在 docker 中构建这些文件，还是仅仅启动服务器就应该期望它们存在？

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [2022年十月19日 10:27 UTC](https://meta.discourse.org/t/what-command-process-builds-the-included-assets/242335/2 "2022-10-19T10:27:33Z")

</div>

样式表由 rails 应用程序按需构建，因此理论上您无需手动执行任何操作。

运行 `bin/rake assets:precompile` 将会预编译它们，如果您想为部署到多个主机创建优化的 docker 镜像，这会很有用。

---

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [2022年十月19日 10:29 UTC](https://meta.discourse.org/t/what-command-process-builds-the-included-assets/242335/3 "2022-10-19T10:29:52Z")

</div>

谢谢你，大卫，这大大缩小了我调查的范围。

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2022年十月19日 16:39 UTC](https://meta.discourse.org/t/what-command-process-builds-the-included-assets/242335/4 "2022-10-19T16:39:26Z")

</div>

> [@david](#):
>
> 样式表由 rails 应用程序按需构建，所以理论上您无需手动执行任何操作。

啊哈！我一直对此感到好奇。

> [@david](#):
>
> 运行 `bin/rake assets:precompile` 将会预先编译它们，如果您想为部署到多个主机创建优化的 docker 镜像，这会很有用。

如果它们在 S3 上并且是按需编译的，它们也会被上传到 S3 吗？

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [2022年十月19日 16:42 UTC](https://meta.discourse.org/t/what-command-process-builds-the-included-assets/242335/5 "2022-10-19T16:42:58Z")

</div>

> [@pfaffman](#):
>
> 如果它们在 S3 上并且是按需编译的

按需编译的资源（例如，样式表、主题 JavaScript、SVG 精灵）不会上传到 S3。它们直接从应用程序获取（或者，如果配置了 CDN\_URL，则通过 CDN\_URL 获取）。

像核心/插件 JS 和区域设置这样的静态内容由 `assets:precompile` 生成，并保证在运行时永远不会更改。

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2022年十月19日 16:46 UTC](https://meta.discourse.org/t/what-command-process-builds-the-included-assets/242335/6 "2022-10-19T16:46:00Z")

</div>

> [@david](#):
>
> 即时编译的资源（例如样式表、主题 JavaScript、SVG 精灵）不会上传到 S3。它们直接从应用程序获取（如果配置了 CDN\_URL，则通过 CDN\_URL 获取）。

我明白了；这有助于解释为什么有些东西是由应用程序提供的。如果有多个容器在运行（例如，在负载均衡器后面），每个容器都会按需生成这些资源。

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [2022年十月19日 16:50 UTC](https://meta.discourse.org/t/what-command-process-builds-the-included-assets/242335/7 "2022-10-19T16:50:45Z")

</div>

是的，没错。这些东西也倾向于缓存到 postgres/redis 中，因此它们只需要由接收到请求的第一个应用程序容器生成。其他容器可以从 redis/postgres 中廉价地获取编译后的版本并将其写入文件系统。

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2022年十月19日 21:18 UTC](https://meta.discourse.org/t/what-command-process-builds-the-included-assets/242335/8 "2022-10-19T21:18:55Z")

</div>

> [@david](#):
>
> 其他容器随后可以从redis/postgres廉价地获取编译后的版本并将其写入文件系统。

而且，如果存在CDN，那么他们甚至可能不需要这样做，我猜。

我正在与某人合作，他似乎在某些资源未加载（一些图标显示得非常大）方面遇到问题，我正在寻找一些解释。

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2022年十一月18日 21:19 UTC](https://meta.discourse.org/t/what-command-process-builds-the-included-assets/242335/9 "2022-11-18T21:19:32Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
