Created
November 20, 2024 03:11
-
-
Save pintend/dd4e268f76c7b8497db2b1826c485ef9 to your computer and use it in GitHub Desktop.
PHP 8.3 connecting to MSServer 2012 - 11.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # amd64/php | php | |
| ARG PHP_PLATFORM="amd64/php" | |
| # 8.2 | 8.3 | |
| ARG PHP_VERSION="8.3" | |
| ARG ALPINE_VERSION="3.20" | |
| FROM --platform="linux/amd64" ${PHP_PLATFORM}:${PHP_VERSION}-fpm-alpine${ALPINE_VERSION} | |
| # 17.10.5 | 17.10.6 | |
| ARG ODBC_VERSION="17.10.6" | |
| ARG MSTOOLS_VERSION="17.10.1" | |
| WORKDIR /root | |
| RUN apk add --no-cache \ | |
| curl \ | |
| gpg \ | |
| gpg-agent \ | |
| nano \ | |
| openssl \ | |
| $PHPIZE_DEPS \ | |
| unixodbc-dev | |
| # Download the packages | |
| RUN mkdir -p /tmp/mssql | |
| # See https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16&tabs=alpine18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline#17 | |
| RUN curl -o /tmp/mssql/msodbcsql17_${ODBC_VERSION}.1-1_amd64.apk \ | |
| https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_${ODBC_VERSION}.1-1_amd64.apk | |
| RUN curl -o /tmp/mssql/mssql-tools_${MSTOOLS_VERSION}.1-1_amd64.apk \ | |
| https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/mssql-tools_${MSTOOLS_VERSION}.1-1_amd64.apk | |
| # Download the signature files | |
| RUN curl -o /tmp/mssql/msodbcsql17_${ODBC_VERSION}.1-1_amd64.sig \ | |
| https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_${ODBC_VERSION}.1-1_amd64.sig | |
| RUN curl -o /tmp/mssql/mssql-tools_${MSTOOLS_VERSION}.1-1_amd64.sig \ | |
| https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/mssql-tools_${MSTOOLS_VERSION}.1-1_amd64.sig | |
| # Clean up any existing GPG keyring issues | |
| RUN rm -rf /root/.gnupg && mkdir -p /root/.gnupg && chmod 700 /root/.gnupg | |
| # Import Microsoft GPG keys | |
| RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --import - | |
| # Verify the signatures | |
| RUN gpg --verify /tmp/mssql/msodbcsql17_${ODBC_VERSION}.1-1_amd64.sig /tmp/mssql/msodbcsql17_${ODBC_VERSION}.1-1_amd64.apk | |
| RUN gpg --verify /tmp/mssql/mssql-tools_${MSTOOLS_VERSION}.1-1_amd64.sig /tmp/mssql/mssql-tools_${MSTOOLS_VERSION}.1-1_amd64.apk | |
| # Install the packages | |
| RUN apk add --allow-untrusted \ | |
| /tmp/mssql/msodbcsql17_${ODBC_VERSION}.1-1_amd64.apk \ | |
| /tmp/mssql/mssql-tools_${MSTOOLS_VERSION}.1-1_amd64.apk | |
| # Add mssql tools to PATH | |
| RUN echo 'export "PATH=$PATH:/opt/mssql-tools/bin"' >> /etc/profile | |
| RUN rm -rf /tmp/mssql | |
| # Fix ssl ms sql error 0x2746 | |
| RUN echo -e "\ | |
| openssl_conf = default_conf\n\ | |
| \n\ | |
| [default_conf]\n\ | |
| ssl_conf = ssl_sect\n\ | |
| \n\ | |
| [ssl_sect]\n\ | |
| system_default = system_default_sect\n\ | |
| \n\ | |
| [system_default_sect]\n\ | |
| MinProtocol = TLSv1\n\ | |
| CipherString = DEFAULT@SECLEVEL=0\n\ | |
| " > /etc/ssl/openssl.cnf.new \ | |
| && cat /etc/ssl/openssl.cnf >> /etc/ssl/openssl.cnf.new \ | |
| && mv /etc/ssl/openssl.cnf.new /etc/ssl/openssl.cnf | |
| # Install the php entensions | |
| RUN pecl install pdo_sqlsrv sqlsrv | |
| RUN docker-php-ext-enable pdo_sqlsrv sqlsrv | |
| COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | |
| # Setup quick alias for artisan and tinker | |
| RUN printf "alias artisan=\"php /laravel/artisan\"\nalias tinker=\"artisan tinker\"\n" > /etc/profile.d/alias.sh | |
| # can test connection to server with | |
| # sqlcmd -S $SERVER -U $USER -P $PASSWORD -q "SELECT @@version" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment