Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

feat ref #223: fixes the error installing sqlsrv #224

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions docker-compose-services/sqlsrv/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ARG BASE_IMAGE
FROM $BASE_IMAGE
ARG odbc_version=2.3.7
robertoperuzzo marked this conversation as resolved.
Show resolved Hide resolved

ENV PATH="${PATH}:/opt/mssql-tools/bin"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests apt-utils curl gnupg2 ca-certificates
Expand All @@ -8,16 +7,25 @@ RUN curl -sSL -O https://packages.microsoft.com/keys/microsoft.asc
RUN apt-key add <microsoft.asc
RUN curl -sSL -o /etc/apt/sources.list.d/mssql-release.list https://packages.microsoft.com/config/debian/11/prod.list

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests build-essential dialog php-pear php-dev unixodbc-dev locales
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests \
build-essential \
dialog \
php-pear \
php$DDEV_PHP_VERSION-dev \
unixodbc=$odbc_version \
odbcinst=$odbc_version \
odbcinst1debian2=$odbc_version \
unixodbc-dev=$odbc_version \
locales

RUN ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive apt-get install -y msodbcsql18 mssql-tools

# Change the PHP version to what you want. It is currently set to version 8.0.
RUN pecl channel-update pecl.php.net
RUN pecl -d php_suffix=8.0 install sqlsrv
RUN pecl -d php_suffix=8.0 install pdo_sqlsrv
RUN pecl -d php_suffix=$DDEV_PHP_VERSION install sqlsrv
RUN pecl -d php_suffix=$DDEV_PHP_VERSION install pdo_sqlsrv

RUN echo 'extension=sqlsrv.so' >> "/etc/php/8.0/mods-available/sqlsrv.ini"
RUN echo 'extension=pdo_sqlsrv.so' >> "/etc/php/8.0/mods-available/pdo_sqlsrv.ini"
RUN echo 'extension=sqlsrv.so' >> /etc/php/$DDEV_PHP_VERSION/mods-available/sqlsrv.ini
RUN echo 'extension=pdo_sqlsrv.so' >> /etc/php/$DDEV_PHP_VERSION/mods-available/pdo_sqlsrv.ini

RUN phpenmod sqlsrv pdo_sqlsrv
RUN phpenmod -v $DDEV_PHP_VERSION sqlsrv pdo_sqlsrv