open-compute 是一个基于 Rust 构建的自托管、兼容 Cloudflare Workers 编程模型的 Serverless 平台。它将 Worker 运行时、部署管理、定时任务和存储服务整合到一个二进制程序中,支持 KV、D1、R2、Durable Objects、Queues 等能力,默认使用 SQLite 和本地存储,无需额外部署 Redis、PostgreSQL 或 Kubernetes,可运行在自己的 Linux 服务器上。

需要注意:它是单机自托管平台,而不是 Cloudflare 全球边缘网络的完整替代品。部分功能仍在开发中,实际使用前应核对兼容性。
安装
官方支持 Linux x86-64 / ARM64 和 macOS Apple Silicon。
# curl -fsSL https://open-compute.dev/install.sh | sh
curl --follow https://github.com/elliothux/open-compute/releases/download/v0.3.0/ocd-v0.3.0-linux-x64 -o /tmp/ocd
sudo mv /tmp/ocd /usr/local/bin/ocd
sudo chmod a+x /usr/local/bin/ocd
-> % ocd --version
ocd 0.3.0
catroll@eqr [22时26分19秒] [~/Projects/Mine/staticize] [develop *]
-> % ocd --help
Open Compute daemon
Usage: ocd [OPTIONS] <COMMAND>
Commands:
run Start the platform process in the foreground
start Start the one managed daemon service in the selected scope
stop Stop the one managed daemon service in the selected scope
restart Restart the one managed daemon service in the selected scope
status Show the selected daemon scope status
logs Show recent service logs
dashboard Open the operator Dashboard with a one-time login URL
setup Create a first-host configuration, secrets, and managed service
instances List registered instances in the selected daemon scope
instance Instance registration utilities
cache Clean regenerable daemon or instance cache entries
target Manage explicit remote open-compute Cf targets
cf Run the exact project-local Cf against one selected open-compute target
worker Offline Worker build utilities; these do not require platform configuration
config Configuration utilities
caddy Inspect and operate the formally pinned managed Caddy
doctor Read-only (or explicit `--full`) environment checks
capabilities Print the versioned P1 product and release capability contract
backup Offline full-platform snapshot operations
support-bundle Generate a bounded, secret-scanned local support archive
scheduler Offline scheduler recovery utilities
licenses Print the licenses included in this executable
docs List or print an embedded operator runbook
upgrade Replace this install with a newer formal release
uninstall Remove the receipt-owned program while preserving instance data by default
purge Irreversibly delete one exact registered local instance
help Print this message or the help of the given subcommand(s)
Options:
--config <CONFIG> Exact configuration path; relative values use the startup working directory
--instance <INSTANCE> Exact registered instance ID
--system Select the system OCD scope instead of the current user's scope
--no-update-check Skip upgrade reminder and asynchronous update-check refresh for this invocation
-h, --help Print help
-V, --version Print version
初始化并启动服务
-> % ocd setup --yes
SETUP_PLAN scope=user config=/home/catroll/.open-compute/instances/default/compute.toml data_dir=/home/catroll/.open-compute/instances/default/data listener=127.0.0.1:8787 dashboard=true start=true
Created symlink '/home/catroll/.config/systemd/user/default.target.wants/dev.open-compute.ocd.service' → '/home/catroll/.config/systemd/user/dev.open-compute.ocd.service'.
SETUP_OK instance=01a126362942755984f3c59f728021c1 config=/home/catroll/.open-compute/instances/default/compute.toml scope=user started=true
Next: run `ocd dashboard --instance 01a126362942755984f3c59f728021c1`.
-> % ocd status
OCD_STATUS user running
setup 会初始化配置、数据目录、用户级服务和第一个实例;status 用于确认运行状态。正常情况下应看到服务处于 READY 状态。
打开管理面板
# ocd dashboard # 需要认证,输入 token
ocd dashboard --instance 01a126362942755984f3c59f728021c1 # 直接登录
该命令会打开管理面板的登录链接。如果服务器没有图形界面,查看终端输出,并在能够访问该服务的浏览器中打开对应链接。
部署 Hello World
这里使用最简单的 TypeScript Worker,直接返回 JSON,不引入 Vite 等额外构建工具。
mkdir hello-worker
cd hello-worker
cat > cloudflare.config.ts <<'EOF'
import { defineConfig } from "cf/config";
export default defineConfig({
worker: {
name: "hello-worker",
entrypoint: "src/index.ts",
compatibilityDate: "2026-09-08",
workersDev: false,
},
});
EOF
mkdir src
cat > src/index.ts <<'EOF'
export default {
async fetch(request: Request): Promise<Response> {
const url = new URL(request.url);
return Response.json({
message: "Hello, World!",
path: url.pathname,
method: request.method,
});
},
};
EOF
第二步:安装开发工具
官方入门文档采用 Node.js 22.18+,并使用 Bun 管理依赖。
bun init -y
bun add -d cf@1.0.0-beta.12
注意:如果执行 bun init -y 时已经生成了 package.json,保留它即可。
第三步:部署 Worker
确保 ocd status 显示实例就绪,然后在项目目录执行:
ocd cf deploy --mode dev
这是将 Worker 部署到本地 open-compute 实例的命令。官方文档说明默认服务入口为 http://127.0.0.1:8787,具体 Worker 地址使用其规范域名。
第四步:测试接口
curl -i --resolve hello-worker.localhost:8787:127.0.0.1 http://hello-worker.localhost:8787/
预期返回:
HTTP/1.1 200 OK
Content-Type: application/json
{
"message": "Hello, World!",
"path": "/",
"method": "GET"
}
如果你在另一台机器上访问,需要配置平台的 Gateway 或其他反向代理,不能直接假定 localhost 域名可以跨机器访问。