Wget / curl for OpenShift before installing dependencies

I am trying to do a clean install of an Oracle client on an OpenShift POD before installing the dependencies (in my case python requirements.txt), the Oracle installation must be present in order to install cx_Oracle.

How can I automate this process? Can I just add a line to one of the action_hooks?

Thank.

+3


source to share


1 answer


OpenShift 3 has no idea about action hooks like OpenShift 2.

To achieve what you want to do, you will need to do the following.

Create a directory .s2i/bin

in the application source repository.

In this directory, create a file named assemble

. Add to this file:

#!/bin/bash

set -eo pipefail

# Add steps here to install Oracle client libraries and header files.
# Install these in a new subdirectory under /opt/app-root. Lets assume
# you use /opt/app-root/oracle.

# ...

# Set and export whatever environment variables you need to set
# to have cx_Oracle when installed pickup header files and libraries
# from under /opt/app-root/oracle. So that Oracle shared libraries
# are found when the Python application is later run, this should
# include setting LD_RUN_PATH environment variable to compile the
# directory where the Oracle libraries are located into the module
# when it is built.

export LD_RUN_PATH=/opt/app-root/oracle/lib

# ...

# Run the original assemble script.

/usr/libexec/s2i/assemble

      

Make sure this assemble

script is executable.

chmod +x .s2i/bin/assemble

      

If it cx_Oracle

comes as Python binary wheels and doesn't need to be compiled, the LD_RUN_PATH

above trick does not work. In this case, also follow these steps.



In the directory .s2i/bin

enter run

script. Add to this file:

#!/bin/bash

set -eo pipefail

# Set LD_LIBRARY_PATH environment variable to directory containing
# the Oracle client libraries.

export LD_LIBRARY_PATH=/opt/app-root/oracle/lib

# Run the original run script, ensuring exec is used.

exec /usr/libexec/s2i/run

      

Make sure this script is executable.

chmod +x .s2i/bin/run

      

If you need to access a terminal module and run scripts that require Oracle, be aware that LD_LIBRARY_PATH

it will not be installed if you rely on this path, so no Oracle libraries will be found. In this case it is better to add the file .s2i/environment

and add there LD_LIBRARY_PATH

.

LD_LIBRARY_PATH=/opt/app-root/oracle/lib

      

By setting to .s2i/environment

, the environment variable will be set on the image and will always be set even when accessing the container using the terminal.

Keep in mind that the S2I build process runs as a non-root user and therefore you need to install something in a new subdirectory /opt/app-root

.

+5


source







All Articles