基于 drupal-php build sqlserver php 环境


最后编写的 Dockerfile 文件如下:

FROM wodby/drupal-php:7.3

USER root

# Install packages
RUN echo 'http://mirrors.aliyun.com/alpine/edge/main' > /etc/apk/repositories && \
    echo 'http://mirrors.aliyun.com/alpine/edge/community' >> /etc/apk/repositories && \
    echo 'http://mirrors.aliyun.com/alpine/edge/testing' >> /etc/apk/repositories && \

    apk add --update \
        libressl \
        ca-certificates \
        openssh-client \
        rsync \
        git \
        curl \
        wget \
        gzip \
        tar \
        patch \
        perl \
        pcre \
        imap \
        imagemagick \
        mariadb-client \

        # Temp packages
        build-base \
        autoconf \
        libtool \
        php7-dev \
        pcre-dev \
        imagemagick-dev \

        # PHP packages
        php7 \
        php7-fpm \
        php7-opcache \
        php7-session \
        php7-dom \
        php7-xml \
        php7-xmlreader \
        php7-ctype \
        php7-ftp \
        php7-gd \
        php7-json \
        php7-posix \
        php7-curl \
        php7-pdo \
        php7-pdo_mysql \
        php7-sockets \
        php7-zlib \
        php7-mcrypt \
        php7-mysqli \
        php7-sqlite3 \
        php7-bz2 \
        php7-phar \
        php7-openssl \
        php7-posix \
        php7-zip \
        php7-calendar \
        php7-iconv \
        php7-imap \
        php7-soap \
        php7-dev \
        php7-pear \
        php7-redis \
        php7-mbstring \
        php7-xdebug \
        php7-exif \
        php7-xsl \
        php7-ldap \
        php7-bcmath \
        php7-memcached \
        php7-oauth \
        php7-apcu

RUN php -v
RUN apk add unixodbc-dev
    # Install sqlsrv
RUN pecl install sqlsrv && docker-php-ext-enable sqlsrv
#        echo 'extension=sqlsrv.so' > /etc/php7/conf.d/sqlsrv.ini
RUN pecl install pdo_sqlsrv && \
    docker-php-ext-enable pdo_sqlsrv
RUN echo 'pdo_sqlsrv.client_buffer_max_kb_size = 50240' >> /usr/local/etc/php/conf.d/docker-php-ext-pdo_sqlsrv.ini
#RUN docker-php-
#        echo 'extension=pdo_sqlsrv.so' > /etc/php7/conf.d/pdo_sqlsrv.ini
#RUN     pecl install wincache && docker-php-ext-enable wincache


#Download the desired package(s)
RUN curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.1.1-1_amd64.apk
RUN curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/mssql-tools_17.5.1.2-1_amd64.apk


#(Optional) Verify signature, if 'gpg' is missing install it using 'apk add gnupg':
#RUN curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.1.1-1_amd64.sig
#RUN curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/mssql-tools_17.5.1.2-1_amd64.sig

#RUN curl https://packages.microsoft.com/keys/microsoft.asc && gpg --import -
#RUN gpg --verify msodbcsql17_17.5.1.1-1_amd64.sig msodbcsql17_17.5.1.1-1_amd64.apk
#RUN gpg --verify mssql-tools_17.5.1.2-1_amd64.sig mssql-tools_17.5.1.2-1_amd64.apk


#Install the package(s)
RUN apk add --allow-untrusted msodbcsql17_17.5.1.1-1_amd64.apk
RUN apk add --allow-untrusted mssql-tools_17.5.1.2-1_amd64.apk

#pdo_sqlsrv.client_buffer_max_kb_size = 50240

容器 Dockerfile 参考:

SQL Server Container microsoft/mssql-server-linux

https://github.com/wodby/drupal-php

drupal-php Dockerfile

SQL Server 驱动:

安装 Linux 和 macOS 上的 Microsoft ODBC Driver for SQL Server

Microsoft Drivers for PHP for SQL Server 的 Linux 和 macOS 安装教程

sqlsrv在linux需要wincache的问题:

https://www.drupal.org/project/sqlsrv/issues/2942556

https://www.drupal.org/project/sqlsrv/releases

https://www.drupal.org/project/sqlsrv/releases/7.x-1.4

缺 sql.h 与 换 aliyun 源:

https://blog.csdn.net/qq_37126235/article/details/81939882

https://developer.aliyun.com/mirror/