I tried the same code mentioned in xk6-file. It seems to execute with no issues but no file gets created.
Following is my dockerfile:
# Build the k6 binary with the extension
FROM golang:1.18.1 as builder
RUN go install go.k6.io/xk6/cmd/xk6@latest
RUN xk6 build --output /k6 --with github.com/grafana/xk6-sql@latest --with github.com/avitalique/xk6-file@latest
# Use the operator's base image and override the k6 binary
FROM grafana/k6:latest
COPY --from=builder /k6 /usr/bin/k6
Please note that when I build xk6-file locally using below commands, it creates file. When I use above docker file, it is not creating file.
go install go.k6.io/xk6/cmd/xk6@latest
xk6 build v0.36.0 --with github.com/avitalique/xk6-file@latest