This is the Dockerfile to install OCI8 in FrankenPHP using the new official installer for PHP extensions PIE, which replaces PECL (deprecated now). The recipe can be easily adapted for any docker installation of PHP OCI8 using PIE:
# Start with the official FrankenPHP image
FROM dunglas/frankenphp:1-php8.5
# 1. Install system utilities and the AIO library required by Oracle
RUN apt-get update && apt-get install -y \
unzip \
libaio1t64 \
curl \
build-essential \
libtool \
&& rm -rf /var/lib/apt/lists/*
# Fix the Oracle Y2038 compatibility break by symlinking the new t64 library to the old name
RUN ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1
# 2. Set up the Oracle Instant Client
WORKDIR /opt/oracle
RUN curl -o instantclient-basic.zip https://download.oracle.com/otn_software/linux/instantclient/2112000/instantclient-basic-linux.x64-21.12.0.0.0dbru.zip \
&& curl -o instantclient-sdk.zip https://download.oracle.com/otn_software/linux/instantclient/2112000/instantclient-sdk-linux.x64-21.12.0.0.0dbru.zip \
&& unzip instantclient-basic.zip \
&& unzip instantclient-sdk.zip \
&& rm -f *.zip
# Set environment variables so PHP knows where Oracle lives
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient_21_12
ENV ORACLE_HOME=/opt/oracle/instantclient_21_12
# 3. Compile the custom OCI8 extension against the Instant Client via PIE
# Download the PIE executable from the PHP Foundation
RUN curl -fL --output /usr/local/bin/pie https://github.com/php/pie/releases/latest/download/pie.phar \
&& chmod +x /usr/local/bin/pie
# Install OCI8 via PIE by passing the configure flag directly
RUN pie install oci8/oci8 --with-oci8=instantclient,/opt/oracle/instantclient_21_12 \
&& docker-php-ext-enable oci8