Skip to content

Commit f6753f0

Browse files
committed
use multicore compile;remove useless network;
2 parents 8371126 + cea37ce commit f6753f0

File tree

3 files changed

+63
-68
lines changed

3 files changed

+63
-68
lines changed

Dockerfile

+42-41
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ ARG REDIS_VERSION=4.1.1
77

88
COPY ./sources.list /etc/apt/sources.list.tmp
99
RUN cc=$(curl 'https://ifconfig.co/country'); if [ "$cc" = "China" ]; then \
10-
mv /etc/apt/sources.list.tmp /etc/apt/sources.list; fi
10+
mv /etc/apt/sources.list.tmp /etc/apt/sources.list; else \
11+
rm -rf /etc/apt/sources.list.tmp; fi
1112
RUN apt-get update
1213

1314
# Install extensions from source
@@ -22,45 +23,45 @@ RUN chmod +x /tmp/extensions/install.sh \
2223
# 3. Line `&& :\` do nothing just for better reading.
2324
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
2425
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
25-
&& docker-php-ext-install gd \
26+
&& docker-php-ext-install $mc gd \
2627
&& :\
2728
&& apt-get install -y libicu-dev \
28-
&& docker-php-ext-install intl \
29+
&& docker-php-ext-install $mc intl \
2930
&& :\
3031
&& apt-get install -y libxml2-dev \
3132
&& apt-get install -y libxslt-dev \
32-
&& docker-php-ext-install soap \
33-
&& docker-php-ext-install xsl \
34-
&& docker-php-ext-install xmlrpc \
35-
&& docker-php-ext-install wddx \
33+
&& docker-php-ext-install $mc soap \
34+
&& docker-php-ext-install $mc xsl \
35+
&& docker-php-ext-install $mc xmlrpc \
36+
&& docker-php-ext-install $mc wddx \
3637
&& :\
3738
&& apt-get install -y libbz2-dev \
38-
&& docker-php-ext-install bz2 \
39+
&& docker-php-ext-install $mc bz2 \
3940
&& :\
40-
&& docker-php-ext-install zip \
41-
&& docker-php-ext-install pcntl \
42-
&& docker-php-ext-install pdo_mysql \
43-
&& docker-php-ext-install mysqli \
44-
&& docker-php-ext-install mbstring \
45-
&& docker-php-ext-install exif \
46-
&& docker-php-ext-install bcmath \
47-
&& docker-php-ext-install calendar \
48-
&& docker-php-ext-install sockets \
49-
&& docker-php-ext-install gettext \
50-
&& docker-php-ext-install shmop \
51-
&& docker-php-ext-install sysvmsg \
52-
&& docker-php-ext-install sysvsem \
53-
&& docker-php-ext-install sysvshm
54-
#&& docker-php-ext-install pdo_firebird \
55-
#&& docker-php-ext-install pdo_dblib \
56-
#&& docker-php-ext-install pdo_oci \
57-
#&& docker-php-ext-install pdo_odbc \
58-
#&& docker-php-ext-install pdo_pgsql \
59-
#&& docker-php-ext-install pgsql \
60-
#&& docker-php-ext-install oci8 \
61-
#&& docker-php-ext-install odbc \
62-
#&& docker-php-ext-install dba \
63-
#&& docker-php-ext-install interbase \
41+
&& docker-php-ext-install $mc zip \
42+
&& docker-php-ext-install $mc pcntl \
43+
&& docker-php-ext-install $mc pdo_mysql \
44+
&& docker-php-ext-install $mc mysqli \
45+
&& docker-php-ext-install $mc mbstring \
46+
&& docker-php-ext-install $mc exif \
47+
&& docker-php-ext-install $mc bcmath \
48+
&& docker-php-ext-install $mc calendar \
49+
&& docker-php-ext-install $mc sockets \
50+
&& docker-php-ext-install $mc gettext \
51+
&& docker-php-ext-install $mc shmop \
52+
&& docker-php-ext-install $mc sysvmsg \
53+
&& docker-php-ext-install $mc sysvsem \
54+
&& docker-php-ext-install $mc sysvshm
55+
#&& docker-php-ext-install $mc pdo_firebird \
56+
#&& docker-php-ext-install $mc pdo_dblib \
57+
#&& docker-php-ext-install $mc pdo_oci \
58+
#&& docker-php-ext-install $mc pdo_odbc \
59+
#&& docker-php-ext-install $mc pdo_pgsql \
60+
#&& docker-php-ext-install $mc pgsql \
61+
#&& docker-php-ext-install $mc oci8 \
62+
#&& docker-php-ext-install $mc odbc \
63+
#&& docker-php-ext-install $mc dba \
64+
#&& docker-php-ext-install $mc interbase \
6465
#&& :\
6566
#&& apt-get install -y unixodbc-dev \
6667
#&& pecl install sqlsrv pdo_sqlsrv \
@@ -69,41 +70,41 @@ RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
6970
#&& apt-get install -y curl \
7071
#&& apt-get install -y libcurl3 \
7172
#&& apt-get install -y libcurl4-openssl-dev \
72-
#&& docker-php-ext-install curl \
73+
#&& docker-php-ext-install $mc curl \
7374
#&& :\
7475
#&& apt-get install -y libreadline-dev \
75-
#&& docker-php-ext-install readline \
76+
#&& docker-php-ext-install $mc readline \
7677
#&& :\
7778
#&& apt-get install -y libsnmp-dev \
7879
#&& apt-get install -y snmp \
79-
#&& docker-php-ext-install snmp \
80+
#&& docker-php-ext-install $mc snmp \
8081
#&& :\
8182
#&& apt-get install -y libpspell-dev \
8283
#&& apt-get install -y aspell-en \
83-
#&& docker-php-ext-install pspell \
84+
#&& docker-php-ext-install $mc pspell \
8485
#&& :\
8586
#&& apt-get install -y librecode0 \
8687
#&& apt-get install -y librecode-dev \
87-
#&& docker-php-ext-install recode \
88+
#&& docker-php-ext-install $mc recode \
8889
#&& :\
8990
#&& apt-get install -y libtidy-dev \
90-
#&& docker-php-ext-install tidy \
91+
#&& docker-php-ext-install $mc tidy \
9192
#&& :\
9293
#&& apt-get install -y libgmp-dev \
9394
#&& ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \
94-
#&& docker-php-ext-install gmp \
95+
#&& docker-php-ext-install $mc gmp \
9596
#&& :\
9697
#&& apt-get install -y postgresql-client \
9798
#&& apt-get install -y mysql-client \
9899
#&& :\
99100
#&& apt-get install -y libc-client-dev \
100101
#&& docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
101-
#&& docker-php-ext-install imap \
102+
#&& docker-php-ext-install $mc imap \
102103
#&& :\
103104
#&& apt-get install -y libldb-dev \
104105
#&& apt-get install -y libldap2-dev \
105106
#&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu \
106-
#&& docker-php-ext-install ldap \
107+
#&& docker-php-ext-install $mc ldap \
107108
#&& :\
108109
#&& apt-get install -y libmagickwand-dev \
109110
#&& pecl install imagick-3.4.3 \

docker-compose.yml

+9-21
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ services:
1212
- ./log/:/var/log/dnmp/:rw
1313
restart: always
1414
networks:
15-
- net-php72
16-
- net-php56
17-
- net-php54
15+
- default
1816

1917
php72:
2018
build:
@@ -33,9 +31,7 @@ services:
3331
cap_add:
3432
- SYS_PTRACE
3533
networks:
36-
- net-php72
37-
- net-mysql
38-
- net-redis
34+
- default
3935

4036
php56:
4137
build:
@@ -54,9 +50,7 @@ services:
5450
cap_add:
5551
- SYS_PTRACE
5652
networks:
57-
- net-php56
58-
- net-mysql
59-
- net-redis
53+
- default
6054

6155
php54:
6256
build:
@@ -74,9 +68,7 @@ services:
7468
cap_add:
7569
- SYS_PTRACE
7670
networks:
77-
- net-php54
78-
- net-mysql
79-
- net-redis
71+
- default
8072

8173
mysql:
8274
image: mysql:8.0
@@ -87,15 +79,15 @@ services:
8779
- ./mysql/:/var/lib/mysql/:rw
8880
restart: always
8981
networks:
90-
- net-mysql
82+
- default
9183
environment:
9284
MYSQL_ROOT_PASSWORD: "123456"
9385

9486
redis:
9587
image: redis:4.0
9688
restart: always
9789
networks:
98-
- net-redis
90+
- default
9991
ports:
10092
- "6379:6379"
10193

@@ -104,7 +96,7 @@ services:
10496
ports:
10597
- "8080:80"
10698
networks:
107-
- net-mysql
99+
- default
108100
environment:
109101
- PMA_HOST=mysql
110102
- PMA_PORT=3306
@@ -114,14 +106,10 @@ services:
114106
ports:
115107
- "8081:80"
116108
networks:
117-
- net-redis
109+
- default
118110
environment:
119111
- REDIS_1_HOST=redis
120112
- REDIS_1_PORT=6379
121113

122114
networks:
123-
net-php72:
124-
net-php56:
125-
net-php54:
126-
net-mysql:
127-
net-redis:
115+
default:

extensions/install.sh

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
echo "============================================"
4-
echo "The exact version of php is $PHP_VERSION"
4+
echo "Building extensions for $PHP_VERSION"
55
echo "============================================"
66

77
function getPHPVersion() {
@@ -14,18 +14,24 @@ function getPHPVersion() {
1414

1515
version=$(getPHPVersion)
1616

17+
# Use multicore compilation if php version greater than 5.4
18+
if [ ${version} -ge 50600 ]; then
19+
export mc="-j$(nproc)";
20+
fi
21+
22+
1723
# Mcrypt was DEPRECATED in PHP 7.1.0, and REMOVED in PHP 7.2.0.
1824
if [ ${version} -lt 70200 ]; then
1925
apt-get install -y libmcrypt-dev \
20-
&& docker-php-ext-install mcrypt
26+
&& docker-php-ext-install $mc mcrypt
2127
fi
2228

2329
# From PHP 5.6, we can use docker-php-ext-install to install opcache
2430
if [ ${version} -lt 50600 ]; then
2531
cd /tmp/extensions \
2632
&& mkdir zendopcache \
2733
&& tar -xf zendopcache-7.0.5.tgz -C zendopcache --strip-components=1 \
28-
&& ( cd zendopcache && phpize && ./configure && make && make install ) \
34+
&& ( cd zendopcache && phpize && ./configure && make $mc && make install ) \
2935
&& docker-php-ext-enable opcache
3036

3137
else
@@ -36,7 +42,7 @@ if [ "$REDIS_VERSION" != "false" ]; then
3642
cd /tmp/extensions \
3743
&& mkdir redis \
3844
&& tar -xf redis-${REDIS_VERSION}.tgz -C redis --strip-components=1 \
39-
&& ( cd redis && phpize && ./configure && make && make install ) \
45+
&& ( cd redis && phpize && ./configure && make $mc && make install ) \
4046
&& docker-php-ext-enable redis
4147
fi
4248

@@ -45,7 +51,7 @@ if [ "$XDEBUG_VERSION" != "false" ]; then
4551
cd /tmp/extensions \
4652
&& mkdir xdebug \
4753
&& tar -xf xdebug-${XDEBUG_VERSION}.tgz -C xdebug --strip-components=1 \
48-
&& ( cd xdebug && phpize && ./configure && make && make install ) \
54+
&& ( cd xdebug && phpize && ./configure && make $mc && make install ) \
4955
&& docker-php-ext-enable xdebug
5056
fi
5157

@@ -54,6 +60,6 @@ if [ "$SWOOLE_VERSION" != "false" ]; then
5460
cd /tmp/extensions \
5561
&& mkdir swoole \
5662
&& tar -xf swoole-${SWOOLE_VERSION}.tgz -C swoole --strip-components=1 \
57-
&& ( cd swoole && phpize && ./configure && make && make install ) \
63+
&& ( cd swoole && phpize && ./configure && make $mc && make install ) \
5864
&& docker-php-ext-enable swoole
5965
fi

0 commit comments

Comments
 (0)