I am facing a problem integrating the postman-to-k6 node library in my openshift cluster pod. When I configure it locally, it works perfectly but when I upload it to the pod from the docker imager created I have permission errors.
This is my Dockerfile:
WORKDIR /app
# Copy the entire project directory into the container
COPY . /app
# Copy the Postman collection file into the container
COPY ./test.json /app/collection/test.json
# Create the necessary directory
RUN mkdir -p /app/libs
# Install Postman
RUN npm install -D @apideck/postman-to-k6
# Add npm global bin directory to PATH
ENV PATH /app/node_modules/.bin:$PATH
# Run postman-to-k6 to generate ajv.js and then copy it to /app/libs
RUN postman-to-k6 --version && mv /app/node_modules/@apideck/postman-to-k6/vendor/ajv.js /app/libs/ajv.js
# Create a non-root user
RUN useradd -r -d / -u 1001 -g root nonroot
RUN chown -R nonroot /app
# Switch to the non-root user
USER nonroot
CMD ls -l /app/libs && ls -l /app/libs/ajv.js && postman-to-k6 /app/collection/test.json --mock
And the error is the following:
Error: EACCES: permission denied, unlink 'libs/ajv.js'
at Object.unlinkSync (node:fs:1876:11)
at Object.rimrafSync [as removeSync] (/app/node_modules/fs-extra/lib/remove/rimraf.js:254:15)
at /app/node_modules/fs-extra/lib/empty/index.js:39:12
at Array.forEach (<anonymous>)
at Object.emptyDirSync (/app/node_modules/fs-extra/lib/empty/index.js:37:9)
at Command.run (/app/node_modules/@apideck/postman-to-k6/bin/postman-to-k6.js:85:6) {
errno: -13,
code: 'EACCES',
syscall: 'unlink',
path: 'libs/ajv.js'
}
Why is trying to access libs/ajv.js and not using the /app path?
Thank you in advance.