Dockerfile for a Laravel application with SQL Server (MSSQL)
DockerLet's install the MSSQL driver for a Laravel application on php:8.2-apache-buster
docker image.
FROM php:8.2-apache-buster
RUN apt update && apt install -y unixodbc-dev gpg libzip-dev \
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt update \
&& ACCEPT_EULA=Y apt-get install -y msodbcsql18 \
&& pecl install sqlsrv \
&& pecl install pdo_sqlsrv \
&& docker-php-ext-install pdo opcache bcmath zip \
&& mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& echo 'extension=sqlsrv.so' >> "$PHP_INI_DIR/php.ini" \
&& echo 'extension=pdo_sqlsrv.so' >> "$PHP_INI_DIR/php.ini" \
&& a2enmod rewrite
This will install the requirement for database communication between Laravel and a distant SQL server.