这里的问题是 web 容器需要一个 oracle 客户端来与 db 容器中的 oracle 数据库通信。这需要做一些工作,因为 oracle 没有在 apt-get 上提供客户端,所以我从 Oracle 的站点下载了 RPM,将它们放入 vendor/ 并在 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/