taubyte-build-runtime-config
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBuild runtime config
构建运行时配置
When to use
适用场景
Use whenever a resource needs server-side build logic, runtime environment variables, or deployment-time setup. For Go functions, also load .
taubyte-go-sdk-constraints当资源需要服务端构建逻辑、运行时环境变量或部署时设置时使用。对于Go函数,还需加载****。
taubyte-go-sdk-constraintsHow builds are triggered
构建触发方式
-
Resource code and config are pushed to GitHub (normalworkflow for the function, website, or library repo as appropriate).
git push -
Remote cloud
After the push, the cloud is reached from GitHub (webhook). Builds trigger automatically — no extra inject step on your machine. -
Local Dream
GitHub cannot call into your laptop, so webhooks do not drive Dream the same way. After pushing to GitHub you must trigger the build from the local machine using Dream inject:Command Use for dream inject push-allConfig and code for the whole project — run from the project root ( = absolute project root).--pathdream inject push-specificIndividual resource repos that need their own inject after a full sync — e.g. libraries and websites (per-resource repo path and identifiers). Always runsuccessfully beforepush-allwhen both apply. Universe, Docker, and flag details (e.g.push-specific,--ridfor websites) live in--fn.taubyte-dream-local-operations
-
资源代码与配置推送至GitHub(针对函数、网站或库仓库的常规工作流)。
git push -
远程云端
推送完成后,GitHub通过webhook连接云端。构建会自动触发——无需在本地执行额外的注入步骤。 -
本地Dream
GitHub无法访问你的笔记本电脑,因此webhook无法以同样方式驱动Dream。推送至GitHub后,你必须在本地机器上通过Dream inject触发构建:命令 用途 dream inject push-all整个项目的配置与代码——需在项目根目录运行( = 项目根目录绝对路径)。--pathdream inject push-specific需要单独注入的单个资源仓库——例如库和网站(需指定资源仓库路径及标识符)。 当两种命令都适用时,务必先成功运行**,再运行push-all。Universe、Docker及参数细节(如网站的push-specific、--rid)可参考--fn**。taubyte-dream-local-operations
Targets
目标路径
- Function:
<project>/code/.../functions/<name>/.taubyte/ - Website repo:
<project>/websites/tb_website_<name>/.taubyte/ - Library repo:
<project>/libraries/tb_library_<name>/.taubyte/
- 函数:
<project>/code/.../functions/<name>/.taubyte/ - 网站仓库:
<project>/websites/tb_website_<name>/.taubyte/ - 库仓库:
<project>/libraries/tb_library_<name>/.taubyte/
Required checks
必要检查
- exists and is valid (image, workflow, etc. — not runtime env var declarations).
.taubyte/config.yaml - exists, is non-empty, writes output Taubyte expects (e.g. function wasm + ret-code, website assets under
.taubyte/build.sh)./out - Runtime env vars (if any) are set in (e.g.
.taubyte/build.shbefore build steps), not inexport ….config.yaml
- 存在且有效(包含镜像、工作流等——不包含运行时环境变量声明)。
.taubyte/config.yaml - 存在且非空,能输出Taubyte所需内容(例如函数wasm文件+返回码,网站资源存于
.taubyte/build.sh目录下)。/out - 运行时环境变量(如有)需在****中设置(例如构建步骤前使用
.taubyte/build.sh),不要放在export …中。config.yaml
Function config.yaml
pattern
config.yaml函数config.yaml
模板
config.yamlyaml
version: 1.00
environment:
image: taubyte/go-wasi:latest
workflow:
- buildKeep for image/workflow and similar metadata only.
config.yamlyaml
version: 1.00
environment:
image: taubyte/go-wasi:latest
workflow:
- build****仅用于存储镜像/工作流等元数据。
config.yamlFunction build.sh
pattern
build.sh函数build.sh
模板
build.shbash
#!/bin/bash
. /utils/wasm.shbash
#!/bin/bash
. /utils/wasm.shRuntime env for this build (example — use real names/values your code expects):
本次构建的运行时环境(示例——使用代码实际需要的名称/值):
export MY_VAR=value
export MY_VAR=value
build "${FILENAME}"
ret=$?
echo -n $ret > /out/ret-code
exit $ret
---build "${FILENAME}"
ret=$?
echo -n $ret > /out/ret-code
exit $ret
---Website build.sh
(technology-specific)
build.sh网站build.sh
(技术栈专属)
build.shWebsite is not one generic script — it must match how that repo is built (package manager, scripts, and especially where the bundler writes static files). Treating every Node site like Vite (always ) is wrong for Create React App and other stacks that emit or another directory.
build.shpackage.jsondist/build/Always
- Produce a non-empty (Taubyte’s deploy staging path inside the build environment — not the same as a framework’s own
/outfolder name on disk).out - Put build-time env here with , not in
export.config.yaml
Pick the pattern from the repo
Read ( or equivalent) and the framework docs to learn the real output directory, then copy that tree into .
package.jsonscripts.build/outExamples (illustrative — adjust to the project)
-
Plain static (no bundler):bash
#!/bin/bash cp index.html /out/ -
Vite (default output):
dist/bash#!/bin/bash npm ci npm run build cp -r dist/* /out/ -
Create React App /(output
react-scripts, notbuild/):dist/bash#!/bin/bash npm ci npm run build cp -r build/* /out/ -
Other stacks (Next, Nuxt, custom webpack, etc.): run that project’s install + production build commands, thenusing the directory that tool actually generates (check docs and a local build once if unsure).
cp -r <framework-output-dir>/* /out/
网站的**并非通用脚本**——它必须匹配该仓库的构建方式(包管理器、脚本,尤其是打包工具输出静态文件的路径)。将所有Node站点都当作Vite(默认输出)处理是错误的,因为Create React App等技术栈的输出目录是****或其他目录。
build.shpackage.jsondist/build/务必
- 生成非空的****目录(这是构建环境中Taubyte的部署临时路径——与框架自身磁盘上的
/out文件夹名称不同)。out - 在此处通过**设置构建时环境变量**,而非在
export中。config.yaml
根据仓库选择模板
查看****(或等效字段)及框架文档,了解实际输出目录,然后将该目录下的所有内容复制到中。
package.jsonscripts.build/out示例(仅供参考——需根据项目调整)
-
纯静态站点(无打包工具):bash
#!/bin/bash cp index.html /out/ -
Vite(默认输出****):
dist/bash#!/bin/bash npm ci npm run build cp -r dist/* /out/ -
Create React App /(输出**
react-scripts**,而非build/):dist/bash#!/bin/bash npm ci npm run build cp -r build/* /out/ -
其他技术栈(Next、Nuxt、自定义webpack等):运行该项目的安装+生产构建命令,然后使用工具实际生成的目录执行****(若不确定,可查看文档并在本地构建一次确认)。
cp -r <framework-output-dir>/* /out/
Rules
规则
- Env vars: declare and use them in only; do not put runtime env declarations in
.taubyte/build.shfor this purpose..taubyte/config.yaml - Websites: tailor to the actual framework and build output (e.g. Vite →
build.sh, CRA →dist/); never copy a Vite-only script onto a React-CRA repo without changing paths and commands.build/ - Do not push to GitHub before validating and
.taubyte/build.sh..taubyte/config.yaml - After changing build/config, remote cloud: rely on webhook-driven builds after push; Dream: run and, for website/library resource repos,
dream inject push-allas required, then verify logs/build perdream inject push-specific.taubyte-push-build-verify - Document notable env or build assumptions in the context log ().
taubyte-context-log - For Go compile issues, validate handler code against .
taubyte-go-sdk-constraints
- 环境变量:仅在**中声明和使用;切勿为该目的在
.taubyte/build.sh**中声明运行时环境变量。.taubyte/config.yaml - 网站:根据实际框架和构建输出调整**(例如Vite →
build.sh**,CRA →dist/);切勿直接将仅适用于Vite的脚本复制到React-CRA仓库而不修改路径和命令。build/ - 在验证**和
.taubyte/build.sh**之前,不要推送至GitHub。.taubyte/config.yaml - 修改构建/配置后,远程云端:推送后依赖webhook驱动构建;Dream:运行**,对于网站/库资源仓库,按需运行
dream inject push-all,然后根据dream inject push-specific**验证日志/构建结果。taubyte-push-build-verify - 在上下文日志()中记录值得注意的环境或构建假设。
taubyte-context-log - 若遇到Go编译问题,需根据****验证处理器代码。
taubyte-go-sdk-constraints