rivet-deploy-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDeploy an image to a Rivet cluster
将 image 部署到 Rivet cluster
A deploy is a local build, one upload, and two Code Mode operations run through the tool. It needs Docker and a shell. It does not need the Rivet CLI or any other login.
execute一次部署包括一次本地 build、一次上传,以及通过 工具执行的两项 Code Mode 操作。它需要 Docker 和 shell,不需要 Rivet CLI 或任何其他登录凭据。
executeBefore starting
开始之前
- Confirm the session can deploy. If does not list
search, the session is read-only or is pinned to a project or namespace, and the deploy cannot run from here. Say so instead of retrying.rivet.deploy.prepare - Pick the cluster. Run in
return (await rivet.cloud.v2.clusters.list()).items;and use theexecutefield of the one to deploy to, which is its name. On a connection pinned to a cluster,clusterreports it, andrivet.context()is left out of every call below.cluster
- 确认 session 可以执行部署。如果 未列出
search,说明该 session 是只读的,或已固定到某个 project 或 namespace,无法从此处执行部署。应直接说明情况,不要重试。rivet.deploy.prepare - 选择 cluster。在 中运行
execute,并使用目标 cluster 的return (await rivet.cloud.v2.clusters.list()).items;字段,其值即 cluster 名称。如果连接已固定到某个 cluster,cluster会报告该 cluster,此时以下所有调用均省略rivet.context()。cluster
Steps
步骤
-
Build and measure the image in the shell. The platform must be.
linux/amd64shdocker build --platform linux/amd64 -t app . docker image save app -o image.tar wc -c < image.tar # content_length openssl md5 -binary image.tar | base64 # content_md5The tarball must be 5 GiB or smaller. Measure the exact file that will be uploaded, because the build fails verification when either value differs. -
Register the build.js
return await rivet.deploy.prepare({ cluster: "my-cluster", image: "app:latest", content_length: 48213504, content_md5: "1B2M2Y8AsgTpgAmY7PhCfg==", });is a number, not a string. Passcontent_lengthwhen the tarball is not namedfile. Keep the returnedimage.tar.build_id -
Run the returnedcommand in the shell, unchanged. It is a curl command against a presigned URL that is good for that one tarball until
upload, so it carries no Rivet credentials.expires_at -
Roll out, repeating untilis
done.truejsreturn await rivet.deploy.rollout({ cluster: "my-cluster", build_id: "<build_id>" });Each call advances one step and returns immediately, so call it again whileisdone. Seefalsefor each step, the errors, and how to roll back.references/rollout.md -
Report theand the
build_idfrom the final result to the user. Theendpointsis what a later rollback needs.build_id
-
在 shell 中构建 image 并测量大小。平台必须为。
linux/amd64shdocker build --platform linux/amd64 -t app . docker image save app -o image.tar wc -c < image.tar # content_length openssl md5 -binary image.tar | base64 # content_md5tar 包大小必须不超过 5 GiB。请测量将要上传的确切文件,因为任一值不一致都会导致构建验证失败。 -
注册 build。js
return await rivet.deploy.prepare({ cluster: "my-cluster", image: "app:latest", content_length: 48213504, content_md5: "1B2M2Y8AsgTpgAmY7PhCfg==", });是数字,不是字符串。如果 tar 包不名为content_length,请传入image.tar。保留返回的file。build_id -
在 shell 中原样运行返回的命令。这是一条针对预签名 URL 的 curl 命令,该 URL 在
upload之前仅适用于对应的 tar 包,因此不包含 Rivet 凭据。expires_at -
执行 rollout,重复调用直到为
done。truejsreturn await rivet.deploy.rollout({ cluster: "my-cluster", build_id: "<build_id>" });每次调用都会推进一个步骤并立即返回,因此当为done时应再次调用。有关每个步骤、错误及回滚方式,请参阅false。references/rollout.md -
向用户报告和最终结果中的
build_id。后续回滚需要使用该endpoints。build_id
Rules
规则
- Never rebuild or re-upload to retry a rollout. Call again with the same
rivet.deploy.rollout.build_id - Use for the whole deploy. Do not drive
rivet.deploy.*orrivet.cloud.v2.builds.*by hand, because an upsert replaces the pool's settings wholesale and would drop its allowlist.rivet.cloud.v2.runnerPools.upsert - Do not guess a ,
cluster, orregionname. List them first.pool
- rollout 失败时,绝不要重新构建或重新上传。使用相同的 再次调用
build_id。rivet.deploy.rollout - 整个部署过程都应使用 。不要手动调用
rivet.deploy.*或rivet.cloud.v2.builds.*,因为 upsert 会整体替换 pool 的设置,从而丢失其 allowlist。rivet.cloud.v2.runnerPools.upsert - 不要猜测 、
cluster或region的名称。请先列出它们。pool