Reputation: 63
I'currently developing a web app with docker containers. I'm using a node:7 base image and installed ghostscript with it's dependencies. My project also contains a package.json with all the node packages. I need to use ghostscript4js which relies on ghostscript and node-gyp, which are both installed. During the npm installation I'm getting a g++ error:
> [email protected] install /usr/src/app/node_modules/ghostscript4js
> node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp http GET https://nodejs.org/download/release/v7.10.1/node-v7.10.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v7.10.1/node-v7.10.1-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v7.10.1/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v7.10.1/SHASUMS256.txt
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/usr/src/app/node_modules/ghostscript4js/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/root/.node-gyp/7.10.1/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/root/.node-gyp/7.10.1',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=node.lib',
gyp info spawn args '-Dmodule_root_dir=/usr/src/app/node_modules/ghostscript4js',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/usr/src/app/node_modules/ghostscript4js/build'
CXX(target) Release/obj.target/ghostscript4js/src/ghostscript4js.o
SOLINK_MODULE(target) Release/obj.target/ghostscript4js.node
g++: error: /usr/lib/x86_64-linux-gnu/libgs.so: No such file or directory
ghostscript4js.target.mk:121: recipe for target 'Release/obj.target/ghostscript4js.node' failed
make: Leaving directory '/usr/src/app/node_modules/ghostscript4js/build'
make: *** [Release/obj.target/ghostscript4js.node] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:194:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.9.49-moby
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/src/app/node_modules/ghostscript4js
gyp ERR! node -v v7.10.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
npm info lifecycle [email protected]~install: Failed to exec install script
I'm not sure how to ensure that there is a libgs.so and where it is. It should be installed by ghostscript just installs fine. I'm relatively new to docker and especially in using a node image as a base.
Here is the dockerfile with the commands I'm using:
FROM node:7
ENV APP_DIR="/usr/src/app"
COPY ./ ${APP_DIR}
# Step 1: Install App
# -------------------
WORKDIR ${APP_DIR}
# Step 2: Install Python, GhostScript and npm packages
# -------------------
ARG CACHE_DATE=2017-01-01
RUN \
apt-get update && \
apt-get install -y build-essential make gcc g++ python python-dev python-pip python-virtualenv
RUN apt-get update && apt-get -y install ghostscript && apt-get clean
RUN apt-get install -y libgs-dev
RUN GS4JS_HOME="/usr/lib" && export GS4JS_HOME
RUN npm install
# Step 3: Start App
# -----------------
CMD ["npm", "run", "start"]
Upvotes: 1
Views: 1368
Reputation: 63
I was pointed in the right direction. It seems that the image that not take the environment-variable with RUN GS4JS_HOME="/usr/lib" && export GS4JS_HOME
I changed the dockerfile and used ENV GS4JS_HOME="/usr/lib"
instead. Now it is working.
Upvotes: 1