microsoft/msphpsql

unable to install in ubuntu 22.04 container

dadamssg opened this issue · 1 comments

PHP version
8.3

PHP SQLSRV or PDO_SQLSRV version
5.12.0

Microsoft ODBC Driver version
18

Client operating system
ubuntu

Problem description
I'm unable to install the drivers.

Expected behavior and actual behavior
Actual behavior:

2.756 checking how to run the C++ preprocessor... /lib/cpp
2.763 configure: error: in `/tmp/pear/temp/pear-build-defaultuseryxEhPr/sqlsrv-5.12.0':
2.763 configure: error: C++ preprocessor "/lib/cpp" fails sanity check
2.763 See `config.log' for more details
2.774 ERROR: `/tmp/pear/temp/sqlsrv/configure --with-php-config=/usr/bin/php-config' failed

Repro code or steps to reproduce

Dockerfile:

FROM ubuntu:22.04 AS base

ENV DEBIAN_FRONTEND noninteractive

# Install dependencies
RUN apt-get update \
    && apt-get install -y software-properties-common \
    && LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php \
    && apt-get install -yq --no-install-recommends \
        sudo \
        curl \
        php8.3 \
        php8.3-dev \
        php8.3-fpm \
        php8.3-pdo \
        php8.3-xml \
        php8.3-zip \
        php8.3-curl \
        php8.3-gd \
        php8.3-imap \
        php8.3-mcrypt \
        php8.3-mbstring \
        php8.3-soap \
        php8.3-bcmath \
        php8.3-xdebug \
        php8.3-mongodb \
        php8.3-imagick \
        php8.3-redis \
        php-pear \
        nginx \
    && curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc \
    && curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list \
    && apt-get update \
    && sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev \
    && echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc \
    && apt-get autoremove --purge -y \
        software-properties-common \
    && apt-get -y clean \
    && rm -rf /var/lib/apt/lists/* /var/tmp/*

RUN pecl channel-update pecl.php.net \
    && pecl config-set php_ini /etc/php/8.3/fpm/php.ini \
    && pecl install sqlsrv \
    && pecl install pdo_sqlsrv \
    && pecl install xhprof \
    && printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.3/mods-available/sqlsrv.ini \
    && printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/8.3/mods-available/pdo_sqlsrv.ini \
    && phpenmod -v 8.3 sqlsrv pdo_sqlsrv

Build:

docker build --no-cache .

figure it out by adding build-essential g++.

RUN apt-get update \
    && apt-get install -y software-properties-common build-essential g++ \
    && LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php \
    && apt-get install -yq --no-install-recommends \
        sudo \
        curl \
        php8.3 \
        php8.3-dev \
        php8.3-fpm \
        php8.3-pdo \
        php8.3-xml \
        php8.3-zip \
        php8.3-curl \
        php8.3-gd \
        php8.3-imap \
        php8.3-mcrypt \
        php8.3-mbstring \
        php8.3-soap \
        php8.3-bcmath \
        php8.3-xdebug \
        php8.3-mongodb \
        php8.3-imagick \
        php8.3-redis \
        php-pear \
        nginx \
        supervisor \
        wkhtmltopdf \
        libreoffice \
        wget \
        vim \
    && curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc \
    && curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list \
    && apt-get update \
    && sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev \
    && echo 'export PATH="$PATH:/opt/mssql-tools18/bin:/usr/sbin"' >> ~/.bashrc \
    && apt-get autoremove --purge -y \
        software-properties-common \
    && apt-get -y clean \
    && rm -rf /var/lib/apt/lists/* /var/tmp/*

RUN pecl channel-update pecl.php.net \
    && pecl config-set php_ini /etc/php/8.3/fpm/php.ini \
    && pecl install sqlsrv \
    && pecl install pdo_sqlsrv \
    && pecl install xhprof \
    && printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.3/mods-available/sqlsrv.ini \
    && printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/8.3/mods-available/pdo_sqlsrv.ini \
    && phpenmod -v 8.3 sqlsrv pdo_sqlsrv