Skip to content

Commit 1250668

Browse files
Adding MSSQL Support
1 parent 1a80385 commit 1250668

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

php-fpm/Dockerfile-70

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,78 @@ RUN if [ ${CODEIGNITER} = true ]; then \
186186
docker-php-ext-install tokenizer \
187187
;fi
188188

189+
#####################################
190+
# SQL SERVER:
191+
#####################################
192+
ARG MSSQL=false
193+
RUN if [ ${MSSQL} = true ]; then \
194+
195+
#####################################
196+
# Install Depenencies:
197+
#####################################
198+
apt-get update && \
199+
apt-get install -y --force-yes wget apt-transport-https curl freetds-common php5-odbc libsybdb5 freetds-bin unixodbc unixodbc-dev php5-sybase && \
200+
201+
#####################################
202+
# The following steps were taken from
203+
# Microsoft's github account:
204+
# https://github.com/Microsoft/msphpsql/wiki/Dockerfile-for-getting-pdo_sqlsrv-for-PHP-7.0-on-Debian-in-3-ways
205+
#####################################
206+
207+
# Add PHP 7 repository
208+
# for Debian jessie
209+
# And System upgrade
210+
echo "deb http://packages.dotdeb.org jessie all" \
211+
| tee /etc/apt/sources.list.d/dotdeb.list \
212+
&& wget -qO- https://www.dotdeb.org/dotdeb.gpg \
213+
| apt-key add - \
214+
&& apt-get update \
215+
&& apt-get upgrade -qq && \
216+
217+
# Install UnixODBC
218+
# Compile odbc_config as it is not part of unixodbc package
219+
apt-get install -y whiptail \
220+
unixodbc libgss3 odbcinst devscripts debhelper dh-exec dh-autoreconf libreadline-dev libltdl-dev \
221+
&& dget -u -x http://http.debian.net/debian/pool/main/u/unixodbc/unixodbc_2.3.1-3.dsc \
222+
&& cd unixodbc-*/ \
223+
&& dpkg-buildpackage -uc -us -B -d \
224+
&& cp -v ./exe/odbc_config /usr/local/bin/ && \
225+
226+
# Fake uname for install.sh
227+
printf '#!/bin/bash\nif [ "$*" == "-p" ]; then echo "x86_64"; else /bin/uname "$@"; fi' \
228+
| tee /usr/local/bin/uname \
229+
&& chmod +x /usr/local/bin/uname && \
230+
231+
# Microsoft ODBC Driver 13 for Linux
232+
# Note: There's a copy of this tar on my hubiC
233+
wget -nv -O msodbcsql-13.0.0.0.tar.gz \
234+
"https://meetsstorenew.blob.core.windows.net/contianerhd/Ubuntu%2013.0%20Tar/msodbcsql-13.0.0.0.tar.gz?st=2016-10-18T17%3A29%3A00Z&se=2022-10-19T17%3A29%3A00Z&sp=rl&sv=2015-04-05&sr=b&sig=cDwPfrouVeIQf0vi%2BnKt%2BzX8Z8caIYvRCmicDL5oknY%3D" \
235+
&& tar -xf msodbcsql-13.0.0.0.tar.gz \
236+
&& cd msodbcsql-*/ \
237+
&& ldd lib64/libmsodbcsql-13.0.so.0.0 \
238+
&& ./install.sh install --accept-license \
239+
&& ls -l /opt/microsoft/msodbcsql/ \
240+
&& odbcinst -q -d -n "ODBC Driver 13 for SQL Server" && \
241+
242+
243+
#####################################
244+
# Install sqlsrv y pdo_sqlsrv
245+
# extensions:
246+
#####################################
247+
248+
pecl install sqlsrv-4.0.6 && \
249+
pecl install pdo_sqlsrv-4.0.6 && \
250+
251+
#####################################
252+
# Set locales for the container
253+
#####################################
254+
255+
apt-get install -y locales \
256+
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
257+
&& locale-gen \
258+
;fi
259+
260+
189261
#
190262
#--------------------------------------------------------------------------
191263
# Final Touch

php-fpm/laravel.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ upload_max_filesize = 20M
1111
; Sets max size of post data allowed.
1212
; http://php.net/post-max-size
1313
post_max_size = 20M
14+
; Enables the MSSQL extensions
15+
extension=sqlsrv.so
16+
extension=pdo_sqlsrv.so

0 commit comments

Comments
 (0)