moodlehq / moodle-php-apache

PHP + Apache docker images for Moodle development
61 stars 68 forks source link

Try to build the php-sqlsrv extension for the linux/arm64 platform #159

Closed stronk7 closed 1 year ago

stronk7 commented 1 year ago

It seems that, since June 2022 (version 5.10), there is support for arm64 in the php sqlsrv drivers/extension.

https://learn.microsoft.com/en-us/sql/connect/php/release-notes-php-sql-driver?view=sql-server-ver16

Let's give to it a try and check if now we can build it for our arm64 images.

scara commented 1 year ago

Hi @stronk7, do you mean something like below for 8.1 (7.4? 8.0?) up to 8.2? I can create the related PRs.

diff --git a/root/tmp/setup/php-extensions.sh b/root/tmp/setup/php-extensions.sh
index cf56e5d..e61d194 100755
--- a/root/tmp/setup/php-extensions.sh
+++ b/root/tmp/setup/php-extensions.sh
@@ -77,11 +77,14 @@ echo "pcov.initial.files=1024" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.
 # Install Microsoft dependencies for sqlsrv.
 # (kept apart for clarity, still need to be run here
 # before some build packages are deleted)
-if [[ ${TARGETPLATFORM} == "linux/amd64" ]]; then
-    /tmp/setup/sqlsrv-extension.sh
-else
-    echo "sqlsrv extension not available for ${TARGETPLATFORM} architecture, skipping"
-fi
+case $TARGETPLATFORM in
+    linux/amd64|linux/arm64)
+        /tmp/setup/sqlsrv-extension.sh
+        ;;
+    *)
+        echo "sqlsrv extension not available for ${TARGETPLATFORM} architecture, skipping"
+        ;;
+esac

 # Keep our image size down..
 pecl clear-cache
diff --git a/root/tmp/setup/sqlsrv-extension.sh b/root/tmp/setup/sqlsrv-extension.sh
index 4911851..b834cf1 100755
--- a/root/tmp/setup/sqlsrv-extension.sh
+++ b/root/tmp/setup/sqlsrv-extension.sh
@@ -5,14 +5,13 @@ set -e
 # Install Microsoft dependencies for sqlsrv
 echo "Downloading sqlsrv files"
 curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
-# TODO, bullseye should be 11, but the msodbcsql17 package is not available yet, hence using buster (10) one.
-curl https://packages.microsoft.com/config/debian/10/prod.list -o /etc/apt/sources.list.d/mssql-release.list
-apt-get update
+curl https://packages.microsoft.com/config/debian/11/prod.list -o /etc/apt/sources.list.d/mssql-release.list
+apt update

 echo "Install msodbcsql"
-ACCEPT_EULA=Y apt-get install -y msodbcsql17
+ACCEPT_EULA=Y apt install -y msodbcsql18 mssql-tools18

-ln -fsv /opt/mssql-tools/bin/* /usr/bin
+ln -fsv /opt/mssql-tools18/bin/* /usr/bin

 # Need 5.10.1 (or later) for PHP 8.2 support
 pecl install sqlsrv-5.10.1

HTH, Matteo

andrewnicols commented 1 year ago

Hopefully solved in #164.

Supported for PHP 8.0 onwards it seems, but not earlier. https://learn.microsoft.com/en-us/sql/connect/php/system-requirements-for-the-php-sql-driver?view=sql-server-ver16

stronk7 commented 1 year ago

Closed by #164