Skip to content

Commit ea73b98

Browse files
authored
Merge pull request #14 from PHPExpertsInc/v7.0
Version 7.0: Major improvements + PHP 8.1 support
2 parents 3500871 + 8a7620a commit ea73b98

File tree

14 files changed

+131
-83
lines changed

14 files changed

+131
-83
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## v7.0.0
2+
* **[2021-11-02 15:47:49 CDT]** PHP 8.1 RC5.
3+
* **[2021-11-01 08:08:36 CDT]** Dramatically reduced total build time from 33 minutes to 11 minutes.
4+
* **[2021-11-01 06:24:52 CDT]** Embedded composer into the php container.
5+
* **[2021-11-01 06:00:30 CDT]** Run the native PHP when inside docker.
6+
* **[2021-07-29 07:13:12 CDT]** Set the PHP memory_limit to unlimited by default.
7+
* **[2021-07-29 07:07:35 CDT]** Fixed the building of xdebug.
8+
* **[2021-06-21 07:10:58 CDT]** Added git and ssh for private packages supoprt.
9+
110
## v6.6.0
211
* [2021-09-22 08:40:22 CDT] - Added the abiltiy to run commands in containers from the CLI.
312

bin/composer

-1.88 MB
Binary file not shown.

bin/php

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
44

5+
# Detect if it's running inside of docker and run it natively if it is.
6+
# @see https://stackoverflow.com/a/25518345/430062
7+
if [ "$PHP_VERSION" == "native" ] || [ -f "/.dockerenv" ]; then
8+
(/bin/env --chdir=/ php "$@")
9+
exit
10+
fi
11+
512
if [ -z "$PROJECT_NAME" ]; then
613
PROJECT_NAME=$(basename $ROOT | tr '[:upper:]' '[:lower:]' | sed "s/[^[:alpha:]-]//g")
714
fi
@@ -13,11 +20,6 @@ if [ -z "$PHP_VERSION" ]; then
1320
PHP_VERSION="7"
1421
fi
1522

16-
if [ "$PHP_VERSION" == "native" ]; then
17-
(/bin/env --chdir=/ php "$@")
18-
exit
19-
fi
20-
2123
# Test if the network exists.
2224
docker network inspect $NETWORK_NAME > /dev/null 2>&1
2325
if [ $? == 0 ]; then

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
"phpexperts/docker-phpstan": "Dockerized phpstan/phpstan",
2424
"phpexperts/docker-rector": "Dockerized rector/rector"
2525
},
26-
"bin": ["bin/php"]
26+
"bin": ["bin/php", "bin/composer"]
2727
}

docker/build-images.sh

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22

33
#PHP_VERSIONS="7.4"
44
#PHP_VERSIONS="5.6 7.0 7.1 7.2 7.3 7.4"
5-
#PHP_VERSIONS="5.6 7.0 7.1 7.2 7.3 7.4 8.0"
6-
PHP_VERSIONS="7.0 7.1 7.2 7.3 7.4 8.0"
5+
PHP_VERSIONS="5.6 7.0 7.1 7.2 7.3 7.4 8.0"
6+
#PHP_VERSIONS="7.0 7.1 7.2 7.3 7.4 8.0"
77
#PHP_VERSIONS="8.0"
88
cd images
99

10+
# Build the base linux image first.
11+
docker build linux --tag="phpexperts/linux:latest"
12+
1013
for VERSION in ${PHP_VERSIONS}; do
1114
MAJOR_VERSION=${VERSION%.*}
1215
# @TODO: Need to add support for v8.0, too.
1316
docker rm $(docker ps -aq)
14-
docker rmi --force phpexperts/php:latest
15-
docker rmi --force phpexperts/php:${MAJOR_VERSION}-debug
16-
docker rmi --force phpexperts/php:${MAJOR_VERSION}
17+
docker rmi --force phpexperts/php:latest 2> /dev/null
18+
docker rmi --force phpexperts/php:${MAJOR_VERSION}-debug 2> /dev/null
19+
docker rmi --force phpexperts/php:${MAJOR_VERSION} 2> /dev/null
20+
21+
docker rmi --force phpexperts/web:nginx-php${VERSION}-debug 2> /dev/null
22+
docker rmi --force phpexperts/web:nginx-php${VERSION}-debug 2> /dev/null
1723

1824
docker build base --tag="phpexperts/php:latest" --build-arg PHP_VERSION=$VERSION
1925
docker build base --tag="phpexperts/php:${MAJOR_VERSION}" --build-arg PHP_VERSION=$VERSION
@@ -27,7 +33,7 @@ for VERSION in ${PHP_VERSIONS}; do
2733
done
2834

2935
# docker rmi --force phpexperts/php:8 phpexperts/php:8.0 phpexperts/web:nginx-php8
30-
# docker build base-php8 --tag="phpexperts/php:8.0"
36+
# docker build base-php8 --tag="phpexperts/php:8.1"
3137
# docker build base-php8 --tag="phpexperts/php:8"
3238

3339
# docker build web-php8 --tag="phpexperts/web:nginx-php8"

docker/images/base-debug/Dockerfile

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ ARG PHP_VERSION=7.4
55

66
COPY xdebug.conf /tmp
77

8-
RUN apt-get update && \
9-
apt-get install -y php-xdebug && \
10-
8+
RUN apt-get install -y php${PHP_VERSION}-xdebug && \
9+
#
1110
# Configure XDebug
1211
cat /tmp/xdebug.conf >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini && \
1312
rm /tmp/xdebug.conf && \
14-
13+
#
1514
# Cleanup
1615
apt-get remove -y && \
1716
apt-get autoremove -y && \
18-
apt-get clean && \
19-
rm -rf /var/lib/apt/lists/*
17+
apt-get clean
18+
#rm -rf /var/lib/apt/lists/*

docker/images/base-php8/Dockerfile

+27-36
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,39 @@
11
# phpexperts/php:7
2-
FROM ubuntu:focal as intermediate
2+
FROM phpexperts/linux:latest AS intermediate
33
#FROM phpexperts/php:8.0-temp
44

5-
ARG PHP_VERSION=8.0
5+
ARG PHP_VERSION=8.1
66

77
# Fix add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56
88
ENV LC_ALL C.UTF-8
99
ENV DEBIAN_FRONTEND noninteractive
1010

11-
RUN apt-get update && \
12-
# Configure ondrej PPA
13-
apt-get install -y software-properties-common && \
14-
apt-get upgrade -y && \
15-
#
16-
# Install PHP & curl (for composer)
17-
apt-get install -y --no-install-recommends \
18-
curl \
19-
less vim inetutils-ping unzip net-tools && \
20-
#
21-
# Compile PHP 8 manuall
22-
apt-get install -y --no-install-recommends gcc g++ make && \
11+
# Compile PHP 8.1 manually
12+
RUN apt-get install -y --no-install-recommends gcc g++ make && \
2313
apt-get install -y libxml2-dev libcurl4-openssl-dev libjpeg-dev libpng-dev \
2414
libmysqlclient-dev libpq-dev libicu-dev libfreetype6-dev \
2515
libxslt-dev libssl-dev libldb-dev libedit-dev libsodium-dev \
2616
zlibc zlib1g zlib1g-dev libsqlite3-dev libgmp-dev libzip-dev \
2717
libonig-dev binutils && \
2818
#
29-
curl https://downloads.php.net/~carusogabriel/php-8.0.0RC3.tar.xz -o php.xz && \
19+
curl https://downloads.php.net/~patrickallaert/php-8.1.0RC5.tar.xz -o php.xz && \
3020
tar xvf php.xz && \
31-
cd php-8.0.0RC3 && \
21+
cd php-8.1.0RC5 && \
3222
# Build CLI
3323
./configure --enable-mbstring --with-pdo-mysql --with-pdo-pgsql --enable-mysqlnd \
3424
--enable-gd --with-gmp --enable-bcmath --with-curl --with-zip --with-openssl \
35-
--enable-sockets --with-libedit --with-sodium --enable-exif --enable-intl \
25+
--enable-sockets --disable-phpdbg --with-libedit --with-sodium --enable-exif --enable-intl \
3626
--with-mysqli --with-xsl --with-zlib --prefix=/workdir/install/usr \
37-
--with-config-file-path=/etc/php/8.0/cli --with-config-file-scan-dir=/etc/php/8.0/cli/conf.d && \
27+
--with-config-file-path=/etc/php/8.1/cli --with-config-file-scan-dir=/etc/php/8.1/cli/conf.d && \
3828
make -j8 && \
3929
make install && \
4030
# Build FPM
4131
./configure --enable-mbstring --with-pdo-mysql --with-pdo-pgsql --enable-mysqlnd \
4232
--enable-gd --with-gmp --enable-bcmath --with-curl --with-zip --with-openssl \
43-
--enable-sockets --with-libedit --with-sodium --enable-exif --enable-intl \
33+
--enable-sockets --disable-phpdbg --with-libedit --with-sodium --enable-exif --enable-intl \
4434
--with-mysqli --with-xsl --with-zlib \
4535
--enable-fpm --with-fpm-user=www-data --enable-pcntl --prefix=/workdir/install/usr \
46-
--with-config-file-path=/etc/php/8.0/fpm --with-config-file-scan-dir=/etc/php/8.0/fpm/conf.d && \
36+
--with-config-file-path=/etc/php/8.1/fpm --with-config-file-scan-dir=/etc/php/8.1/fpm/conf.d && \
4737
make -j8 && \
4838
make install && \
4939
#
@@ -52,21 +42,21 @@ RUN apt-get update && \
5242
mkdir -p /workdir/install/etc/php/${PHP_VERSION}/cli/conf.d && \
5343
mkdir -p /workdir/install/etc/php/${PHP_VERSION}/fpm/conf.d && \
5444
mkdir -p /workdir/install/etc/php/${PHP_VERSION}/fpm/pool.d && \
55-
cd /php-8.0.0RC3 && \
45+
#cd /php-8.1.0RC5 && \
5646
cp -v php.ini-development /workdir/install/etc/php/${PHP_VERSION}/cli/php.ini && \
5747
cp -v php.ini-development /workdir/install/etc/php/${PHP_VERSION}/fpm/php.ini && \
5848
cp -v ./sapi/fpm/php-fpm.conf /workdir/install/etc/php/${PHP_VERSION}/fpm/ && \
59-
cp -v ./sapi/fpm/www.conf /workdir/install/etc/php/${PHP_VERSION}/fpm/pool.d && \
49+
cp -v ./sapi/fpm/www.conf /workdir/install/etc/php/${PHP_VERSION}/fpm/pool.d
6050
#
6151
## Fix the extension_dir path (screwed up from --prefix=/workdir/install/usr):
62-
echo extension_dir=$(/workdir/install/usr/bin/php --info | grep ^extension_dir | awk '{print $3}' | sed 's#/workdir/install##') >> /workdir/install/etc/php/${PHP_VERSION}/cli/php.ini && \
52+
RUN echo extension_dir=$(/workdir/install/usr/bin/php --info | grep ^extension_dir | awk '{print $3}' | sed 's#/workdir/install##') >> /workdir/install/etc/php/${PHP_VERSION}/cli/php.ini && \
6353
echo extension_dir=$(/workdir/install/usr/bin/php --info | grep ^extension_dir | awk '{print $3}' | sed 's#/workdir/install##') >> /workdir/install/etc/php/${PHP_VERSION}/fpm/php.ini && \
6454
sed -i 's#/workdir/install##' /workdir/install/usr/bin/phpize && \
6555
#
66-
## Strip the PHP binaries to dramatically reduce the image size (583 MB to 156 MB).
67-
strip /workdir/install/usr/bin/php /workdir/install/usr/sbin/php-fpm && \
6856
## Remove the worthless php-cgi and save 64 MB.
6957
rm /workdir/install/usr/bin/php-cgi && \
58+
## Strip the PHP binaries to dramatically reduce the image size (583 MB to 156 MB).
59+
strip -v /workdir/install/usr/bin/php /workdir/install/usr/sbin/php-fpm && \
7060
#
7161
## Install PHP so that the build programs will work.
7262
cp -avf /workdir/install/* / && \
@@ -109,39 +99,40 @@ RUN apt-get update && \
10999

110100
WORKDIR /workdir
111101

112-
FROM ubuntu:focal
102+
ENTRYPOINT ["/usr/bin/bash", "-l"]
113103

114-
ARG PHP_VERSION=8.0
104+
FROM phpexperts/linux:latest
105+
106+
ARG PHP_VERSION=8.1
115107

116108
# Fix add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56
117109
ENV LC_ALL C.UTF-8
118110
ENV DEBIAN_FRONTEND noninteractive
119111

120-
COPY --from=intermediate /workdir/php-8.0-ubuntu.tar.gz /php-8.0-ubuntu.tar.gz
112+
COPY --from=intermediate /workdir/php-8.1-ubuntu.tar.gz /php-8.1-ubuntu.tar.gz
121113

122114
RUN apt-get update && \
123115
# Configure ondrej PPA
124116
apt-get install -y software-properties-common && \
125117
apt-get upgrade -y && \
126118
#
127119
# Install PHP & curl (for composer)
128-
apt-get install -y --no-install-recommends \
129-
curl \
130-
less vim inetutils-ping unzip net-tools && \
131120
# Install PHP extension dependencies
132-
apt-get install -y libpq5 libpng16-16 libonig5 libzip5 libxslt-dev zlibc zlib1g libsodium-dev libedit-dev && \
121+
apt-get install -y libpq5 libpng16-16 libonig5 libxslt-dev zlibc zlib1g libsodium-dev libedit-dev libcurl4 libzip4 && \
133122
#
134123
# Cleanup
135124
apt-get remove -y && \
136125
apt-get autoremove -y && \
137126
apt-get clean && \
138-
rm -rf /var/lib/apt/lists/* && \
139-
tar xvf php-8.0-ubuntu.tar.gz && \
140-
rm -v php-8.0-ubuntu.tar.gz
127+
# rm -rf /var/lib/apt/lists/* && \
128+
cd / && \
129+
tar xvf php-8.1-ubuntu.tar.gz && \
130+
rm -v php-8.1-ubuntu.tar.gz && \
131+
echo "Finished..."
141132

142-
VOLUME ["/workdir"]
143133
WORKDIR /workdir
144134

145135
COPY entrypoint.sh /usr/local/bin/entrypoint-php.sh
146136

147137
ENTRYPOINT ["/usr/local/bin/entrypoint-php.sh"]
138+

docker/images/base-php8/entrypoint.sh

+5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
if [ "$PHP_FPM_USER_ID" != "" ]; then
55
usermod -u $PHP_FPM_USER_ID www-data
66
fi
7+
PHP_VERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')
78

89
# Set php.ini options
910
for TYPE in cli fpm; do
1011
PHP_INI=/etc/php/${PHP_VERSION}/${TYPE}/php.ini
1112

13+
if [ "$PHP_MEMORY_LIMIT" != "" ]; then
14+
sed -i "s!memory_limit =.\+!memory_limit = $PHP_MEMORY_LIMIT!g" "$PHP_INI"
15+
fi
16+
1217
# Update the PHP upload_max_filesize setting if one was specified
1318
if [ "$PHP_UPLOAD_MAX_FILESIZE" != "" ]; then
1419
sed -i "s!upload_max_filesize = 2M!upload_max_filesize = $PHP_UPLOAD_MAX_FILESIZE!g" "$PHP_INI"

docker/images/base/Dockerfile

100644100755
+17-24
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
# phpexperts/php:7
2-
FROM ubuntu:focal
2+
FROM phpexperts/linux:latest
33

44
ARG PHP_VERSION=7.4
55

66
# Fix add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56
77
ENV LC_ALL C.UTF-8
88
ENV DEBIAN_FRONTEND noninteractive
99

10-
RUN apt-get update && \
11-
12-
# Configure ondrej PPA
13-
apt-get install -y software-properties-common && \
14-
add-apt-repository ppa:ondrej/php && \
15-
apt-get update && \
16-
apt-get upgrade -y && \
17-
18-
# Install PHP & curl (for composer)
19-
apt-get install -y --no-install-recommends \
20-
curl \
10+
RUN apt-get install -y --no-install-recommends \
2111
php${PHP_VERSION}-cli \
22-
vim inetutils-ping unzip net-tools \
23-
php${PHP_VERSION}-fpm && \
24-
apt-get install -y --no-install-recommends \
12+
php${PHP_VERSION}-fpm \
2513
php${PHP_VERSION}-bcmath \
2614
php${PHP_VERSION}-curl \
2715
php${PHP_VERSION}-dom \
@@ -44,28 +32,33 @@ RUN apt-get update && \
4432
apt-get install -y --no-install-recommends \
4533
php${PHP_VERSION}-sodium; \
4634
fi && \
47-
35+
#
4836
# Cleanup
4937
apt-get autoremove -y && \
5038
apt-get clean && \
51-
rm -rf /var/lib/apt/lists/* && \
52-
rm -rf /var/cache/apt/* && \
53-
39+
#rm -rf /var/lib/apt/lists/* && \
40+
#rm -rf /var/cache/apt/* && \
41+
#
5442
# Fix "Unable to create the PID file (/run/php/php5.6-fpm.pid).: No such file or directory (2)"
55-
mkdir -p /run/php && \
56-
43+
mkdir -p /run/php
44+
#
5745
## Configure PHP-FPM
58-
sed -i "s!display_startup_errors = Off!display_startup_errors = On!g" /etc/php/${PHP_VERSION}/fpm/php.ini && \
46+
RUN sed -i "s!display_startup_errors = Off!display_startup_errors = On!g" /etc/php/${PHP_VERSION}/fpm/php.ini && \
47+
sed -i "s!memory_limit =.\+!memory_limit = -1!g" /etc/php/${PHP_VERSION}/cli/php.ini && \
48+
sed -i "s!memory_limit =.\+!memory_limit = -1!g" /etc/php/${PHP_VERSION}/fpm/php.ini && \
5949
sed -i "s!;error_log = php_errors.log!error_log = /proc/self/fd/2!g" /etc/php/${PHP_VERSION}/fpm/php.ini && \
6050
sed -i "s!max_execution_time = 30!max_execution_time = 600!g" /etc/php/${PHP_VERSION}/fpm/php.ini && \
6151
sed -i "s!session.gc_probability = 0!session.gc_probability = 1!g" /etc/php/${PHP_VERSION}/fpm/php.ini && \
62-
52+
#
6353
sed -i "s!;daemonize = yes!daemonize = no!g" /etc/php/${PHP_VERSION}/fpm/php-fpm.conf && \
6454
sed -i "s!error_log = /var/log/php${PHP_VERSION}-fpm.log!error_log = /proc/self/fd/2!g" /etc/php/${PHP_VERSION}/fpm/php-fpm.conf && \
65-
55+
#
6656
sed -i "s!;catch_workers_output = yes!catch_workers_output = yes!g" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf && \
6757
sed -i "s!listen = /run/php/php${PHP_VERSION}-fpm.sock!listen = 0.0.0.0:9000!g" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf
6858

59+
# Install Composer
60+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && composer --version
61+
6962
VOLUME ["/workdir"]
7063
WORKDIR /workdir
7164

docker/images/base/entrypoint.sh

+10
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
if [ "$PHP_FPM_USER_ID" != "" ]; then
55
usermod -u $PHP_FPM_USER_ID www-data
66
fi
7+
PHP_VERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')
78

89
# Set php.ini options
910
for TYPE in cli fpm; do
1011
PHP_INI=/etc/php/${PHP_VERSION}/${TYPE}/php.ini
1112

13+
if [ "$PHP_MEMORY_LIMIT" != "" ]; then
14+
sed -i "s!memory_limit =.\+!memory_limit = $PHP_MEMORY_LIMIT!g" "$PHP_INI"
15+
fi
16+
1217
# Update the PHP upload_max_filesize setting if one was specified
1318
if [ "$PHP_UPLOAD_MAX_FILESIZE" != "" ]; then
1419
sed -i "s!upload_max_filesize = 2M!upload_max_filesize = $PHP_UPLOAD_MAX_FILESIZE!g" "$PHP_INI"
@@ -20,6 +25,11 @@ for TYPE in cli fpm; do
2025
fi
2126
done
2227

28+
if [ "$RUN_COMPOSER" == "1" ]; then
29+
/usr/local/bin/composer "$@"
30+
exit
31+
fi
32+
2333
if [ -z "$INTERACTIVE" ]; then
2434
/usr/bin/php "$@"
2535
else

docker/images/linux/Dockerfile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM ubuntu:focal
2+
3+
# Fix add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56
4+
ENV LC_ALL C.UTF-8
5+
ENV DEBIAN_FRONTEND noninteractive
6+
7+
RUN apt-get update && \
8+
# Configure ondrej PPA
9+
apt-get install -y software-properties-common && \
10+
add-apt-repository ppa:ondrej/php && \
11+
apt-get upgrade -y
12+
13+
# Fix add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56
14+
ENV LC_ALL C.UTF-8
15+
ENV DEBIAN_FRONTEND noninteractive
16+
17+
RUN echo "Building base Linux..." && \
18+
# Configure ondrej PPA
19+
apt-get install -y software-properties-common && \
20+
add-apt-repository ppa:ondrej/php && \
21+
apt-get update && \
22+
apt-get upgrade -y && \
23+
#
24+
# Install PHP & curl (for composer)
25+
apt-get install -y --no-install-recommends \
26+
curl git ssh \
27+
less vim inetutils-ping zip unzip net-tools
28+
29+
WORKDIR /workdir
30+
31+
ENTRYPOINT ["bash", "-l"]

0 commit comments

Comments
 (0)