Search code examples
phpdockerpecloracle-cloud-infrastructure

Error pecl install oci8-2.2.0 - Try to build container on apple with chip silicon (M2)


I pass the day on this problem, the docker file work perfectly on windows. When I launch docker-compose up I have this error :

`=> ERROR [web 11/54] RUN echo 'instantclient,/usr/lib/oracle/21.1/client64/lib' | pecl install oci8-2.2.0 7.0s

[web 11/54] RUN echo 'instantclient,/usr/lib/oracle/21.1/client64/lib' | pecl install oci8-2.2.0:
#0 0.201
#0 0.201 Notice: Trying to access array offset on value of type bool in PEAR/REST.php on line 187
#0 0.201 PHP Notice: Trying to access array offset on value of type bool in /usr/share/php/PEAR/REST.php on line 187 #0 0.201 PHP Stack trace: #0 0.201 PHP 1. {main}() /usr/share/php/peclcmd.php:0 #0 0.201 PHP 2. require_once() /usr/share/php/peclcmd.php:31 #0 0.201 PHP 3. PEAR_Command_Install->run() /usr/share/php/pearcmd.php:316 #0 0.201 PHP 4. PEAR_Command_Install->doInstall() /usr/share/php/PEAR/Command/Common.php:270 #0 0.201 PHP 5. PEAR_Downloader->download() /usr/share/php/PEAR/Command/Install.php:666 #0 0.201 PHP 6. PEAR_Downloader_Package->initialize() /usr/share/php/PEAR/Downloader.php:296 #0 0.201 PHP 7. PEAR_Downloader_Package->_fromString() /usr/share/php/PEAR/Downloader/Package.php:189 #0 0.201 PHP 8. PEAR_Downloader->_getPackageDownloadUrl() /usr/share/php/PEAR/Downloader/Package.php:1706 #0 0.201 PHP 9. PEAR_REST_10->getDownloadURL() /usr/share/php/PEAR/Downloader.php:870 #0 0.201 PHP 10. PEAR_REST->retrieveData() /usr/share/php/PEAR/REST/10.php:74 #0 0.201 PHP 11. PEAR_REST->useLocalCache() /usr/share/php/PEAR/REST.php:80`

`End of the error :
#0 6.963 /usr/bin/ld: skipping incompatible /usr/lib/oracle/21.1/client64/lib/libclntsh.so when searching for -lclntsh

#0 6.963 /usr/bin/ld: cannot find -lclntsh

#0 6.963 collect2: error: ld returned 1 exit status

#0 6.964 make: *** [Makefile:209: oci8.la] Error 1

#0 6.969 ERROR: `make' failed

------

failed to solve: process "/bin/sh -c echo 'instantclient,/usr/lib/oracle/21.1/client64/lib' | pecl install oci8-2.2.0" did not complete successfully: exit code: 1
There a part of my Dockerfile `

RUN apt-get update && apt-get upgrade -y && \
  apt-get install -y \
  curl \
  git \
  nano \
  apache2 \
  php \
  php-cli php-curl php-gd php-iconv php-imap php-mbstring php-pgsql php-xsl php-zip php-xdebug php-imagick\
  php-dev php-pear build-essential libaio1 php-mailparse php-bcmath\
  libapache2-mod-php \
  postgresql-client \
  unzip \
  zip \
  xsltproc \
  libxml2-utils\
  libmcrypt-dev\
  unixodbc-dev

# Oracle instantclient
ADD docker/conf/oracle/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip /tmp/
ADD docker/conf/oracle/instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip /tmp/
RUN mkdir -p /usr/lib/oracle/21.1/client64
RUN unzip -qq /tmp/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip -d /usr/lib/oracle/21.1/client64
RUN unzip -qq /tmp/instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip -d /usr/lib/oracle/21.1/client64
RUN mv /usr/lib/oracle/21.1/client64/instantclient_21_4 /usr/lib/oracle/21.1/client64/lib
RUN echo /usr/lib/oracle/21.1/client64/lib > /etc/ld.so.conf.d/oracle.conf
RUN pecl channel-update pecl.php.net
RUN echo 'instantclient,/usr/lib/oracle/21.1/client64/lib' | pecl install oci8-2.2.0
RUN echo "extension = oci8.so" >> /etc/php/7.4/cli/php.ini
RUN echo "extension = oci8.so" >> /etc/php/7.4/apache2/php.ini
RUN echo "LD_LIBRARY_PATH=\"/usr/lib/oracle/21.1/client64/lib\"" >> /etc/environment
RUN echo "ORACLE_HOME=\"/usr/lib/oracle/21.1/client64/lib\"" >> /etc/environment
RUN echo "ServerTokens Prod" >> /etc/apache2/apache2.conf
RUN echo "ServerSignature Off" >> /etc/apache2/apache2.conf
RUN echo "export LD_LIBRARY_PATH=\"/usr/lib/oracle/21.1/client64/lib\"" >> /etc/apache2/envvars
RUN echo "export ORACLE_HOME=\"/usr/lib/oracle/21.1/client64/lib\"" >> /etc/apache2/envvars
RUN ldconfig
ADD docker/conf/oracle/php-7.4.3.tar.gz /tmp/
RUN cp -r /tmp/php-7.4.3/ext/pdo_oci /tmp
RUN cd /tmp/pdo_oci && \
    phpize && \
    ./configure --with-pdo-oci=instantclient,/usr/lib/oracle/21.1/client64/lib && \
    make install
  • I tried to delete all, and reinstall.
  • Check the box on desktop docker to use rosetta.
  • Launch this cmd : softwareupdate --install-rosetta
  • Delete all and retry with Colima

I got all time the same issue.


Solution

  • Solved, I'm not sure how my colleague solved the problem, but the image was built on the server, and I pulled the image with docker-compose pull.

    So no more problems with the build because it was prebuilt