xk6 icon indicating copy to clipboard operation
xk6 copied to clipboard

Docker image does not support CGO_ENABLED on Mac

Open javaducky opened this issue 2 years ago • 2 comments

Some extensions depend on libraries written in C, requiring the CGO_ENABLED=1 environment setting. An example is xk6-sql to support using SQLite3 databases. The preference, of course, would be for extensions to utilize pure-Go libraries strictly, but this will not always be the case.

We need the xk6 builder image to allow for the CGO runtime.

javaducky avatar Apr 11 '23 12:04 javaducky

The golang image the grafana/xk6 image is based on already has gcc installed.

So to compile a binary that requires cgo, you only need to set CGO_ENABLED=1 in the container.

E.g. this works for xk6-sql:

docker run --rm -it -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" -e CGO_ENABLED=1 grafana/xk6 build \
  --with github.com/grafana/xk6-sql

imiric avatar Apr 11 '23 13:04 imiric

This may then be an issue on Mac.

image

javaducky avatar Apr 11 '23 15:04 javaducky