1

I'm trying to install extensions with the k6 docker image via the go install command, but the pipeline is saying I don't have go. Does the base image not have golang available?

I'm interested in using the Kafka k6 extension, but not sure the best way to install it whilst using the base image provided by loadimpact.

Ryan
  • 1,102
  • 1
  • 15
  • 30

1 Answers1

0

If you meant base image as grafana/k6 it doesn't have Go in path (last FROM is alpine).

You can use multistaging, first build binary and copy it to more basic image.

FROM golang:1.18-alpine as builder

WORKDIR /app

ENV CGO_ENABLED 0
RUN go install go.k6.io/xk6/cmd/xk6@latest

# Your extension's github url, I used mine as example
RUN xk6 build \
    --with github.com/eugercek/xk6-imap

FROM alpine

COPY --from=builder /app/k6 /bin/
COPY ./script.js .

ENTRYPOINT [ "k6", "run", "/script.js" ]
Umut Gerçek
  • 630
  • 6
  • 9