Output
DOCKER_BUILDKIT=1 docker build --build-arg PLUGIN_NAME=request-block \
-t request-block:20230223-173305-3b1a471 \
--output extensions/request-block .
[+] Building 67.7s (12/12) FINISHED
image: request-block:20230223-173305-3b1a471
output wasm file: extensions/request-block/plugin.wasm
This command eventually builds a wasm file and a Docker image.
This local wasm file is exported to the specified plugin's directory and can be used directly for debugging.
You can also use `make build-push` to build and push the image at the same time.
### Environmental parameters
| Name | Optional/Required | Default | 含义 |
|---------------|-------------------|--------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| `PLUGIN_NAME` | Optional | hello-world | The name of the plugin to build. |
| `REGISTRY` | Optional | empty | The regitstry address of the generated image, e.g. `example.registry.io/my-name/`. Note that the REGISTRY value should end with /. |
| `IMG` | Optional | If it is empty, it is generated based on the repository address, plugin name, build time, and git commit id. | The generated image tag will override the `REGISTRY` parameter if it is not empty. |
## Build on local yourself
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
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
```
### step2. build and push docker image
A simple Dockerfile:
```Dockerfile
FROM scratch
COPY main.wasm plugin.wasm
```
```bash
docker build -t