Docker 構建PHP 映象環境

是阿東啊發表於2021-05-18

這個映象只是用來處理 CI 流程的
是一個 CentOS7 + php73 + composer 環境

如需要構建 php 其他版本, 可修改 php73 至對應版本

php擴充套件支援了 sqlsrv , oracle, mongo

不需要支援 oracle 的需要刪除相關程式碼

同級目錄還有一個 oracle 資料夾, oracle資料夾下的檔案

instantclient-basic-linux.x64-11.2.0.4.0.zip
instantclient-sdk-linux.x64-11.2.0.4.0.zip
instantclient-sqlplus-linux.x64-11.2.0.4.0.zip

Dockerfile

FROM centos:7

RUN yum install -y yum-utils epel-release
RUN yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm 

RUN yum install -y zip \
        unzip \
        systemtap-sdt-devel \
        git \
        libaio

RUN curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo \
    && ACCEPT_EULA=Y yum install msodbcsql17 mssql-tools -y \
    && echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc \
    && source ~/.bashrc

COPY ./oracle /usr/local/src/

RUN cd /usr/local/src \
    && unzip instantclient-basic-linux.x64-11.2.0.4.0.zip -d /usr/local \
    && unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip -d /usr/local \
    && unzip instantclient-sqlplus-linux.x64-11.2.0.4.0.zip -d /usr/local \
    && cd /usr/local/instantclient_11_2 \
    && ln -s libclntsh.so.11.1 libclntsh.so \
    && ln -s libocci.so.11.1 libocci.so \
    && echo '/usr/local/instantclient_11_2' > /etc/ld.so.conf.d/oracle-instantclient.conf \
    && ldconfig \
    && echo 'export PATH="$PATH:/usr/local/instantclient_11_2"' >> ~/.bashrc \
    && source ~/.bashrc 

RUN yum install -y php73-php-common \
        php73-php-fpm \
        php73-php-cli \
        php73-php-bcmath \
        php73-php-gd \
        php73-php-json \
        php73-php-mbstring \
        php73-php-mcrypt \
        php73-php-mysqlnd \
        php73-php-opcache \
        php73-php-pdo \
        php73-php-pecl-crypto \
        php73-php-pecl-mcrypt \
        php73-php-pecl-geoip \
        php73-php-recode \
        php73-php-snmp \
        php73-php-soap \
        php73-php-xml \
        php73-php-pear \
        php73-php-devel \
        php73-php-pecl-mongodb \
        php73-pecl-redis \
        php73-php-sqlsrv \
    && ln -s /opt/remi/php73/root/bin/* /usr/bin/ 

RUN curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer

RUN export PHP_DTRACE=yes \
    && pecl channel-update pecl.php.net \
    && sh -c '/bin/echo -e "instantclient,/usr/local/instantclient_11_2" | pecl install oci8-2.2.0' \
    && echo 'extension=oci8.so' >> /etc/opt/remi/php73/php.d/20-oci8.ini
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章