Skip to content

Commit e1f897f

Browse files
author
yjc
committed
优化php56,php70,php71镜像Dockerfile
1 parent a169852 commit e1f897f

File tree

10 files changed

+19
-33
lines changed

10 files changed

+19
-33
lines changed

php56-fpm-centos68-gccext/Dockerfile

-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ ENV PHALCON_VERSION 3.3.1
1212
ENV XHPROF_VERSION 4.1.5
1313

1414
RUN yum -y install git
15-
RUN ln -s /usr/local/php/bin/pecl /usr/bin/ && \
16-
ln -s /usr/local/php/sbin/php-fpm /usr/bin/
1715

1816
# php-ext
1917
RUN pecl install memcache protobuf mongodb seaslog
@@ -57,8 +55,6 @@ RUN echo "extension=msgpack.so" >> "$PHP_INI_FILE" && \
5755
echo "extension=tideways.so" >> "$PHP_INI_FILE" && \
5856
echo "extension=libevent.so" >> "$PHP_INI_FILE" && \
5957
echo "extension=gearman.so" >> "$PHP_INI_FILE"
60-
61-
RUN useradd www
6258

6359
ADD ./run.sh /run.sh
6460
RUN chmod 755 /run.sh

php56-fpm-centos68-withext/Dockerfile

-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ FROM php56-fpm-centos68
33
44

55
# RUN yum -y install git
6-
RUN ln -s /usr/local/php/bin/pecl /usr/bin/ && \
7-
ln -s /usr/local/php/sbin/php-fpm /usr/bin/
86

97
ADD libgearman.tar.gz /usr/local/lib/
108
RUN ln -s /usr/local/lib/libgearman.so.8.0.0 /usr/local/lib/libgearman.so && \
@@ -23,9 +21,6 @@ RUN echo "extension=msgpack.so" >> "$PHP_INI_FILE" && \
2321

2422
#RUN yum -y install libevent-devel && echo "extension=libevent.so" >> "$PHP_INI_FILE"
2523

26-
# fix fpm
27-
RUN useradd www
28-
2924
ADD ./run.sh /run.sh
3025
RUN chmod +x /run.sh
3126

php56-fpm-centos68/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ RUN tar zxvf /libmcrypt-2.5.8.tar.gz \
5555
&& cd /libmcrypt-2.5.8 && ./configure && make && make install && cd - / && rm -rf /libmcrypt* \
5656
&& tar zxvf /mhash-0.9.9.9.tar.gz && cd mhash-0.9.9.9 && ./configure && make && make install && cd - / && rm -rf /mhash* \
5757
&& tar zxvf /mcrypt-2.6.8.tar.gz && cd mcrypt-2.6.8 && LD_LIBRARY_PATH=/usr/local/lib ./configure && make && make install && cd - / && rm -rf /mcrypt*
58-
58+
59+
# install php
5960
RUN wget -O /php-${PHP_VERSION}.tar.bz2 "$PHP_URL" \
6061
&& tar jxvf /php-${PHP_VERSION}.tar.bz2 && cd php-${PHP_VERSION}/ \
6162
&& ./configure --prefix=/usr/local/php --with-config-file-scan-dir=/usr/local/php/etc/ --enable-inline-optimization --enable-opcache --enable-session --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite --with-sqlite3 --with-gettext --enable-mbregex --enable-mbstring --enable-xml --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-xmlrpc --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-curlwrappers --with-zlib --enable-zip --with-bz2 --with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-readline \
@@ -65,6 +66,7 @@ RUN wget -O /php-${PHP_VERSION}.tar.bz2 "$PHP_URL" \
6566
&& cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf \
6667
&& make clean && yum clean all && cd - && rm -rf /php-${PHP_VERSION}* \
6768
&& ln -sf /usr/local/php/bin/* /usr/bin/ \
69+
&& ln -sf /usr/local/php/sbin/* /usr/bin/ \
6870
&& sed -i "s/;date.timezone =/date.timezone =PRC/" /usr/local/php/etc/php.ini
6971

7072
RUN useradd www

php56-fpm-centos68/Dockerfile_online

+3-5
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ RUN wget -O /php-${PHP_VERSION}.tar.bz2 "$PHP_URL" \
5252
&& cp php.ini* /usr/local/php/etc/ \
5353
&& cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf \
5454
&& make clean && yum clean all && cd - && rm -rf /php-${PHP_VERSION}* \
55-
&& ln -s /usr/local/php/bin/php /usr/bin/php \
56-
&& ln -s /usr/local/php/bin/phpize /usr/bin/phpize \
57-
&& ln -s /usr/local/php/bin/php-config /usr/bin/php-config \
58-
&& ln -s /usr/local/php/bin/pecl /usr/bin/pecl \
55+
&& ln -sf /usr/local/php/bin/* /usr/bin/ \
56+
&& ln -sf /usr/local/php/sbin/* /usr/bin/ \
5957
&& sed -i "s/;date.timezone =/date.timezone =PRC/" /usr/local/php/etc/php.ini
6058

6159
RUN useradd www
@@ -107,5 +105,5 @@ CMD /run.sh && tail -f
107105
EXPOSE 80
108106
EXPOSE 9000
109107

110-
#docker build -t php56-fpm-centos68 .
108+
#docker build -t php56-fpm-centos68 -f Dockerfile_online .
111109

php56-fpm-centos68/README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ php5.6的开发环境。包含:
3232

3333
``` bash
3434
cp -rf ../php70-fpm-centos68/*gz ./
35-
docker build -t php56-fpm-centos68 .
35+
c
3636
```
3737
或者执行bulid.sh。
3838

3939
编译需要30分钟左右。实际视机器性能而定。
4040

41+
如果不能COPY当前目录的已下载文件,那么可以指定 Dockerfile_online :
42+
``` bash
43+
docker build -t php56-fpm-centos68 -f Dockerfile_online .
44+
```
45+
该Dockerfile会联网下载所需要的资源。
46+
4147
2、编译完成后可以创建容器了。默认会自动启动Nginx、php-fpm服务:
4248

4349
``` bash

php70-fpm-centos68/Dockerfile

+2-3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ RUN wget -O /php-${PHP_VERSION}.tar.bz2 "$PHP_URL" \
6565
&& cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf \
6666
&& cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf \
6767
&& make clean && yum clean all && cd - && rm -rf /php-${PHP_VERSION}* \
68+
&& ln -sf /usr/local/php/bin/* /usr/bin/ \
69+
&& ln -sf /usr/local/php/sbin/* /usr/bin/ \
6870
&& sed -i "s/;date.timezone =/date.timezone =PRC/" /usr/local/php/etc/php.ini
6971

7072
RUN useradd www
@@ -88,9 +90,6 @@ RUN echo 'install nginx' \
8890
#RUN wget https://github.com/swoole/swoole-src/archive/swoole-src-${SWOOLE_VER}.tar.gz \
8991
RUN echo 'install swoole' \
9092
&& tar xzf /${SWOOLE_VER}.tar.gz && cd swoole-src-${SWOOLE_VER} \
91-
&& ln -s /usr/local/php/bin/php /usr/bin/php \
92-
&& ln -s /usr/local/php/bin/phpize /usr/bin/phpize \
93-
&& ln -s /usr/local/php/bin/php-config /usr/bin/php-config \
9493
&& phpize \
9594
&& ./configure \
9695
&& make && make install \

php71-fpm-centos68-phalcon-withext/Dockerfile

-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ ENV PHP_VERSION 7.1.12
77
ENV PHP_URL="http://cn2.php.net/distributions/php-${PHP_VERSION}.tar.bz2"
88

99
# RUN yum -y install git
10-
RUN ln -s /usr/local/php/bin/pecl /usr/bin/ && \
11-
ln -s /usr/local/php/sbin/php-fpm /usr/bin/
1210

1311
ADD libgearman.so.8 /usr/local/lib/
1412
ADD ext.tar.gz /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/
@@ -24,9 +22,6 @@ RUN echo "extension=msgpack.so" >> "$PHP_INI_FILE" && \
2422
echo "extension=tideways.so" >> "$PHP_INI_FILE" && \
2523
echo "extension=gearman.so" >> "$PHP_INI_FILE"
2624

27-
# fix fpm
28-
RUN useradd www && cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
29-
3025
ADD ./run.sh /run.sh
3126
RUN chmod +x /run.sh
3227

php71-fpm-centos68-phalcon/Dockerfile

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ ENV PHALCON_VERSION 3.3.1
1212
ENV XHPROF_VERSION 4.1.5
1313

1414
RUN yum -y install git
15-
RUN ln -s /usr/local/php/bin/pecl /usr/bin/ && \
16-
ln -s /usr/local/php/sbin/php-fpm /usr/bin/
1715

1816
# php-ext
1917
RUN pecl install msgpack protobuf yaconf mongodb seaslog

php71-fpm-centos68/Dockerfile

+2-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ RUN wget -O /php-${PHP_VERSION}.tar.bz2 "$PHP_URL" \
6464
&& cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf \
6565
&& cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf \
6666
&& make clean && yum clean all && cd - && rm -rf /php-${PHP_VERSION}* \
67+
&& ln -sf /usr/local/php/bin/* /usr/bin/ \
68+
&& ln -sf /usr/local/php/sbin/* /usr/bin/ \
6769
&& sed -i "s/;date.timezone =/date.timezone =PRC/" /usr/local/php/etc/php.ini
6870

6971
RUN useradd www
@@ -87,9 +89,6 @@ RUN echo 'install nginx' \
8789
#RUN wget https://github.com/swoole/swoole-src/archive/swoole-src-${SWOOLE_VER}.tar.gz \
8890
RUN echo 'install swoole' \
8991
&& tar xzf /${SWOOLE_VER}.tar.gz && cd swoole-src-${SWOOLE_VER} \
90-
&& ln -s /usr/local/php/bin/php /usr/bin/php \
91-
&& ln -s /usr/local/php/bin/phpize /usr/bin/phpize \
92-
&& ln -s /usr/local/php/bin/php-config /usr/bin/php-config \
9392
&& phpize \
9493
&& ./configure \
9594
&& make && make install \

php71-fpm-centos68/Dockerfile_online

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ RUN wget -O /php-${PHP_VERSION}.tar.bz2 "$PHP_URL" \
5050
&& cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf \
5151
&& cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf \
5252
&& make clean && yum clean all && cd - && rm -rf /php-${PHP_VERSION}* \
53-
&& ln -s /usr/local/php/bin/php /usr/bin/php \
54-
&& ln -s /usr/local/php/bin/phpize /usr/bin/phpize \
55-
&& ln -s /usr/local/php/bin/php-config /usr/bin/php-config \
56-
&& ln -s /usr/local/php/bin/pecl /usr/bin/pecl \
53+
&& ln -sf /usr/local/php/bin/* /usr/bin/ \
54+
&& ln -sf /usr/local/php/sbin/* /usr/bin/ \
5755
&& sed -i "s/;date.timezone =/date.timezone =PRC/" /usr/local/php/etc/php.ini
5856

5957
RUN useradd www

0 commit comments

Comments
 (0)