I would to install a debian package (urcapctl_0.0.1_amd64.deb) in a docker image. During post installation of this debian package, it tries to run npm install command.
Here is how post installation script look like
#!/bin/sh
cd /usr/share/urcapx-generator/
npm install
Dockerfile
FROM urcap-dev:1.1.9
COPY target/urcapctl_0.0.1_amd64.deb /usr/local/src
RUN apt-get update && \
apt-get install -y /usr/local/src/urcapctl_0.0.1_amd64.deb && \
rm -rf /var/lib/apt/lists/*
After building the docker image using docker build --progress=plain --no-cache -t test .
Error logs
#9 1.550 /var/lib/dpkg/info/urcapctl.postinst: 16: npm: not found
But If I run manually the base docker image, I can see npm is installed.
docker run -it --user urcapdev --workdir=/home/urcapdev --entrypoint bash docker.urrd.dk/urcapx/urcap-dev:1.1.9
urcapdev ➜ ~/ws $ npm --version
8.3.1
urcapdev ➜ ~/ws $ which npm
/usr/local/share/nvm/versions/node/v16.14.0/bin/npm
I am guessing the issue is because npm is triggered as a root user during postinst script. Is there any work around for this ?
Running npm install in this way is considered a bad practice. But I have no other choice for now.
Thanks
You've seen that:
If you get errors such as:
Then, before installing that package, you need your Dockerfile to do: