# 11.xk6构建扩展性插件

基于docker构建xk6 (opens new window)的扩展性插件.

This command line tool and associated Go package makes it easy to make custom builds of k6⁠. It is used heavily by k6 extension developers as well as anyone who wishes to make custom k6 binaries (with or without extensions).

# 1. docker命令构建

docker run --rm -it -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" grafana/xk6 build v0.43.1 \
  --with github.com/mostafa/xk6-kafka@v0.17.0 \
  --with github.com/grafana/xk6-output-influxdb@v0.3.0
This would create a k6 binary in the current working directory.

1
2
3
4
5

# 2. 进入容器构建

有时候下载github module很慢,可以通过进入容器等待下载完成再构建 docker run --rm -it -u "$(id -u)😒(id -g)" -v "${PWD}:/xk6" --entrypoint /bin/sh grafana/xk6

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
xk6 build v0.43.1 \
-with github.com/mostafa/xk6-kafka@v0.17.0 \
--with github.com/grafana/xk6-output-influxdb@v0.3.0
1
2
3
4
5
Last Updated: 11/25/2024, 3:57:41 PM
Apache License 2.0 | Copyright © 2022 by xueliang.wu 苏ICP备15016087号