Xk6 oracle extension throws GoError: ORA-00000: DPI-1047: Cannot locate a 64-bit Oracle Client library: \"Error loading shared library libclntsh.so: No such file or directory\

Here is my docker file that I copied and modified versions from https://github.com/stefnedelchevbrady/xk6-sql-with-oracle/blob/main/Dockerfile:

Build the k6 binary with the extension

FROM golang:1.21-alpine as builder

WORKDIR $GOPATH/src/go.k6.io/k6

ADD . .

RUN apk --no-cache add build-base git

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

RUN CGO_ENABLED=1 xk6 build v0.46.0 --output /k6 --with github.com/stefnedelchevbrady/xk6-sql-with-oracle@latest --with github.com/avitalique/xk6-file@latest

Use the operator’s base image and override the k6 binary

FROM alpine:latest

RUN apk add --no-cache ca-certificates \

&& adduser -D -u 12345 -g 12345 k6

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

USER 12345

WORKDIR /app

COPY . .

ENTRYPOINT k6 run $SCRIPT

$SCRIPT is provided from .env file which will be accesible when I run docker run command passing .env file.

Inside $SCRIPT, I have sql related commands inside a function as follows: (username, password, host, dbName are variables I am passing to this function)
let connectionString = username+“/”+password+“@//”+host+“:1521/”+dbName;
const db = sql.open(‘oracle’, connectionString);
let query = “select * from sometable”
let results = sql.query(db, query)

Upon running the docker command, I get following error at sql.query line:
{“executor”:“shared-iterations”,“level”:“error”,“msg”:"GoError: ORA-00000: DPI-1047: Cannot locate a 64-bit Oracle Client library: "Error loading shared library libclntsh.so: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help\n\tat reflect.methodValueCall (native)\n\tat …

Did you install the Oracle Instant Client?

1 Like

Thanks for the reply. Yes, I had to make these changes to get it working finally. Install oracle client, build xk6 with latest version by explicitly mentioning the version numbers as xk6-oracle extension uses older version and also switch to debian instead of alpine

2 Likes