Skip to content

Commit

Permalink
Preliminar support for php72
Browse files Browse the repository at this point in the history
With sqlsrv latest 5.2-RC1 drivers and MSODBC 17 preview
it seems that it's possible to make the extension to work
under Debian 9.

it requires to install MSODBC 13, uninstall it and then install
MSODBC 17, but seems to be working ok.

oci also requires some little changes

and, finally, what I've been unable to fix/make work is solr. it
seems that still is not ready, so I've disabled it for now.

This will help fixing moodlehq#16.
  • Loading branch information
stronk7 committed Jan 19, 2018
1 parent c0df519 commit 7cfe608
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 16 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM php:7.1-apache
FROM php:7.2-apache

ADD root/ /
# Fix the original permissions of /tmp, the PHP default upload tmp dir.
RUN chmod 777 /tmp && chmod +t /tmp
# Setup the required extensions.
ARG DEBIAN_FRONTEND=noninteractive
RUN /tmp/setup/php-extensions.sh
RUN /tmp/setup/oci8-extension.sh

Expand Down
3 changes: 3 additions & 0 deletions root/tmp/setup/oci8-extension.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ ln -s /usr/local/instantclient_12_1 /usr/local/instantclient
ln -s /usr/local/instantclient/libclntsh.so.12.1 /usr/local/instantclient/libclntsh.so
ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus

echo 'export LD_LIBRARY_PATH="/usr/local/instantclient"' >> /root/.bashrc
echo 'umask 002' >> /root/.bashrc

echo 'instantclient,/usr/local/instantclient' | pecl install oci8 && docker-php-ext-enable oci8
echo 'oci8.statement_cache_size = 0' >> /usr/local/etc/php/conf.d/docker-php-ext-oci8.ini
23 changes: 9 additions & 14 deletions root/tmp/setup/php-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

set -e

echo "Installing apt depdencies"
echo "Installing apt dependencies"

BUILD_PACKAGES="gettext libcurl4-openssl-dev libpq-dev libmysqlclient-dev libldap2-dev libxslt-dev \
BUILD_PACKAGES="gettext libcurl4-openssl-dev libpq-dev default-libmysqlclient-dev libldap2-dev libxslt-dev \
libxml2-dev libicu-dev libfreetype6-dev libjpeg62-turbo-dev libmemcached-dev \
zlib1g-dev libpng12-dev unixodbc-dev"
zlib1g-dev libpng-dev unixodbc-dev gnupg2"

LIBS="locales libaio1 libcurl3 libgss3 libicu52 libmysqlclient18 libpq5 libmemcached11 libmemcachedutil2 libldap-2.4-2 libxml2 libxslt1.1 unixodbc libmcrypt-dev"
LIBS="locales libaio1 libcurl3 libgss3 libicu57 libpq5 libmemcached11 libmemcachedutil2 libldap-2.4-2 libxml2 libxslt1.1 unixodbc libmcrypt-dev"

apt-get update
apt-get install -y --no-install-recommends $BUILD_PACKAGES $LIBS unzip ghostscript locales apt-transport-https
Expand All @@ -34,19 +34,14 @@ docker-php-ext-install -j$(nproc) gd
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/
docker-php-ext-install -j$(nproc) ldap

pecl install solr memcached redis apcu igbinary
docker-php-ext-enable solr memcached redis apcu igbinary
pecl install memcached redis apcu igbinary
docker-php-ext-enable memcached redis apcu igbinary

echo 'apc.enable_cli = On' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini

# Install Microsoft depdencises for sqlsrv
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/debian/8/prod.list -o /etc/apt/sources.list.d/mssql-release.list
apt-get update
ACCEPT_EULA=Y apt-get install -y msodbcsql

pecl install sqlsrv-4.3.0
docker-php-ext-enable sqlsrv
# Go for sqlsrv extension now (kept apart for clarity, still need to be run here
# before some build packages are deleted.
/tmp/setup/sqlsrv-extension.sh

# Keep our image size down..
pecl clear-cache
Expand Down
33 changes: 33 additions & 0 deletions root/tmp/setup/sqlsrv-extension.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -e

# Install Microsoft dependencies for sqlsrv
# Debian 9 requires ODBC driver 17, still not package available in repos, so followed this
# https://github.com/Microsoft/msphpsql/wiki/Install-and-configuration#user-content-odbc-17-linux-installation
echo "Downloading sqlsrv files"
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/debian/8/prod.list -o /etc/apt/sources.list.d/mssql-release.list
apt-get update

echo "Install msodbcsql"
ACCEPT_EULA=Y apt-get install -y msodbcsql

# now remove ODBC driver 13.1, then download and install 17 from Github
apt-get purge -y msodbcsql

curl https://raw.githubusercontent.com/Microsoft/msphpsql/dev/ODBC%2017%20binaries%20preview/Debian%209/msodbcsql_17.0.0.5-1_amd64.deb \
-o /tmp/msodbcsql_17.0.0.5-1_amd64.deb
curl https://raw.githubusercontent.com/Microsoft/msphpsql/dev/ODBC%2017%20binaries%20preview/Debian%209/mssql-tools_17.0.0.5-1_amd64.deb \
-o /tmp/mssql-tools_17.0.0.5-1_amd64.deb

ACCEPT_EULA=Y dpkg -i /tmp/msodbcsql_17.0.0.5-1_amd64.deb
ACCEPT_EULA=Y dpkg -i /tmp/mssql-tools_17.0.0.5-1_amd64.deb

rm /tmp/msodbcsql_17.0.0.5-1_amd64.deb
rm /tmp/mssql-tools_17.0.0.5-1_amd64.deb

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

pecl install sqlsrv-5.2.0RC1
docker-php-ext-enable sqlsrv
2 changes: 1 addition & 1 deletion tests/fixtures/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'oci8',
'pgsql',
'redis',
'solr',
# Disabled because it's not available for php72 yet 'solr',
'soap',
'sqlsrv',
'xsl',
Expand Down

0 comments on commit 7cfe608

Please sign in to comment.