Xk6 browser in docker with organization certificate

Hi,

Managed to get it working. For anyone else that has this issue, make your dockerfile look like this so as to add the certificate to chromium cert storage:

FROM golang:1.19-bullseye as builder

RUN go install -trimpath go.k6.io/xk6/cmd/xk6@latest

RUN  xk6 build --output "/tmp/k6" --with github.com/grafana/xk6-browser@main 

FROM debian:bullseye

RUN apt-get update && \
    apt-get install -y chromium &&\
    apt install -y libnss3-tools curl &&\
    apt-get install -y ca-certificates

COPY ./certs/myroot.crt /usr/local/share/ca-certificates/myroot.crt
COPY ./certs/myroot.crt /usr/local/share/ca-certificates/myroot.pem
RUN chmod 644 /usr/local/share/ca-certificates/myroot.crt && \
    update-ca-certificates

RUN mkdir -p $HOME/.pki/nssdb
RUN certutil -d $HOME/.pki/nssdb -N --empty-password
RUN certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n myroot -i /usr/local/share/ca-certificates/myroot.pem

COPY --from=builder /tmp/k6 /usr/bin/k6

ENV XK6_HEADLESS=true

ENTRYPOINT ["k6"]

Many thanks for the amazing tool your guys are working on here!

1 Like