grafana / xk6

Build k6 with extensions
Apache License 2.0
215 stars 20 forks source link

Docker image does not support CGO_ENABLED on Mac #65

Open javaducky opened 1 year ago

javaducky commented 1 year ago

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.

imiric commented 1 year ago

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
javaducky commented 1 year ago

This may then be an issue on Mac.

image