Skip to content
Snippets Groups Projects
Commit 3314a017 authored by Carsten Karbach's avatar Carsten Karbach
Browse files

Add setup for oracle instant client

parent f692a25c
No related branches found
No related tags found
No related merge requests found
FROM ubuntu:16.04
MAINTAINER Carsten Karbach (c.karbach@fz-juelich.de)
ARG oic=rpms/oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
ARG osdk=rpms/oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
ARG osqlplus=rpms/oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm
# install dependencies, certificates, apache
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
......@@ -28,6 +32,67 @@ RUN apt-get update && \
# Install composer
RUN cd /tmp && curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
#Oracle Envs
RUN echo "# Oracle Instant Client" >> /etc/environment && \
echo "LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64" >> /etc/environment && \
echo "TNS_ADMIN=/usr/lib/oracle/12.2/client64" >> /etc/environment && \
echo "ORACLE_BASE=/usr/lib/oracle/12.2/client64" >> /etc/environment && \
echo "ORACLE_HOME=/usr/lib/oracle/12.2/client64" >> /etc/environment && \
echo "NLS_LANG=GERMAN_GERMANY.WE8MSWIN1252" >> /etc/environment && \
echo 'NLS_NUMERIC_CHARACTERS=". "' >> /etc/environment
#Make variables also available to www-data user in apache
RUN echo 'export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64' >> /etc/apache2/envvars && \
echo 'export TNS_ADMIN=/usr/lib/oracle/12.2/client64' >> /etc/apache2/envvars && \
echo 'export ORACLE_BASE=/usr/lib/oracle/12.2/client64' >> /etc/apache2/envvars && \
echo 'export ORACLE_HOME=/usr/lib/oracle/12.2/client64' >> /etc/apache2/envvars && \
echo 'export NLS_LANG=GERMAN_GERMANY.WE8MSWIN1252' >> /etc/apache2/envvars && \
echo 'export NLS_NUMERIC_CHARACTERS=". "' >> /etc/apache2/envvars
#PHP PDO OCI Stuff... really annoying!
RUN mkdir /tmp/rpms
ADD $oic $osdk $osqlplus /tmp/rpms/
ENV ORACLE_HOME /usr/lib/oracle/12.2/client64
#change workdir to tmp
WORKDIR /tmp
#install oracle instant client and compile php oci and pdo extensions.
ADD utils/build_oracle_pdo_oci.sh /tmp/
RUN apt-get update && apt-get install -y --no-install-recommends \
alien \
build-essential \
gcc \
libxml2-dev \
make \
php-pear \
php7.0-dev \
wget \
&& \
alien -i /tmp/$oic && \
alien -i /tmp/$osdk && \
alien -i /tmp/$osqlplus && \
echo "/usr/lib/oracle/12.2/client64/lib" > /etc/ld.so.conf.d/oracle.conf && ldconfig && \
./build_oracle_pdo_oci.sh && \
apt-get -y purge \
alien \
build-essential \
gcc \
libxml2-dev \
make \
php7.0-dev \
wget \
&& \
apt-get -y autoremove && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends libaio1 && \
apt-get -y autoremove && \
rm -rf /var/lib/apt/lists/*
WORKDIR /root
# Setup for EventsAPI application
RUN rm /var/www/html/index.html
# Add EventsApi source
......
......@@ -12,6 +12,8 @@ if test -e "$APACHE_SSL_CERT_KEY";then
cp $APACHE_SSL_CERT_KEY ./servercerts/ssl-cert-eventsapi.key
fi
cp ~/workspace/dockerenv/*.rpm rpms
docker build -t karbach/restapi:v1 .
#Clear automatically created folders
......
......@@ -11,3 +11,14 @@ docker run -d -p 8081:80 -p 4433:443 -v /path/to/folder/on/host:/var/www/html/Ev
- add the files ./configs/certificates/ssl-cert-eventsapi.pem and ./configs/certificates/ssl-cert-eventsapi.key as certificate and key file
- go into EventsAPI root folder and run ./build_docker.sh
- launch the container with ./launch_docker.sh
# Build with Oracle Instant client
- Download Oracle Instant client RPMs from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
- oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
- oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
- oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm
- Place files into rpms folder
- Use Dockerfile to install and compile PHP with oracle instant client
- Configure DB credentials in configs/dbaccess.cnf
- Test DB access with examples/dbaccesstest.php
#install and configure OCI8
DIR=$(mktemp -d)
cd $DIR
pecl channel-update pecl.php.net && \
pecl download OCI8-2.1.4 && \
tar zxvf oci8-2.1.4.tgz || exit 1
cd oci8-2.1.4 || exit 1
phpize && \
./configure --with-oci8=instantclient,/usr/lib/oracle/12.2/client64/lib && \
make install || exit 1
#register OCI with PHP
echo "extension=oci8.so" > /etc/php/7.0/mods-available/oci8.ini && \
ln -s /etc/php/7.0/mods-available/oci8.ini /etc/php/7.0/apache2/conf.d/oci8.ini && \
ln -s /etc/php/7.0/mods-available/oci8.ini /etc/php/7.0/cli/conf.d/oci8.ini || exit 1
#recompile PHP PDO OCI
wget https://github.com/php/php-src/archive/PHP-7.0.22.zip && \
unzip PHP-7.0.22.zip || exit 1
cd php-src-PHP-7.0.22/ext/pdo_oci/ || exit 1
sed -i s/11.1\ 12.1/11.2\ 12.1\ 12.2/ config.m4 && \
sed -i s/11.2\|12.1/11.2\|12.1\|12.2/ config.m4 && \
phpize && \
./configure --with-pdo-oci=instantclient,/usr,12.2 && \
make install && \
make clean && \
echo "extension=pdo_oci.so" > /etc/php/7.0/mods-available/pdo_oci.ini && \
ln -s /etc/php/7.0/mods-available/pdo_oci.ini /etc/php/7.0/apache2/conf.d/pdo_oci.ini && \
ln -s /etc/php/7.0/mods-available/pdo_oci.ini /etc/php/7.0/cli/conf.d/pdo_oci.ini || exit 1
cd /
rm -rf $DIR
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment