strongloop / strong-oracle

Deprecated: Node.js Driver for Oracle databases (Use https://github.com/oracle/node-oracledb instead)
Other
45 stars 18 forks source link

DockerFile for strong-oracle ready container, npm install strong-oracle fails #32

Closed CollinEstes closed 9 years ago

CollinEstes commented 9 years ago

So I'm trying to create a dockerfile for my strong-oracle app to run within,all the instant client libraries are added and the environment variables are set correctly (from what I can tell).

Looking for some help getting over this last hump with it, here is my DockerFile:

# INSTALL UBUNTU
FROM ubuntu:14.04

#UPDATE APT-GET
RUN apt-get update && apt-get install -y curl
RUN apt-get install libaio1

#INSTALL IO.JS
RUN curl -fsSL bit.ly/iojs-dev -o /tmp/iojs-dev.sh; bash /tmp/iojs-dev.sh

#INSTALL ORACLE INSTANT CLIENT (I have the instant client libraries in my project file)
RUN mkdir -p opt/instantclient
ADD ./instantclient /opt/instantclient

#SETUP THE APP (I have a simple app with strong-oracle as a dependencies)
RUN mkdir -p /app
ADD ./ /app

#SETUP ORACLE ENV VARIABLES
ADD ./oracle_env_vars.sh run.sh
RUN chmod +x run.sh
CMD ./run.sh

and my oracle_env_vars

export OCI_HOME=/opt/instantclient
export OCI_LIB_DIR=$OCI_HOME
export OCI_INCLUDE_DIR=$OCI_HOME/sdk/include
export OCI_VERSION=12
export DYLD_LIBRARY_PATH=$OCI_LIB_DIR

ln -s $OCI_LIB_DIR/libclntsh.so.12.1 libclntsh.so
ln -s $OCI_LIB_DIR/libocci.so.12.1 libocci.so

echo '/opt/instantclient/' |  tee -a /etc/ld.so.conf.d/oracle_instant_client.conf
ldconfig

cd ./app && npm install

So it gets through everything all the way to the npm install without failing and I've done some checks echoing my environment variables to prove they are created and everything looks good.

Strong-oracle fails with:

make: Entering directory `/app/node_modules/strong-oracle/build'
  CXX(target) Release/obj.target/oracle_bindings/src/connection.o
In file included from ../src/connection.cpp:2:0:
../src/connection.h:10:18: fatal error: occi.h: No such file or directory
 #include <occi.h>
                  ^
compilation terminated.
make: *** [Release/obj.target/oracle_bindings/src/connection.o] Error 1
make: Leaving directory `/app/node_modules/strong-oracle/build'
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:269:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1009:12)
gyp ERR! System Linux 4.0.2-boot2docker
gyp ERR! command "/usr/local/bin/iojs" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /app/node_modules/strong-oracle
gyp ERR! node -v v2.0.2
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
npm ERR! Linux 4.0.2-boot2docker
npm ERR! argv "/usr/local/bin/iojs" "/usr/local/bin/npm" "install"
npm ERR! node v2.0.2
npm ERR! npm  v2.9.0
npm ERR! code ELIFECYCLE

npm ERR! strong-oracle@1.6.4 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the strong-oracle@1.6.4 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the strong-oracle package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls strong-oracle
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /app/npm-debug.log
bnoordhuis commented 9 years ago

Does $OCI_HOME/sdk/include contain occi.h?

CollinEstes commented 9 years ago

So I thought it did but looks like it doesn't find it, most likely the OCI_HOME isn't getting set correctly I guess.

I add this to my shell file to test for it

[ -f $OCI_HOME/sdk/include/occi.h ] && echo "Found" || echo "Not found"

But I got a Not found. I must not be setting up the env. variables right, but I'm not sure what is going wrong.

cjbj commented 9 years ago

Once you resolve the env var issue, make sure you are running the 'ln -s' commands in the right directory. DYLD_LIBRARY_PATH is an OS X variable, so you can remove that line - and since you run ldconfig you don't need to set LD_LIBRARY_PATH.

CollinEstes commented 9 years ago

Thanks everyone I got it working. For others who may want to do the same here is my dockerfile and corresponding shell script which sets the env variables to use strong-oracle. The issue I was having was that I was not copying my instant clients libraries correctly (had an extra folder level in there) so I was pointing my ENV variables to the wrong place.

This configuration assumes you have put the Oracle instant client Basic libraries at the root of your project in a folder named 'instantclient'. In that folder it assumes you have included the sdk '/sdk/include' folder as well. It also requires the shell script be in the application folder as well named 'oracle_env_vars.sh'. So the structure is:

  - app        - package.json        - ...(node app)        - oracle_env_vars.sh        - instantclient/               - ... (instantclient binaries)               - sdk                      - include                            - ...(sdk c code)

DOCKERFILE

# INSTALL UBUNTU
FROM ubuntu:14.04

#UPDATE APT-GET AND INSTALL CURL
RUN apt-get update && apt-get install -y curl

#INSTALL IO.JS
RUN curl -fsSL bit.ly/iojs-dev -o /tmp/iojs-dev.sh; bash /tmp/iojs-dev.sh

#INSTALL libaio1 (NEEDED FOR STRONG-ORACLE)
RUN apt-get install libaio1

#INSTALL ORACLE INSTANT CLIENT
RUN mkdir -p opt/instantclient
ADD ./instantclient /opt/instantclient

#CREATE APP FOLDER AND COPY IN APP
RUN mkdir -p /app
ADD ./ /app

#SETUP ORACLE ENV VARIABLES AND START APP IN SHELL SCRIPT
ADD ./oracle_env_vars.sh run.sh
RUN chmod +x run.sh
CMD ./run.sh

Then the oracle_env_vars.sh

#SETUP STRONG-ORACLE ENVIRONMENT VARIABLES
export OCI_HOME=/opt/instantclient
export OCI_LIB_DIR=$OCI_HOME
export OCI_INCLUDE_DIR=$OCI_HOME/sdk/include
export OCI_VERSION=12

#SETUP STRONG-ORACLE SYMLINKS
cd $OCI_LIB_DIR
ln -s $OCI_LIB_DIR/libclntsh.so.12.1 libclntsh.so
ln -s $OCI_LIB_DIR/libocci.so.12.1 libocci.so

# ADD SHARED OBJECT FILES TO LD CACHE FOR STRONG-ORACLE
echo '/opt/instantclient/' | tee -a /etc/ld.so.conf.d/oracle_instant_client.conf
ldconfig

# PERFORM APP's NPM INSTALL
cd ../../app && npm install

# START APP (ENTER START CMDs - ex "node app")

Pretty new to docker and opts in general so I'm sure there is some improvements in these as well, but it is working. I'm not starting the app in this example so if you intend on using this you will have to add that step to the shell script.