diff --git a/plugins/wasm-go/DockerfileBuilder b/plugins/wasm-go/DockerfileBuilder index 120951e11..de9945889 100644 --- a/plugins/wasm-go/DockerfileBuilder +++ b/plugins/wasm-go/DockerfileBuilder @@ -32,4 +32,4 @@ RUN set -e; \ tar -C /usr/local/bin -xzf oras.tgz && rm oras.tgz; \ echo "done"; -ENV PATH=$PATH:/usr/local/go/bin:/usr/local/tinygo/bin:/usr/local/bin +ENV PATH=$PATH:/usr/local/go/bin:/usr/local/bin diff --git a/plugins/wasm-go/Makefile b/plugins/wasm-go/Makefile index f2d3c37a8..aec15250d 100644 --- a/plugins/wasm-go/Makefile +++ b/plugins/wasm-go/Makefile @@ -52,7 +52,6 @@ builder: --platform linux/amd64,linux/arm64 \ --build-arg BASE_IMAGE=docker.io/ubuntu \ --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg TINYGO_VERSION=$(TINYGO_VERSION) \ --build-arg ORAS_VERSION=$(ORAS_VERSION) \ --build-arg HIGRESS_VERSION=$(HIGRESS_VERSION) \ --build-arg USE_HIGRESS_TINYGO=$(USE_HIGRESS_TINYGO) \ diff --git a/plugins/wasm-go/README.md b/plugins/wasm-go/README.md index 00656f7ad..657a932e1 100644 --- a/plugins/wasm-go/README.md +++ b/plugins/wasm-go/README.md @@ -45,16 +45,15 @@ output wasm file: extensions/request-block/plugin.wasm 编译环境要求如下: -- Go 版本: >= 1.18 (需要支持范型特性) - -- TinyGo 版本: >= 0.28.1 +- Go 版本: >= 1.24 (需要支持 wasm 构建特性) 下面是本地多步骤构建 [request-block](extensions/request-block) 的例子。 ### step1. 编译 wasm ```bash -tinygo build -o main.wasm -scheduler=none -target=wasi -gc=custom -tags='custommalloc nottinygc_finalizer' ./extensions/request-block/main.go +GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o ./extensions/request-block/main.wasm ./extensions/request-block + ``` 详细的编译说明,包括要使用更复杂的 Header 状态管理机制,请参考[ Go 开发插件的最佳实践](https://higress.io/docs/latest/user/wasm-go/#3-%E7%BC%96%E8%AF%91%E7%94%9F%E6%88%90-wasm-%E6%96%87%E4%BB%B6)。 @@ -70,8 +69,8 @@ COPY main.wasm plugin.wasm ``` ```bash -docker build -t /request-block:1.0.0 -f . -docker push /request-block:1.0.0 +docker build -t /request-block:2.0.0 -f . +docker push /request-block:2.0.0 ``` ## 创建 WasmPlugin 资源使插件生效 @@ -144,7 +143,7 @@ spec: block_bodies: - "foo" - "bar" - url: oci:///request-block:1.0.0 + url: oci:///request-block:2.0.0 ``` 所有规则会按上面配置的顺序一次执行匹配,当有一个规则匹配时,就停止匹配,并选择匹配的配置执行插件逻辑。 diff --git a/plugins/wasm-go/README_EN.md b/plugins/wasm-go/README_EN.md index 675bf0bb2..0addf4a05 100644 --- a/plugins/wasm-go/README_EN.md +++ b/plugins/wasm-go/README_EN.md @@ -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 /request-block:1.0.0 -f . -docker push /request-block:1.0.0 +docker build -t /request-block:2.0.0 -f . +docker push /request-block:2.0.0 ``` ## Apply WasmPlugin API @@ -83,7 +81,7 @@ spec: defaultConfig: block_urls: - "swagger.html" - url: oci:///request-block:1.0.0 + url: oci:///request-block:2.0.0 ``` When the resource is applied on the Kubernetes cluster with `kubectl apply -f `, diff --git a/plugins/wasm-go/extensions/ai-cache/option.yaml b/plugins/wasm-go/extensions/ai-cache/option.yaml index 8be6bfd1c..d0e92713d 100644 --- a/plugins/wasm-go/extensions/ai-cache/option.yaml +++ b/plugins/wasm-go/extensions/ai-cache/option.yaml @@ -5,14 +5,13 @@ version: 1.0.0 build: # The official builder image version builder: - go: 1.19 - tinygo: 0.28.1 + go: 1.24.4 oras: 1.0.0 # The WASM plugin project directory input: ./ # The output of the build products output: - # Choose between 'files' and 'image' + # Choose between 'files' and 'image' type: files # Destination address: when type=files, specify the local directory path, e.g., './out' or # type=image, specify the remote docker repository, e.g., 'docker.io//' diff --git a/plugins/wasm-go/extensions/ai-history/option.yaml b/plugins/wasm-go/extensions/ai-history/option.yaml index 8be6bfd1c..d0e92713d 100644 --- a/plugins/wasm-go/extensions/ai-history/option.yaml +++ b/plugins/wasm-go/extensions/ai-history/option.yaml @@ -5,14 +5,13 @@ version: 1.0.0 build: # The official builder image version builder: - go: 1.19 - tinygo: 0.28.1 + go: 1.24.4 oras: 1.0.0 # The WASM plugin project directory input: ./ # The output of the build products output: - # Choose between 'files' and 'image' + # Choose between 'files' and 'image' type: files # Destination address: when type=files, specify the local directory path, e.g., './out' or # type=image, specify the remote docker repository, e.g., 'docker.io//' diff --git a/plugins/wasm-go/extensions/ai-proxy/README_dev.md b/plugins/wasm-go/extensions/ai-proxy/README_dev.md index 70634fc88..04a4f983e 100644 --- a/plugins/wasm-go/extensions/ai-proxy/README_dev.md +++ b/plugins/wasm-go/extensions/ai-proxy/README_dev.md @@ -5,13 +5,13 @@ ***Linux/macOS:*** ```shell -DOCKER_BUILDKIT=1; docker build --build-arg PLUGIN_NAME=ai-proxy --build-arg EXTRA_TAGS=proxy_wasm_version_0_2_100 --build-arg BUILDER=higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/wasm-go-builder:go1.19-tinygo0.28.1-oras1.0.0 -t ai-proxy:0.0.1 --output ./out ../.. +DOCKER_BUILDKIT=1; docker build --build-arg PLUGIN_NAME=ai-proxy --build-arg EXTRA_TAGS=proxy_wasm_version_0_2_100 --build-arg BUILDER=higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/wasm-go-builder:go1.24.0-oras1.0.0 -t ai-proxy:0.0.1 --output ./out ../.. ``` ***Windows:*** ```powershell -$env:DOCKER_BUILDKIT=1; docker build --build-arg PLUGIN_NAME=ai-proxy --build-arg EXTRA_TAGS=proxy_wasm_version_0_2_100 --build-arg BUILDER=higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/wasm-go-builder:go1.19-tinygo0.28.1-oras1.0.0 -t ai-proxy:0.0.1 --output .\out ..\.. +$env:DOCKER_BUILDKIT=1; docker build --build-arg PLUGIN_NAME=ai-proxy --build-arg EXTRA_TAGS=proxy_wasm_version_0_2_100 --build-arg BUILDER=higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/wasm-go-builder:go1.24.0-oras1.0.0 -t ai-proxy:0.0.1 --output .\out ..\.. ``` ## 本地运行 diff --git a/plugins/wasm-go/extensions/ai-proxy/option.yaml b/plugins/wasm-go/extensions/ai-proxy/option.yaml index 200674359..496cb206f 100644 --- a/plugins/wasm-go/extensions/ai-proxy/option.yaml +++ b/plugins/wasm-go/extensions/ai-proxy/option.yaml @@ -5,14 +5,13 @@ version: 1.0.0 build: # The official builder image version builder: - go: 1.19 - tinygo: 0.28.1 + go: 1.24.4 oras: 1.0.0 # The WASM plugin project directory input: ./ # The output of the build products output: - # Choose between 'files' and 'image' + # Choose between 'files' and 'image' type: files # Destination address: when type=files, specify the local directory path, e.g., './out' or # type=image, specify the remote docker repository, e.g., 'docker.io//' diff --git a/plugins/wasm-go/extensions/frontend-gray/Makefile b/plugins/wasm-go/extensions/frontend-gray/Makefile index 61e6b1cbd..fc1872d89 100644 --- a/plugins/wasm-go/extensions/frontend-gray/Makefile +++ b/plugins/wasm-go/extensions/frontend-gray/Makefile @@ -1,10 +1,10 @@ .PHONY: reload build: - tinygo build -o main.wasm -scheduler=none -target=wasi -gc=custom -tags='custommalloc nottinygc_finalizer' ./main.go + GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o ./main.wasm ./main.go reload: - tinygo build -o main.wasm -scheduler=none -target=wasi -gc=custom -tags='custommalloc nottinygc_finalizer' ./main.go + GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o ./main.wasm ./main.go ./envoy -c envoy.yaml --concurrency 0 --log-level info --component-log-level wasm:debug start: diff --git a/plugins/wasm-go/extensions/jwt-auth/Makefile b/plugins/wasm-go/extensions/jwt-auth/Makefile index e43f1b692..0187c2303 100644 --- a/plugins/wasm-go/extensions/jwt-auth/Makefile +++ b/plugins/wasm-go/extensions/jwt-auth/Makefile @@ -1,5 +1,5 @@ build: go mod tidy - tinygo build -o main.wasm -scheduler=none -target=wasi -gc=custom -tags="custommalloc nottinygc_finalizer" + GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o ./main.wasm . default: build \ No newline at end of file diff --git a/plugins/wasm-go/extensions/jwt-auth/option.yaml b/plugins/wasm-go/extensions/jwt-auth/option.yaml index 8be6bfd1c..d0e92713d 100644 --- a/plugins/wasm-go/extensions/jwt-auth/option.yaml +++ b/plugins/wasm-go/extensions/jwt-auth/option.yaml @@ -5,14 +5,13 @@ version: 1.0.0 build: # The official builder image version builder: - go: 1.19 - tinygo: 0.28.1 + go: 1.24.4 oras: 1.0.0 # The WASM plugin project directory input: ./ # The output of the build products output: - # Choose between 'files' and 'image' + # Choose between 'files' and 'image' type: files # Destination address: when type=files, specify the local directory path, e.g., './out' or # type=image, specify the remote docker repository, e.g., 'docker.io//' diff --git a/plugins/wasm-go/extensions/log-request-response/README.md b/plugins/wasm-go/extensions/log-request-response/README.md index c35677b1e..e2ff71ef7 100644 --- a/plugins/wasm-go/extensions/log-request-response/README.md +++ b/plugins/wasm-go/extensions/log-request-response/README.md @@ -68,7 +68,7 @@ response: go mod tidy # 编译 -tinygo build -o main.wasm -scheduler=none -target=wasi -gc=custom -tags="custommalloc nottinygc_finalizer" ./main.go +GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o ./main.wasm ./main.go ``` ## 访问日志配置 diff --git a/plugins/wasm-go/extensions/request-block/Makefile b/plugins/wasm-go/extensions/request-block/Makefile index 1210d6ec3..1f1d40043 100644 --- a/plugins/wasm-go/extensions/request-block/Makefile +++ b/plugins/wasm-go/extensions/request-block/Makefile @@ -1,4 +1,4 @@ .DEFAULT: build: - tinygo build -o main.wasm -scheduler=none -target=wasi -gc=custom -tags='custommalloc nottinygc_finalizer' ./main.go + GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o ./main.wasm . mv main.wasm ../../../../docker-compose-test/ \ No newline at end of file