-
-
Save xenogew/3440d323b00e1d661966f2b2ca3ef64a to your computer and use it in GitHub Desktop.
FROM php:8.4-fpm-bookworm | |
WORKDIR /application | |
ENV ACCEPT_EULA=Y | |
# Fix debconf warnings upon build | |
ARG DEBIAN_FRONTEND=noninteractive | |
ARG DEBIAN_VERSION | |
# LEGACY packages that ever installed when last time research of PHP 7.4, | |
# not sure it related to the other factor when run any function, | |
# please check it and confirm by your own envrionment. | |
# NOTICE: libraries list from `user:webchi` | |
# gnupg libpq-dev libzip-dev | |
# NOTICE: libraries list from `me` | |
# apt-utils libxml2-dev gnupg apt-transport-https | |
# Install selected extensions and other stuff | |
RUN apt update \ | |
&& apt -y --no-install-recommends install gnupg libicu-dev \ | |
&& apt clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* | |
# Install MS ODBC Driver for SQL Server | |
RUN DEBIAN_VERSION=$(cat /etc/debian_version | cut -d. -f1) \ | |
&& curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg \ | |
&& curl https://packages.microsoft.com/config/debian/${DEBIAN_VERSION}/prod.list > /etc/apt/sources.list.d/mssql-release.list \ | |
&& apt update \ | |
&& apt -y --no-install-recommends install msodbcsql18 unixodbc-dev \ | |
&& pecl install sqlsrv \ | |
&& pecl install pdo_sqlsrv \ | |
&& echo "extension=pdo_sqlsrv.so" >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ | |
&& echo "extension=sqlsrv.so" >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-sqlsrv.ini \ | |
&& apt clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* | |
# Install required extensions | |
RUN docker-php-ext-install intl mysqli pdo pdo_mysql |
can this be use for PHP 7.4?
I am using this snippet on top of php:7.4.22-apache
. A couple of months ago it worked fine, now I get this error when running apt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev
The following packages have unmet dependencies:
libodbc1 : PreDepends: multiarch-support but it is not installable
odbcinst1debian2 : PreDepends: multiarch-support but it is not installable
E: Unable to correct problems, you have held broken packages.
I am using this snippet on top of
php:7.4.22-apache
. A couple of months ago it worked fine, now I get this error when runningapt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev
The following packages have unmet dependencies: libodbc1 : PreDepends: multiarch-support but it is not installable odbcinst1debian2 : PreDepends: multiarch-support but it is not installable E: Unable to correct problems, you have held broken packages.
the same issue
did you manage to solve this?
I am using this snippet on top of
php:7.4.22-apache
. A couple of months ago it worked fine, now I get this error when runningapt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev
The following packages have unmet dependencies: libodbc1 : PreDepends: multiarch-support but it is not installable odbcinst1debian2 : PreDepends: multiarch-support but it is not installable E: Unable to correct problems, you have held broken packages.
the same issue did you manage to solve this?
Not sure if this will help but snippet is quite old maybe check if debian version of this images is the same version as used in url "https://packages.microsoft.com/config/debian/9/prod.list". Use "cat /etc/os-version" which should give you the answer, I just build image by changin 9 to 11 but my was based on php:8.1.5.
thank you so much, you saved my ass, chef’s kiss!
Upgrade to actual versions
FROM php:8.4.6-fpm
ENV ACCEPT_EULA=Y
RUN apt-get update && apt-get install -y gnupg libpq-dev libzip-dev
# sql server drivers https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg && \
curl https://packages.microsoft.com/config/debian/12/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && apt-get install -y msodbcsql18 unixodbc-dev && \
pecl install sqlsrv-5.12.0 && \
pecl install pdo_sqlsrv-5.12.0 && \
docker-php-ext-enable sqlsrv pdo_sqlsrv && \
docker-php-ext-install pdo_mysql pdo_pgsql zip
COPY --from=composer /usr/bin/composer /usr/bin/composer
USER www-data
COPY --chown=www-data:www-data . .
RUN composer install
Thanks guys, I didn't expect it to be helpful for your work this much.
Even I'm not the PHP developer, but I want to play and look around to update it.
And I reduce/remove some installed packages in Dockerfile
and setup testing environment with Docker Compose, and it worked you can check it and adapt to your own work if you think it is good.
Lastly, my research for setup things up and testing is on my repository
https://github.com/xenogew/php-mssql-docker
P.S. For those who want the last version, please check diff with Revision tab on this Gist.
I followed the instructions but doesn't work. I'm also on my M1 Mac