Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build php-fpm with mssql enabled #3357

Closed
gpstiip88 opened this issue Mar 1, 2023 · 8 comments
Closed

Unable to build php-fpm with mssql enabled #3357

gpstiip88 opened this issue Mar 1, 2023 · 8 comments

Comments

@gpstiip88
Copy link

Description:

Error on building php-fpm with mssql enabled

Expected Behavior:

Successful build

Context information:

Output of git rev-parse HEAD

6c8cb6dd85eb1fcad6f7dce3e9d6c6a29c6e3ed8

Output of docker version

Client: Docker Engine - Community
 Version:           23.0.1
 API version:       1.42
 Go version:        go1.19.5
 Git commit:        a5ee5b1
 Built:             Thu Feb  9 19:46:49 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          23.0.1
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.5
  Git commit:       bc3805a
  Built:            Thu Feb  9 19:46:49 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.18
  GitCommit:        2456e983eb9e37e47538f59ea18f2043c9a73640
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker-compose version

docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

System info: Mac, Windows or Linux. Include which disto/version

Ubuntu 18.04.6

Steps to reproduce the issue:

  1. Add laradock as submodule on an empty project git submodule add https://github.com/Laradock/laradock.git
  2. Copy .env.example into .env and set PHP_FPM_INSTALL_MSSQL to true
  3. Run docker-compose up -d php-fpm
  4. Get error on build ERROR: Service 'php-fpm' failed to build : Build failed

Stacktrace & Additional info:

#0 40.79 libtool: link: warning: library `/usr/lib/x86_64-linux-gnu/libodbc.la' was moved.
#0 40.79 grep: /usr/lib/x86_64-linux-gnu/libltdl.la: No such file or directory
#0 40.79 /bin/sed: can't read /usr/lib/x86_64-linux-gnu/libltdl.la: No such file or directory
#0 40.79 libtool: link: `/usr/lib/x86_64-linux-gnu/libltdl.la' is not a valid libtool archive
#0 40.79 make: *** [Makefile:223: pdo_sqlsrv.la] Error 1
#0 40.79 ERROR: `make' failed
------
Dockerfile:738
--------------------
 737 |     
 738 | >>> RUN set -eux; \
 739 | >>>   if [ ${INSTALL_MSSQL} = true ]; then \
 740 | >>>     if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
 741 | >>>       apt-get -yqq install freetds-dev libsybdb5 \
 742 | >>>       && ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so \
 743 | >>>       && docker-php-ext-install mssql pdo_dblib \
 744 | >>>       && php -m | grep -oiE '^mssql$' \
 745 | >>>       && php -m | grep -oiE '^pdo_dblib$' \
 746 | >>>     ;else \
 747 | >>>       ###########################################################################
 748 | >>>       # Ref from https://github.com/Microsoft/msphpsql/wiki/Dockerfile-for-adding-pdo_sqlsrv-and-sqlsrv-to-official-php-image
 749 | >>>       ###########################################################################
 750 | >>>       # Add Microsoft repo for Microsoft ODBC Driver 13 for Linux \
 751 | >>>       apt-get update \
 752 | >>>       && apt-get install -yqq apt-transport-https gnupg lsb-release \
 753 | >>>       && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
 754 | >>>       && curl https://packages.microsoft.com/config/debian/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list \
 755 | >>>       && apt-get update -yqq \
 756 | >>>       && ACCEPT_EULA=Y apt-get install -yqq unixodbc unixodbc-dev libgss3 odbcinst msodbcsql17 locales \
 757 | >>>       && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
 758 | >>>       && ln -sfn /etc/locale.alias /usr/share/locale/locale.alias \
 759 | >>>       && locale-gen \
 760 | >>>       && if [ $(php -r "echo PHP_VERSION_ID - PHP_RELEASE_VERSION;") = "70000" ]; then \
 761 | >>>         pecl install pdo_sqlsrv-5.3.0 sqlsrv-5.3.0 \
 762 | >>>       ;elif [ $(php -r "echo PHP_VERSION_ID - PHP_RELEASE_VERSION;") = "70100" ]; then \
 763 | >>>         pecl install pdo_sqlsrv-5.6.1 sqlsrv-5.6.1 \
 764 | >>>       ;elif [ $(php -r "echo PHP_VERSION_ID - PHP_RELEASE_VERSION;") = "70200" ]; then \
 765 | >>>         pecl install pdo_sqlsrv-5.8.1 sqlsrv-5.8.1 \
 766 | >>>       ;else \
 767 | >>>         pecl install pdo_sqlsrv sqlsrv \
 768 | >>>       ;fi \
 769 | >>>       && docker-php-ext-enable pdo_sqlsrv sqlsrv \
 770 | >>>       && php -m | grep -oiE '^pdo_sqlsrv$' \
 771 | >>>       && php -m | grep -oiE '^sqlsrv$' \
 772 | >>>     ;fi \
 773 | >>>   ;fi
 774 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c set -eux;   if [ ${INSTALL_MSSQL} = true ]; then     if [ $(php -r \"echo PHP_MAJOR_VERSION;\") = \"5\" ]; then       apt-get -yqq install freetds-dev libsybdb5       && ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so       && docker-php-ext-install mssql pdo_dblib       && php -m | grep -oiE '^mssql$'       && php -m | grep -oiE '^pdo_dblib$'     ;else       apt-get update       && apt-get install -yqq apt-transport-https gnupg lsb-release       && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -       && curl https://packages.microsoft.com/config/debian/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list       && apt-get update -yqq       && ACCEPT_EULA=Y apt-get install -yqq unixodbc unixodbc-dev libgss3 odbcinst msodbcsql17 locales       && echo \"en_US.UTF-8 UTF-8\" > /etc/locale.gen       && ln -sfn /etc/locale.alias /usr/share/locale/locale.alias       && locale-gen       && if [ $(php -r \"echo PHP_VERSION_ID - PHP_RELEASE_VERSION;\") = \"70000\" ]; then         pecl install pdo_sqlsrv-5.3.0 sqlsrv-5.3.0       ;elif [ $(php -r \"echo PHP_VERSION_ID - PHP_RELEASE_VERSION;\") = \"70100\" ]; then         pecl install pdo_sqlsrv-5.6.1 sqlsrv-5.6.1       ;elif [ $(php -r \"echo PHP_VERSION_ID - PHP_RELEASE_VERSION;\") = \"70200\" ]; then         pecl install pdo_sqlsrv-5.8.1 sqlsrv-5.8.1       ;else         pecl install pdo_sqlsrv sqlsrv       ;fi       && docker-php-ext-enable pdo_sqlsrv sqlsrv       && php -m | grep -oiE '^pdo_sqlsrv$'       && php -m | grep -oiE '^sqlsrv$'     ;fi   ;fi" did not complete successfully: exit code: 1
ERROR: Service 'php-fpm' failed to build : Build failed
@paulprinke
Copy link

Confirmed. Just tried to use SQLSRV this evening... same error

@bestlong bestlong added the PHP Extension: sqlsrv / dblib (MSSQL) Microsoft SQL Server Functions label Mar 9, 2023
@duchymor
Copy link
Contributor

Awaiting solution here: microsoft/linux-package-repositories#39

@MiguelAngelVM
Copy link

Does anyone have a solution while we wait?

@duchymor
Copy link
Contributor

duchymor commented Mar 27, 2023

This workaround works for me: microsoft/linux-package-repositories#39 (comment) . Key point is using Ubuntu repository. Original:

&& curl https://packages.microsoft.com/config/debian/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list \

Working:
&& curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list \

@duchymor
Copy link
Contributor

Also be aware that the PECL version switch is obsolete. Use 5.9.0 for PHP 7.3 and 5.10.1 for PHP 7.4

@gpstiip88
Copy link
Author

gpstiip88 commented Mar 27, 2023

Thank you @duchymor, these solutions working for me (tested with php 7.4)

###########################################################################
# SQL SERVER:
###########################################################################

ARG INSTALL_MSSQL=false

RUN set -eux; \
  if [ ${INSTALL_MSSQL} = true ]; then \
    if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
      apt-get -yqq install freetds-dev libsybdb5 \
      && ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so \
      && docker-php-ext-install mssql pdo_dblib \
      && php -m | grep -oiE '^mssql$' \
      && php -m | grep -oiE '^pdo_dblib$' \
    ;else \
      ###########################################################################
      # Ref from https://github.com/Microsoft/msphpsql/wiki/Dockerfile-for-adding-pdo_sqlsrv-and-sqlsrv-to-official-php-image
      ###########################################################################
      # Add Microsoft repo for Microsoft ODBC Driver 13 for Linux \
      apt-get update \
      && apt-get install -yqq apt-transport-https gnupg lsb-release \
      && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
      && curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list \ 
      && apt-get update -yqq \
      && ACCEPT_EULA=Y apt-get install -yqq unixodbc unixodbc-dev libgss3 odbcinst msodbcsql17 locales \
      && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
      && ln -sfn /etc/locale.alias /usr/share/locale/locale.alias \
      && locale-gen \
      && if [ $(php -r "echo PHP_VERSION_ID - PHP_RELEASE_VERSION;") = "70000" ]; then \
        pecl install pdo_sqlsrv-5.3.0 sqlsrv-5.3.0 \
      ;elif [ $(php -r "echo PHP_VERSION_ID - PHP_RELEASE_VERSION;") = "70100" ]; then \
        pecl install pdo_sqlsrv-5.6.1 sqlsrv-5.6.1 \
      ;elif [ $(php -r "echo PHP_VERSION_ID - PHP_RELEASE_VERSION;") = "70200" ]; then \
        pecl install pdo_sqlsrv-5.8.1 sqlsrv-5.8.1 \
      ;elif [ $(php -r "echo PHP_VERSION_ID - PHP_RELEASE_VERSION;") = "70300" ]; then \
        pecl install pdo_sqlsrv-5.9.0 sqlsrv-5.9.0 \
      ;elif [ $(php -r "echo PHP_VERSION_ID - PHP_RELEASE_VERSION;") = "70400" ]; then \
        pecl install pdo_sqlsrv-5.10.1 sqlsrv-5.10.1 \
      ;else \
        pecl install pdo_sqlsrv sqlsrv \
      ;fi \
      && docker-php-ext-enable pdo_sqlsrv sqlsrv \
      && php -m | grep -oiE '^pdo_sqlsrv$' \
      && php -m | grep -oiE '^sqlsrv$' \
    ;fi \
  ;fi

@stale
Copy link

stale bot commented Aug 12, 2023

Hi 👋 this issue has been automatically marked as stale 📌 because it has not had recent activity 😴. It will be closed if no further activity occurs. Thank you for your contributions ❤️.

@stale stale bot added the Stale label Aug 12, 2023
@stale
Copy link

stale bot commented Sep 17, 2023

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants