webdevops / Dockerfile

:package: Dockerfiles from WebDevOps for PHP, Apache and Nginx
https://webdevops.io/projects/dockerfiles/
MIT License
1.67k stars 493 forks source link

How can I use alpine-php7 with Oracle at dockerfile? #303

Open ghost opened 5 years ago

ghost commented 5 years ago

I have a PHP application in AWS Elastic Beanstalk using Docker. In my dockerfile i use FROM webdevops / php-nginx: alpine-php7 however I need to add the Oracle extension to use oci_connect. How can I do this?

EnzephaloN commented 5 years ago

Hi @marcosrdesouza

Did you find out how this works? I'm trying same thing with apache. I tried it this way:

FROM webdevops/php-apache:7.2
ADD instantclient-basic-linux.x64-12.2.0.1.0.zip /tmp/
ADD instantclient-sdk-linux.x64-12.2.0.1.0.zip /tmp/
ADD instantclient-sqlplus-linux.x64-12.2.0.1.0.zip /tmp/
RUN unzip /tmp/instantclient-basic-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN unzip /tmp/instantclient-sdk-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN unzip /tmp/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN ln -s /usr/local/instantclient_12_2 /usr/local/instantclient
RUN ln -s /usr/local/instantclient/libclntsh.so.12.1 /usr/local/instantclient/libclntsh.so
RUN ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus
RUN echo 'export LD_LIBRARY_PATH="/usr/local/instantclient"' >> /root/.bashrc
RUN echo 'umask 002' >> /root/.bashrc
RUN echo 'instantclient,/usr/local/instantclient' | pecl install oci8
RUN echo "extension=oci8.so" > $(pecl config-get ext_dir)/oci8.ini
RUN php -i | grep oci8
EXPOSE 80 443 

But sadly the oci-extension isn't loaded because of

PHP Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/lib/php/exten sions/no-debug-non-zts-20170718/oci8.so (libmql1.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so.so (/usr/local/lib/php/ extensions/no-debug-non-zts-20170718/oci8.so.so: cannot open shared object file: No such file or dir ectory)) in Unknown on line 0

Any ideas on this?

best regards Johannes

EnzephaloN commented 5 years ago

Got it working with apache, maybe that helps you to find a solution for nginx:

Dockerfile:

FROM webdevops/php-apache:7.2

# we need libaio!
RUN apt-get update
RUN apt-get install -y libaio1 libaio-dev

ADD instantclient-basic-linux.x64-12.2.0.1.0.zip /tmp/
ADD instantclient-sdk-linux.x64-12.2.0.1.0.zip /tmp/
ADD instantclient-sqlplus-linux.x64-12.2.0.1.0.zip /tmp/
RUN unzip /tmp/instantclient-basic-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN unzip /tmp/instantclient-sdk-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN unzip /tmp/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN ln -s /usr/local/instantclient_12_2 /usr/local/instantclient
RUN ln -s /usr/local/instantclient/libclntsh.so.12.1 /usr/local/instantclient/libclntsh.so
RUN ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus

# set path in environment for additional libraries!
ENV LD_LIBRARY_PATH /usr/local/instantclient_12_2/

# install
RUN echo 'instantclient,/usr/local/instantclient' | pecl install oci8
RUN echo "extension=oci8" > $(pecl config-get ext_dir)/oci8.ini

# don't know if this is necessary
RUN docker-php-ext-enable oci8
RUN ldd /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so
RUN ldconfig

#restart apache
RUN service apache2 restart

#show if oci8 is present
RUN php -i | grep oci8

# export ports
EXPOSE 80 443 

Infos: https://stackoverflow.com/questions/47833041/unable-to-load-dynamic-library-oci8-so-php-7-2 and https://stackoverflow.com/questions/10619298/libaio-so-1-cannot-open-shared-object-file

htuscher commented 5 years ago

Is this solution sufficient? Can the ticket be closed @marcosrdesouza