git clone https://github.com/ImSingee/hammal.git cd hammal mv wrangler.toml.sample wrangler.toml
获取 account_id id
1
wrangler whoami
或者页面上查看
#创建 KV namespace
1 2 3 4 5 6 7
➜ hammal-demo: wrangler kv:namespace create docker_cache ⛅️ wrangler 3.59.0 (update available 3.60.1) ------------------------------------------------------- 🌀 Creating namespace with title "docker-proxy-docker_cache" ✨ Success! Add the following to your configuration file in your kv_namespaces array: { binding = "docker_cache", id = "00fe55d37f61**********47bf" }
修改wrangler.toml文件
1 2 3 4 5 6 7 8 9
name = "docker-proxy" //要创建的cloudflare worlers 应用程序的名称 account_id = "1492*********" //上一步查看到的account id workers_dev = true main = "./src/index.ts" compatibility_date = "2021-12-07" //将创建KV namespace 中的id 写入下方,注意 binding = "HAMMAL_CACHE" 不需要修改 kv_namespaces = [ { binding = "HAMMAL_CACHE", id = "00fe55d3*****95ac1063847bf" } ]
部署应用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
➜ hammal-demo git:(main) ✗ wrangler deploy ⛅️ wrangler 3.59.0 (update available 3.60.1) ------------------------------------------------------- Total Upload: 5.59 KiB / gzip: 1.78 KiB Your worker has access to the following bindings: - KV Namespaces: - HAMMAL_CACHE: 00fe5*******1063847bf Uploaded docker-proxy (1.05 sec) Published docker-proxy (4.16 sec) https://docker-proxy.121324124.workers.dev Current Deployment ID: 0794aebc-*****087e01014b44 Current Version ID: 0794aeb*******087e01014b44
Note: Deployment ID has been renamed to Version ID. Deployment ID is present to maintain compatibility with the previous behavior of this command. This output will change in a future version of Wrangler. To learn more visit: https://developers.cloudflare.com/workers/configuration/versions-and-deployments