Oracle (oci8) Extension Problem With AMD64 Libraries #286
Replies: 3 comments
-
Have you tried using our new beta images and installing with the new extension method? https://serversideup.net/open-source/docker-php/docs/guide/installing-additional-php-extensions |
Beta Was this translation helpful? Give feedback.
-
Thanks Jay! That's definitely the way i found worked with Alpine. For those who might encounter this in future, here are the two ways to do it without the ability to switch image, with the long way around: Notes:
Method 1: Native PHP images (Alpine)FROM php:8.2-cli-alpine3.19
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
# Add PEAR in, just in case
COPY php/go-pear.phar .
RUN php go-pear.phar && pecl channel-update pear.php.net
RUN install-php-extensions ldap oci8 pdo_oci @composer Method 2: Pain
This always ends with this problem, one way or another:
FROM serversideup/php:8.2-fpm-nginx
# Developed from https://gist.github.com/milo/d4a15d67e6538bf82438babc39482b80
# Config vars here: https://serversideup.net/open-source/docker-php/docs/reference/environment-variable-specification
# The files have to be unzipped here because they contain symlinks within the zip file the compiler expects to be there.
# This image is the base AMD/ARM64 PHP8.2 FPM container (175MB), but with the Oracle PHP extension (oci8 3.3.0) installed into it. Which increases its size by 300%, not including php-dev deps.
# Note: this image is based on 64-bit Debian Alpine (amd64), so it is NOT an Ubuntu or x86 64-bit package like Laravel Sail. It needs the 19.22 AMD client libraries from Oracle (not 21)
# Place to store the Oracle files
RUN mkdir /opt/oracle;
COPY docker/production/go-pear.phar .
RUN php go-pear.phar && pecl channel-update pear.php.net
# Get the zips and ext src from the repo rather than download
COPY docker/production/instantclient-sdk-linux-arm64.zip /opt/oracle/instantclient-sdk-linux-arm64.zip
COPY docker/production/instantclient-basic-linux-arm64.zip /opt/oracle/instantclient-basic-linux-arm64.zip
COPY docker/production/oci8-3.3.0 /opt/oracle/oci8
# Install basics
RUN apt-get update && \
apt-get install -y build-essential gcc make autoconf libtool pkg-config re2c bison libc6-dev gobjc++
# Install PHP development files
RUN apt-get install -y php-dev
# Debug: Print system architecture
RUN echo "System Architecture: $(uname -m)"
# unzips to instantclient_19_22, and causes huge problems with overwriting
RUN unzip -L -o /opt/oracle/instantclient-basic-linux-arm64.zip -d /opt/oracle/basic
RUN unzip -L -o /opt/oracle/instantclient-sdk-linux-arm64.zip -d /opt/oracle/sdk
# Merge the folders
RUN mv /opt/oracle/basic/instantclient_19_22 /opt/oracle/instantclient
RUN mv /opt/oracle/sdk/instantclient_19_22/sdk /opt/oracle/instantclient/sdk
RUN echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf
RUN ldconfig
# Create symbolic links for Oracle Instant Client libraries if they don't exist
RUN if [ ! -e /opt/oracle/instantclient/libclntsh.so ]; then \
ln -s /opt/oracle/instantclient/libclntsh.so.19.1 /opt/oracle/instantclient/libclntsh.so; \
fi
RUN if [ ! -e /opt/oracle/instantclient/libocci.so ]; then \
ln -s /opt/oracle/instantclient/libocci.so.19.1 /opt/oracle/instantclient/libocci.so; \
fi
# Set LD_LIBRARY_PATH
# Set the Instant Client path
ENV INSTANT_CLIENT_PATH=/opt/oracle/instantclient
ENV LD_LIBRARY_PATH=$INSTANT_CLIENT_PATH:$LD_LIBRARY_PATH
ENV ORACLE_HOME=/opt/oracle/instantclient
# Clean up
RUN rm /opt/oracle/*.zip && rm -rf /opt/oracle/basic && rm -rf /opt/oracle/sdk
WORKDIR /opt/oracle/oci8
RUN phpize && \
./configure --with-oci8=instantclient,$INSTANT_CLIENT_PATH \
--with-pic CFLAGS=-fPIC && \
make && \
make install || (cat config.log && false) |
Beta Was this translation helpful? Give feedback.
-
Also - this is directly from the docs on the site: FROM serversideup/php:8.2.12-fpm-nginx-bookworm
RUN install-php-extensions ldap oci8 pdo_oci @composer Result:
Fix with: FROM serversideup/php:beta-8.2-fpm-nginx-bookworm |
Beta Was this translation helpful? Give feedback.
-
So this isn't a straightforward support request as i realise it's a bit off-topic, but i'm hoping it might save someone else the trouble. I've used these production images a few times and they're great. The most esoteric i've had to get was installing the MongoDB extension, but it was simple. At work we rely on Oracle, and there's no getting out of it. Installing the PHP extension's been tricky, but generally possible - in so small part to the guidance here: https://gist.github.com/milo/d4a15d67e6538bf82438babc39482b80 .
The process is:
Oracle does some weird things with the naming and versioning of the object files in their release, which means you have to unzip all the symlinks in their place. For AMD, that means v19.22 of the client, compared to v21 for other distros.
Here's the extended Dockerfile:
Which works fine, until you get to the
make
command on either the PECL or from source on any of these images:Beta Was this translation helpful? Give feedback.
All reactions