cx-oraclecloud-foundryinstantclientpush-api

Deploy instant oracle on Pivotal CloudFoundry for cx_Oracle


so im trying to push a python api with cx_oracle dependency which also need oracle instant client,but i couldnt found an tutorial to deploy instant client on pcf,is anybody ever do this before or have any example what should be done? appreciate it

Update:

This is the inside of my .profile

LD_LIBRARY_PATH=/home/vcap/app/oracle/instantclient:${LD_LIBRARY_PATH:-}
export OCI_LIB_DIR=/home/vcap/app/oracle/instantclient
export OCI_INC_DIR=/home/vcap/app/oracle/instantclient/sdk/include
export PYTHONPATH=/home/vcap/app/vendor:$PYTHONPATH
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib

Solution

    1. Use the zip installer of the Oracle Instant Client and not a package manager.
    2. Extract the files to a subfolder under your application, like oracle/.
    3. Install cx-Oracle like normal with pip.
    4. Generate requirements.txt.
    5. Add a file with the exact name of .profile to the root of your application, in it put export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/vcap/app/oracle/lib (where /home/vcap/app is the path to your application files and oracle/lib is the path to the lib directory beneath the folder where you extracted files in step #2).
    6. Then push your app.

    The .profile file will run before your actual application starts and it will adjust the library search path so that the Oracle client libraries can be found.

    If you get the error:

    cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "/home/vcap/app/oracle/instantclient/libclntsh.so: file too short"

    Double check your .profile script and make sure that you have the correct LD_LIBRARY_PATH setting.