Dockerfile phpミラーの構築

3504 ワード

Dockerfileについて簡単に説明します.
FROM centos:7はcentos:7バージョンに依存するミラーを表し、対応するミラーがない場合は最新のcenos:7ミラーを自動的に消去します
RUN yum-y install libxml 2は、あるコマンドを実行することを示す
ENVはミラーの構築中の環境変数を表し、実行時に利用可能
ENTRYPOINTは、CMDコマンドと同様に、nginx:ENTRYPOINT["nginx","-g","daemon off;]のようなコマンドを実行するコマンドを表す.
基本コマンドを説明した後、php環境のミラーを構築します.
Dockerfileファイルを作成し、次のように入力します.
FROM centos:7 

ENV PHP_INI_DIR /usr/local/php/etc

RUN yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libzip-devel pcre-devel

RUN yum install -y https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-6.8.2-1.el7.x86_64.rpm
RUN yum install -y https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-devel-6.8.2-1.el7.x86_64.rpm

RUN cd /tmp
RUN wget wget https://www.php.net/distributions/php-7.4.7.tar.xz && xz -d php-7.4.7.tar.xz && tar -xvf php-7.4.7.tar

RUN ./configure \
    --with-config-file-path="$PHP_INI_DIR" \
    --with-pear --enable-bcmath --with-curl --enable-gd --with-libdir=lib64 --with-bz2 --with-zlib --enable-soap --enable-sockets --with-mysqli --with-pdo-mysql  --with-curl --enable-fpm --enable-mbstring --enable-sockets --enable-gd --with-openssl


RUN make && make install

RUN cp /tmp/php-7.4.7/php.ini-production /usr/local/php/etc/php.ini
#         
# RUN cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# RUN cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

RUN sed -i "s/memory_limit = 128M/memory_limit = 1024M/g" /usr/local/php/etc/php.ini 

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php composer-setup.php && \
php -r
"unlink('composer-setup.php');" && \
mv composer.phar /usr/local/bin/composer && \
composer config -g repo.packagist composer https:
//mirrors.aliyun.com/composer

RUN pecl channel-update pecl.php.net

RUN pecl install -o -f redis && \ echo extension=redis.so >> /usr/local/php/etc/php.ini
ENTRYPOINT [] 

WORKDIR /workdir

 
Dockerfileディレクトリに入りdocker buildを実行する. 
ミラーの構築を待つとphp環境のミラーが完了します