I'm playing around with Docker Compose to make a container running a Rails App with a Oracle backend.
Dockerfile and docker-compose.yml
This works great until my Docker container tries to install the ruby-oci8 gem, which looks for some oracle specific environment variables.
These variables are exposed in the oracle container's Dockerfile:
RUN 'export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe'
The question is, how do I expose this environment variable on the oracle container to the web container?
The problem here is that the web container needs an oracle client to talk to the oracle database in the db container. This took a bit of doing, since oracle does not provide a client on apt-get, so I downloaded the RPMs from Oracle's site, put them in vendor/ and did the following in the dockerfile:
FROM ruby:2.2.2
RUN apt-get update && apt-get install -y build-essential
RUN apt-get install -y libxml2-dev libxslt1-dev
RUN apt-get install -y libqt4-webkit libqt4-dev xvfb
RUN apt-get install -y nodejs
# Needed for Oracle Client
RUN apt-get install -y libaio1 libaio-dev
# Required for Oracle RPMs
RUN apt-get install -y alien
# Set up app at /code
ENV APP_HOME /code
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ADD vendor/*.rpm $APP_HOME/vendor/
# Oracle Client Environment Variables
ENV ORACLE_HOME /usr/lib/oracle/12.1/client64
ENV LD_LIBRARY_PATH $ORACLE_HOME/lib/:$LD_LIBRARY_PATH
ENV NLS_LANG American_America.UTF8
ENV PATH $ORACLE_HOME/bin:$PATH
# Set this so you don't have to type it in with rake db:create
ENV ORACLE_SYSTEM_PASSWORD myoraclecontainerspassword
# Install Oracle Client
RUN alien -i vendor/oracle-instantclient.rpm && alien -i vendor/oracle-sdk.rpm && alien -i vendor/oracle-sqlplus.rpm
ADD Gemfile* $APP_HOME/
RUN bundle install
ADD . $APP_HOME/