docs(wasm-go): update README related to wasm-go (#2586)

Co-authored-by: 澄潭 <zty98751@alibaba-inc.com>
This commit is contained in:
xingpiaoliang
2025-07-16 10:27:40 +08:00
committed by GitHub
parent bdc3ecab71
commit ce271849de
13 changed files with 27 additions and 35 deletions

View File

@@ -41,16 +41,14 @@ You can also use `make build-push` to build and push the image at the same time.
You can also build wasm locally and copy it to a Docker image. This requires a local build environment:
Go version: >= 1.18
TinyGo version: >= 0.25.0
Go version: >= 1.24
The following is an example of building the plugin [request-block](extensions/request-block).
### step1. build wasm
```bash
tinygo build -o main.wasm -scheduler=none -target=wasi ./extensions/request-block/main.go
GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o ./extensions/request-block/main.wasm ./extensions/request-block
```
### step2. build and push docker image
@@ -63,8 +61,8 @@ COPY main.wasm plugin.wasm
```
```bash
docker build -t <your_registry_hub>/request-block:1.0.0 -f <your_dockerfile> .
docker push <your_registry_hub>/request-block:1.0.0
docker build -t <your_registry_hub>/request-block:2.0.0 -f <your_dockerfile> .
docker push <your_registry_hub>/request-block:2.0.0
```
## Apply WasmPlugin API
@@ -83,7 +81,7 @@ spec:
defaultConfig:
block_urls:
- "swagger.html"
url: oci://<your_registry_hub>/request-block:1.0.0
url: oci://<your_registry_hub>/request-block:2.0.0
```
When the resource is applied on the Kubernetes cluster with `kubectl apply -f <your-wasm-plugin-yaml>`,