diff --git a/.docker/php53/Dockerfile b/.docker/php53/Dockerfile index 99ca06bf0..7357b4e48 100644 --- a/.docker/php53/Dockerfile +++ b/.docker/php53/Dockerfile @@ -1,14 +1,26 @@ -FROM buildpack-deps:jessie +FROM buildpack-deps:jessie as php53 ENV PHP_VERSION 5.3.29 +RUN set -eux; \ + codename='jessie'; \ + { \ + echo "deb http://archive.debian.org/debian ${codename} main"; \ + echo "deb http://archive.debian.org/debian ${codename}-backports main"; \ + echo "deb http://archive.debian.org/debian-security ${codename}/updates main"; \ + } > /etc/apt/sources.list; + # php 5.3 needs older autoconf RUN set -eux; \ + \ + buildDeps=' \ + autoconf2.13 \ + '; \ \ apt-get update; \ - apt-get install -y \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ curl \ - autoconf2.13 \ + $buildDeps \ ; \ rm -r /var/lib/apt/lists/*; \ \ @@ -18,7 +30,7 @@ RUN set -eux; \ dpkg -i bison_2.7.1.dfsg-1_amd64.deb; \ rm *.deb; \ \ - curl -sSLf "https://php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror" -o php.tar.bz2; \ + curl --insecure -sSLf "https://php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror" -o php.tar.bz2; \ echo 'c4e1cf6972b2a9c7f2777a18497d83bf713cdbecabb65d3ff62ba441aebb0091 php.tar.bz2' | sha256sum -cw --status; \ \ mkdir -p /usr/src/php; \ @@ -29,29 +41,154 @@ RUN set -eux; \ ./buildconf --force; \ ./configure --disable-cgi \ $(command -v apxs2 > /dev/null 2>&1 && echo '--with-apxs2' || true) \ + --with-config-file-path=/usr/local/etc/php \ + --with-config-file-scan-dir=/usr/local/etc/php/conf.d \ + --with-libdir=lib/x86_64-linux-gnu \ --with-pdo-mysql \ --with-zlib \ + --enable-zip \ --enable-mbstring \ + --with-openssl=/usr \ + --enable-mysqlnd \ + --with-curl \ + --with-readline \ + --enable-ftp \ ; \ make -j"$(nproc)"; \ make install; \ + install -d /usr/local/etc/php/conf.d; \ \ dpkg -r \ bison \ libbison-dev \ ; \ - apt-get purge -y --auto-remove \ - autoconf2.13 \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + $buildDeps \ ; \ - rm -r /usr/src/php + rm -r /usr/src/php; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + rm -r /tmp/pear; \ + :; + +RUN set -eux; \ + { \ + echo '#! /bin/sh -eu'; \ + echo ''; \ + echo 'echo "extension=${1}.so" > "/usr/local/etc/php/conf.d/docker-php-ext-${1}.ini";'; \ + } | tee /usr/local/bin/docker-php-ext-enable; \ + \ + chmod +x /usr/local/bin/docker-php-ext-enable; \ + :; + +CMD ["php", "-a"] + +FROM php53 # Install APC PHP extension # +ARG APC_VERSION RUN set -eux; \ \ - pecl install apc-3.1.13; \ - echo 'extension=apc.so' >> /usr/local/lib/php.ini; \ + packageName=apc; \ + packageVersion=${APC_VERSION}; \ + packageFile=APC-${packageVersion}.tgz; \ + \ + if test x"3.1.13" = x"${packageVersion}"; then \ + packageSha256sum=5ef8ba07729e72946e95951672a5378bed98cb5a294e79bf0f0a97ac62829abd; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ \ - rm -r /tmp/pear; + rm -r /tmp/pear; \ + :; -CMD ["php", "-a"] +# Install memcache PHP extension +# +ARG MEMCACHE_VERSION +RUN set -eux; \ + \ + packageName=memcache; \ + packageVersion=${MEMCACHE_VERSION}; \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"3.0.8" = x"${packageVersion}"; then \ + packageSha256sum=2cae5b423ffbfd33a259829849f6000d4db018debe3e29ecf3056f06642e8311; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ + buildDeps=' \ + libzip-dev \ + '; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + $buildDeps \ + ; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ + \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + $buildDeps \ + ; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + rm -r /tmp/pear + +# Install composer +# +RUN set -eux; \ + composerVersion='1.10.27'; \ + installerUrl='https://raw.githubusercontent.com/composer/getcomposer.org/a19025d6c0a1ff9fc1fac341128b2823193be462/web/installer'; \ + \ + curl --insecure -sSLf "${installerUrl}" -o /usr/local/bin/composer-installer.php; \ + echo '203196aedb1a3b0f563363796bbf6f647a4f8c2419bc1dfc5aa45adc1725025d /usr/local/bin/composer-installer.php' \ + | sha256sum -cw --status; \ + \ + { \ + echo '#! /usr/bin/env php'; \ + cat /usr/local/bin/composer-installer.php; \ + } > /usr/local/bin/composer-installer; \ + rm /usr/local/bin/composer-installer.php; \ + chmod +x /usr/local/bin/composer-installer; \ + \ + composer-installer \ + --disable-tls \ + --version="${composerVersion}" \ + --filename=composer \ + --install-dir=/usr/local/bin \ + ; \ + \ + echo '230d28fb29f3c6c07ab2382390bef313e36de17868b2bd23b2e070554cae23d2 /usr/local/bin/composer' \ + | sha256sum -cw --status; \ + \ + composer --version; \ + \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + git \ + ; \ + rm -r /var/lib/apt/lists/*; \ + :; diff --git a/.docker/php54/Dockerfile b/.docker/php54/Dockerfile index ef5acfd0e..e7b624265 100644 --- a/.docker/php54/Dockerfile +++ b/.docker/php54/Dockerfile @@ -1,34 +1,135 @@ FROM php:5.4-cli +RUN set -eux; \ + codename='jessie'; \ + { \ + echo "deb http://archive.debian.org/debian ${codename} main"; \ + echo "deb http://archive.debian.org/debian ${codename}-backports main"; \ + echo "deb http://archive.debian.org/debian-security ${codename}/updates main"; \ + } > /etc/apt/sources.list; + +RUN set -eux; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + ca-certificates \ + ; \ + \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + :; + RUN docker-php-ext-install pdo RUN docker-php-ext-install pdo_mysql RUN docker-php-ext-install mbstring # Install APC PHP extension # +ARG APC_VERSION RUN set -eux; \ - pecl install apc-3.1.13; \ - docker-php-ext-enable apc; \ - rm -r /tmp/pear; + \ + packageName=apc; \ + packageVersion=${APC_VERSION}; \ + packageFile=APC-${packageVersion}.tgz; \ + \ + if test x"3.1.13" = x"${packageVersion}"; then \ + packageSha256sum=5ef8ba07729e72946e95951672a5378bed98cb5a294e79bf0f0a97ac62829abd; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ + \ + rm -r /tmp/pear; \ + :; # Install memcache PHP extension # ARG MEMCACHE_VERSION RUN set -eux; \ + \ + packageName=memcache; \ + packageVersion=${MEMCACHE_VERSION}; \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"3.0.8" = x"${packageVersion}"; then \ + packageSha256sum=2cae5b423ffbfd33a259829849f6000d4db018debe3e29ecf3056f06642e8311; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ buildDeps=' \ libzip-dev \ '; \ apt-get update; \ - apt-get install -y --no-upgrade --no-install-recommends \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ $buildDeps \ ; \ \ - pecl install memcache-${MEMCACHE_VERSION}; \ - docker-php-ext-enable memcache; \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + docker-php-ext-enable ${packageName}; \ + \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ $buildDeps \ ; \ apt-get clean; \ rm -rf /var/lib/apt/lists/*; \ rm -r /tmp/pear + +# Install composer +# +RUN set -eux; \ + composerVersion='1.10.27'; \ + installerUrl='https://raw.githubusercontent.com/composer/getcomposer.org/a19025d6c0a1ff9fc1fac341128b2823193be462/web/installer'; \ + \ + curl --insecure -sSLf "${installerUrl}" -o /usr/local/bin/composer-installer.php; \ + echo '203196aedb1a3b0f563363796bbf6f647a4f8c2419bc1dfc5aa45adc1725025d /usr/local/bin/composer-installer.php' \ + | sha256sum -cw --status; \ + \ + { \ + echo '#! /usr/bin/env php'; \ + cat /usr/local/bin/composer-installer.php; \ + } > /usr/local/bin/composer-installer; \ + rm /usr/local/bin/composer-installer.php; \ + chmod +x /usr/local/bin/composer-installer; \ + \ + composer-installer \ + --disable-tls \ + --version="${composerVersion}" \ + --filename=composer \ + --install-dir=/usr/local/bin \ + ; \ + \ + echo '230d28fb29f3c6c07ab2382390bef313e36de17868b2bd23b2e070554cae23d2 /usr/local/bin/composer' \ + | sha256sum -cw --status; \ + \ + composer --version; \ + \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + git \ + libzip-dev \ + unzip \ + ; \ + rm -r /var/lib/apt/lists/*; \ + \ + docker-php-ext-install zip; \ + :; diff --git a/.docker/php55_71/Dockerfile b/.docker/php55_71/Dockerfile index 1aa2171a3..49f5740f4 100644 --- a/.docker/php55_71/Dockerfile +++ b/.docker/php55_71/Dockerfile @@ -1,6 +1,24 @@ ARG PHP_TAG FROM php:${PHP_TAG} +RUN set -eux; \ + codename='jessie'; \ + { \ + echo "deb http://archive.debian.org/debian ${codename} main"; \ + echo "deb http://archive.debian.org/debian ${codename}-backports main"; \ + echo "deb http://archive.debian.org/debian-security ${codename}/updates main"; \ + } > /etc/apt/sources.list; + +RUN set -eux; \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + ca-certificates \ + ; \ + \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; \ + :; + RUN docker-php-ext-install pdo RUN docker-php-ext-install pdo_mysql RUN docker-php-ext-install mbstring @@ -10,31 +28,117 @@ RUN docker-php-ext-install mbstring ARG APCU_VERSION RUN set -eux; \ \ - test x"" = x"${APCU_VERSION}" || { \ - pecl install apcu-${APCU_VERSION}; \ - docker-php-ext-enable apcu; \ - \ - rm -r /tmp/pear; \ - } + packageName=apcu; \ + packageVersion=${APCU_VERSION}; \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"4.0.11" = x"${packageVersion}"; then \ + packageSha256sum=454f302ec13a6047ca4c39e081217ce5a61bbea815aec9c1091fb849e70b4d00; \ + else :; fi; \ + \ + if test x"5.1.23" = x"${packageVersion}"; then \ + packageSha256sum=67ee7464ccad2335c3fa4aeb0b8edbcf6d8344feea7922620c6a13015d604482; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ + \ + rm -r /tmp/pear; \ + :; # Install memcache PHP extension # ARG MEMCACHE_VERSION RUN set -eux; \ + \ + packageName=memcache; \ + packageVersion=${MEMCACHE_VERSION}; \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"3.0.8" = x"${packageVersion}"; then \ + packageSha256sum=2cae5b423ffbfd33a259829849f6000d4db018debe3e29ecf3056f06642e8311; \ + else :; fi; \ + \ + if test x"4.0.5.2" = x"${packageVersion}"; then \ + packageSha256sum=7b7667813baea003671f174bbec849e43ff235a8ea4ab7e36c3a0380c2a9ed63; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ buildDeps=' \ libzip-dev \ '; \ apt-get update; \ - apt-get install -y --no-upgrade --no-install-recommends \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ $buildDeps \ ; \ \ - pecl install memcache-${MEMCACHE_VERSION}; \ - docker-php-ext-enable memcache; \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + docker-php-ext-enable ${packageName}; \ + \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ $buildDeps \ ; \ apt-get clean; \ rm -rf /var/lib/apt/lists/*; \ rm -r /tmp/pear + +# Install composer +# +RUN set -eux; \ + composerVersion='1.10.27'; \ + installerUrl='https://raw.githubusercontent.com/composer/getcomposer.org/a19025d6c0a1ff9fc1fac341128b2823193be462/web/installer'; \ + \ + curl --insecure -sSLf "${installerUrl}" -o /usr/local/bin/composer-installer.php; \ + echo '203196aedb1a3b0f563363796bbf6f647a4f8c2419bc1dfc5aa45adc1725025d /usr/local/bin/composer-installer.php' \ + | sha256sum -cw --status; \ + \ + { \ + echo '#! /usr/bin/env php'; \ + cat /usr/local/bin/composer-installer.php; \ + } > /usr/local/bin/composer-installer; \ + rm /usr/local/bin/composer-installer.php; \ + chmod +x /usr/local/bin/composer-installer; \ + \ + composer-installer \ + --disable-tls \ + --version="${composerVersion}" \ + --filename=composer \ + --install-dir=/usr/local/bin \ + ; \ + \ + echo '230d28fb29f3c6c07ab2382390bef313e36de17868b2bd23b2e070554cae23d2 /usr/local/bin/composer' \ + | sha256sum -cw --status; \ + \ + composer --version; \ + \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + git \ + libzip-dev \ + unzip \ + ; \ + rm -r /var/lib/apt/lists/*; \ + \ + docker-php-ext-install zip; \ + :; diff --git a/.docker/php72_73/Dockerfile b/.docker/php72_73/Dockerfile index 69353468b..ebbaef7b3 100644 --- a/.docker/php72_73/Dockerfile +++ b/.docker/php72_73/Dockerfile @@ -10,29 +10,67 @@ RUN docker-php-ext-install mbstring ARG APCU_VERSION RUN set -eux; \ \ - test x"" = x"${APCU_VERSION}" || { \ - pecl install apcu-${APCU_VERSION}; \ - docker-php-ext-enable apcu; \ - \ - rm -r /tmp/pear; \ - } + packageName=apcu; \ + packageVersion=${APCU_VERSION}; \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"5.1.23" = x"${packageVersion}"; then \ + packageSha256sum=67ee7464ccad2335c3fa4aeb0b8edbcf6d8344feea7922620c6a13015d604482; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ + \ + rm -r /tmp/pear; \ + :; # Install memcache PHP extension # ARG MEMCACHE_VERSION RUN set -eux; \ + \ + packageName=memcache; \ + packageVersion=${MEMCACHE_VERSION}; \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"4.0.5.2" = x"${packageVersion}"; then \ + packageSha256sum=7b7667813baea003671f174bbec849e43ff235a8ea4ab7e36c3a0380c2a9ed63; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ buildDeps=' \ libzip-dev \ '; \ apt-get update; \ - apt-get install -y --no-upgrade --no-install-recommends \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ $buildDeps \ ; \ \ - pecl install memcache-${MEMCACHE_VERSION}; \ - docker-php-ext-enable memcache; \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + docker-php-ext-enable ${packageName}; \ + \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ $buildDeps \ ; \ apt-get clean; \ @@ -54,3 +92,43 @@ RUN set -eux; \ \ file /bin/ls --mime | grep application/x-executable; \ :; + +# Install composer +# +RUN set -eux; \ + composerVersion='1.10.27'; \ + installerUrl='https://raw.githubusercontent.com/composer/getcomposer.org/a19025d6c0a1ff9fc1fac341128b2823193be462/web/installer'; \ + \ + curl --insecure -sSLf "${installerUrl}" -o /usr/local/bin/composer-installer.php; \ + echo '203196aedb1a3b0f563363796bbf6f647a4f8c2419bc1dfc5aa45adc1725025d /usr/local/bin/composer-installer.php' \ + | sha256sum -cw --status; \ + \ + { \ + echo '#! /usr/bin/env php'; \ + cat /usr/local/bin/composer-installer.php; \ + } > /usr/local/bin/composer-installer; \ + rm /usr/local/bin/composer-installer.php; \ + chmod +x /usr/local/bin/composer-installer; \ + \ + composer-installer \ + --disable-tls \ + --version="${composerVersion}" \ + --filename=composer \ + --install-dir=/usr/local/bin \ + ; \ + \ + echo '230d28fb29f3c6c07ab2382390bef313e36de17868b2bd23b2e070554cae23d2 /usr/local/bin/composer' \ + | sha256sum -cw --status; \ + \ + composer --version; \ + \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + git \ + libzip-dev \ + unzip \ + ; \ + rm -r /var/lib/apt/lists/*; \ + \ + docker-php-ext-install zip; \ + :; diff --git a/.docker/php74_83/Dockerfile b/.docker/php74_83/Dockerfile index a9d410dbf..2336ef90d 100644 --- a/.docker/php74_83/Dockerfile +++ b/.docker/php74_83/Dockerfile @@ -8,7 +8,7 @@ RUN docker-php-ext-install pdo_mysql # RUN set -eux; \ apt-get update; \ - apt-get install -y --no-upgrade --no-install-recommends \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ libonig-dev \ ; \ \ @@ -22,29 +22,75 @@ RUN set -eux; \ ARG APCU_VERSION RUN set -eux; \ \ - test x"" = x"${APCU_VERSION}" || { \ - pecl install apcu-${APCU_VERSION}; \ - docker-php-ext-enable apcu; \ - \ - rm -r /tmp/pear; \ - } + packageName=apcu; \ + packageVersion=${APCU_VERSION}; \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"5.1.23" = x"${packageVersion}"; then \ + packageSha256sum=67ee7464ccad2335c3fa4aeb0b8edbcf6d8344feea7922620c6a13015d604482; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ + \ + docker-php-ext-enable ${packageName}; \ + \ + rm -r /tmp/pear; \ + :; # Install memcache PHP extension # ARG MEMCACHE_VERSION RUN set -eux; \ + \ + packageName=memcache; \ + packageVersion=${MEMCACHE_VERSION}; \ + packageFile=${packageName}-${packageVersion}.tgz; \ + \ + if test x"4.0.5.2" = x"${packageVersion}"; then \ + packageSha256sum=7b7667813baea003671f174bbec849e43ff235a8ea4ab7e36c3a0380c2a9ed63; \ + else :; fi; \ + \ + if test x"8.0" = x"${packageVersion}"; then \ + packageSha256sum=defe33e6f7831d82b7283b95e14a531070531acbf21278f3f0d7050505cf3395; \ + else :; fi; \ + \ + if test x"8.2" = x"${packageVersion}"; then \ + packageSha256sum=b3f0640eacdeb9046c6c86a1546d7fb8a4e9f219e5d9a36a287e59b2dd8208e5; \ + else :; fi; \ + \ + if test x"" = x"${packageVersion}"; then \ + echo "Skip installation of ${packageName} PHP extension"; \ + return 0; \ + fi; \ + \ buildDeps=' \ libzip-dev \ '; \ apt-get update; \ - apt-get install -y --no-upgrade --no-install-recommends \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ $buildDeps \ ; \ \ - pecl install memcache-${MEMCACHE_VERSION}; \ - docker-php-ext-enable memcache; \ + curl --insecure -sSLfO https://pecl.php.net/get/${packageFile}; \ + echo "${packageSha256sum} ${packageFile}" \ + | sha256sum -cw --status; \ + \ + pecl install ${packageFile}; \ + rm ${packageFile}; \ \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ + docker-php-ext-enable ${packageName}; \ + \ + apt-get purge -y --force-yes --auto-remove -o APT::AutoRemove::RecommendsImportant=true \ $buildDeps \ ; \ apt-get clean; \ @@ -66,3 +112,43 @@ RUN set -eux; \ \ file /bin/ls --mime | grep application/x-executable; \ :; + +# Install composer +# +RUN set -eux; \ + composerVersion='1.10.27'; \ + installerUrl='https://raw.githubusercontent.com/composer/getcomposer.org/a19025d6c0a1ff9fc1fac341128b2823193be462/web/installer'; \ + \ + curl --insecure -sSLf "${installerUrl}" -o /usr/local/bin/composer-installer.php; \ + echo '203196aedb1a3b0f563363796bbf6f647a4f8c2419bc1dfc5aa45adc1725025d /usr/local/bin/composer-installer.php' \ + | sha256sum -cw --status; \ + \ + { \ + echo '#! /usr/bin/env php'; \ + cat /usr/local/bin/composer-installer.php; \ + } > /usr/local/bin/composer-installer; \ + rm /usr/local/bin/composer-installer.php; \ + chmod +x /usr/local/bin/composer-installer; \ + \ + composer-installer \ + --disable-tls \ + --version="${composerVersion}" \ + --filename=composer \ + --install-dir=/usr/local/bin \ + ; \ + \ + echo '230d28fb29f3c6c07ab2382390bef313e36de17868b2bd23b2e070554cae23d2 /usr/local/bin/composer' \ + | sha256sum -cw --status; \ + \ + composer --version; \ + \ + apt-get update; \ + apt-get install -y --force-yes --no-upgrade --no-install-recommends \ + git \ + libzip-dev \ + unzip \ + ; \ + rm -r /var/lib/apt/lists/*; \ + \ + docker-php-ext-install zip; \ + :; diff --git a/.editorconfig b/.editorconfig index 92af3f94c..078a93c60 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,8 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false -[.github/**.yml] +[*.yml] +indent_size = 2 + +[Dockerfile] indent_size = 2 -indent_style = space diff --git a/.env b/.env new file mode 100644 index 000000000..8a907cead --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +# +# Environment variables used by for running tests. +# +# Copy to `.env.local` in order to customize it. +# +DOCKER_COMPOSE='docker-compose' diff --git a/.env.dist b/.env.dist deleted file mode 100644 index c4d23d59a..000000000 --- a/.env.dist +++ /dev/null @@ -1,5 +0,0 @@ -# -# Environment variables used by docker-compose for test. -# -# Copy to `.env` in order to use it. -# diff --git a/.gitignore b/.gitignore index 3c17d4767..ebacf43f2 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ lib/plugins/sfDoctrinePlugin/test/functional/fixtures/log/ /vendor /composer.lock .php-cs-fixer.cache +/var/ +/.env.* diff --git a/README.md b/README.md index 9cf3d95cc..c944ea9f2 100644 --- a/README.md +++ b/README.md @@ -67,18 +67,9 @@ Tests test/bin/test -### For PHP 7.3 and for lowest dependencies versions? - - test/bin/test php73 lowest - -### For PHP 7.3 and for highest dependencies versions? - - test/bin/test php73 highest - -### For executing a dedicated test file? - - test/bin/test php73 highest test/unit/cache/sfAPCCacheTest.php +### Want to do specific test ? Ask help with the option. + test/bin/test --help ### When you finish your work day, do not forget to clean up your desk diff --git a/docker-compose.yml b/docker-compose.yml index b0f11aa46..e7e0f6d77 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,52 +4,19 @@ volumes: db_socket: services: - composer: - image: composer - working_dir: /app - volumes: - - .:/app - entrypoint: - - sh - - -c - - | - exec tail -f /dev/null - - php53: - build: .docker/php53 - working_dir: /app - volumes: - - .:/app - - db_socket:/var/run/mysqld - entrypoint: - - sh - - -c - - | - { - echo 'pdo_mysql.default_socket = /var/run/mysqld/mysql.sock' - echo 'memory_limit = -1' - echo 'short_open_tag = off' - echo 'magic_quotes_gpc = off' - echo 'date.timezone = "UTC"' - echo 'apc.enable_cli = on' - echo 'apc.use_request_time = 0' - } | tee -a /usr/local/lib/php.ini - - exec tail -f /dev/null - depends_on: - - db - - php54: &services_php54 + php53: &services_php build: - context: .docker/php54 + context: .docker/php53 args: MEMCACHE_VERSION: '3.0.8' - environment: - MEMCACHED_HOST: memcached + APC_VERSION: '3.1.13' working_dir: /app volumes: - .:/app - db_socket:/var/run/mysqld + environment: + COMPOSER_HOME: /app/var/cache/composer + MEMCACHED_HOST: memcached entrypoint: - sh - -c @@ -61,7 +28,7 @@ services: echo 'magic_quotes_gpc = off' echo 'date.timezone = "UTC"' echo 'apc.enable_cli = on' - echo 'apc.use_request_time = 0' + echo 'apc.use_request_time = off' } | tee -a /usr/local/etc/php/php.ini exec tail -f /dev/null @@ -69,8 +36,16 @@ services: - db - memcached + php54: + <<: *services_php + build: + context: .docker/php54 + args: + MEMCACHE_VERSION: '3.0.8' + APC_VERSION: '3.1.13' + php55: - <<: *services_php54 + <<: *services_php build: context: .docker/php55_71 args: @@ -79,7 +54,7 @@ services: APCU_VERSION: '4.0.11' php56: - <<: *services_php54 + <<: *services_php build: context: .docker/php55_71 args: @@ -88,7 +63,7 @@ services: APCU_VERSION: '4.0.11' php70: - <<: *services_php54 + <<: *services_php build: context: .docker/php55_71 args: @@ -97,7 +72,7 @@ services: APCU_VERSION: '5.1.23' php71: - <<: *services_php54 + <<: *services_php build: context: .docker/php55_71 args: @@ -105,9 +80,8 @@ services: MEMCACHE_VERSION: '4.0.5.2' APCU_VERSION: '5.1.23' - php72: - <<: *services_php54 + <<: *services_php build: context: .docker/php72_73 args: @@ -115,9 +89,8 @@ services: MEMCACHE_VERSION: '4.0.5.2' APCU_VERSION: '5.1.23' - php73: - <<: *services_php54 + <<: *services_php build: context: .docker/php72_73 args: @@ -125,9 +98,8 @@ services: MEMCACHE_VERSION: '4.0.5.2' APCU_VERSION: '5.1.23' - php74: - <<: *services_php54 + <<: *services_php build: context: .docker/php74_83 args: @@ -135,9 +107,8 @@ services: MEMCACHE_VERSION: '4.0.5.2' APCU_VERSION: '5.1.23' - php80: - <<: *services_php54 + <<: *services_php build: context: .docker/php74_83 args: @@ -145,9 +116,8 @@ services: MEMCACHE_VERSION: '8.0' APCU_VERSION: '5.1.23' - php81: - <<: *services_php54 + <<: *services_php build: context: .docker/php74_83 args: @@ -156,7 +126,7 @@ services: APCU_VERSION: '5.1.23' php82: - <<: *services_php54 + <<: *services_php build: context: .docker/php74_83 args: @@ -165,7 +135,7 @@ services: APCU_VERSION: '5.1.23' php83: - <<: *services_php54 + <<: *services_php build: context: .docker/php74_83 args: diff --git a/require_for_php8.txt b/require_for_php8.txt new file mode 100644 index 000000000..b4e981be3 --- /dev/null +++ b/require_for_php8.txt @@ -0,0 +1,2 @@ +swiftmailer/swiftmailer:^5.4.6 +egulias/email-validator:^2.1.10 diff --git a/test/bin/test b/test/bin/test index 5305c0541..d52df2823 100755 --- a/test/bin/test +++ b/test/bin/test @@ -9,81 +9,359 @@ # Example: "lowest highest" # -# Configuration -# -dependencyPreferences='highest' -skipPHPVersions='php8' +__DIR__=`dirname "$0"` +ROOT_DIR="${__DIR__}/../.." -# Commands -# -dcexec="docker-compose exec -u `id -u`:`id -g`" -installSubmodule='git submodule update --checkout --recursive --force' -composerUpdate='composer update --prefer-dist --no-suggest --optimize-autoloader' -symfonyTestSuite='data/bin/symfony symfony:test --trace' +main () +{ + importEnvironmentVariablesFromDirectory "${ROOT_DIR}" -# Parse arguments -# -phpVersions="${1-}" -dependencyPreferences="${2-${dependencyPreferences}}" -phpTestRuntime="${3-${symfonyTestSuite}}" + configureWithArguments ${1+"$@"} + + startDockerComposeServices + + populatePHPVersions + + tearDownRegisterFunction reset_submodules + tearDownRegisterFunction reset_composer_json + + runTests +} + +printHelp () +{ + cat <...] + [--dependency-preference ...] + [--php-test-runtime ] + +Options: + --help Show this screen. + --php-versions Select specific php versions. [default: ${PHP_VERSIONS}] + Examples: + php53 + 'php53 php54' + --dependency-preference Select spectific dependency preference. [default: ${DEPENDENCY_PREFERENCES}] + Allows values: + - highest + - lowest + --php-test-runtime The endpoint command to run test. [default: ${PHP_TEST_RUNTIME}] + +Files: + There are a few configuration files to control certain aspects of operation. + + /.env + This is the default configuration file read on startup. + + /.env.local + This is the custom configuration file read on startup. + To be used to extends /.env with custom configuration. + +Examples: + + * How to execute all tests on all supported PHP versions and dependencies? + + $ test/bin/test + + * How to execute all tests on specific PHP version ? + + $ test/bin/test --php-versions 'php56 php74 php82' + + * How to execute all tests on lowest and highest dependency preference ? + + $ test/bin/test --dependency-preferences 'lowest highest' + + * How to customize the PHP test runtime ? + + $ test/bin/test --php-test-runtime test/unit/config/sfConfigTest.php + + * When you finish your work day, do not forget to clean up your desk + + $ docker-compose down +EOF +} + +importEnvironmentVariablesFromDirectory () +{ + a_directory=${1} + + . "${a_directory}"/.env + + if test -r "${a_directory}"/.env.local; then + . "${a_directory}"/.env.local + else :; fi +} + +startDockerComposeServices () +{ + echo "+ ${DOCKER_COMPOSE} build" + ${DOCKER_COMPOSE} up -d --build --remove-orphans > /dev/null +} + +configureWithArguments () +{ + configureDockerComposeExecFlags + + # Commands + # + DOCKER_COMPOSE_EXEC="${DOCKER_COMPOSE} exec ${dockerComposeExecFlags}" + INSTALL_GIT_SUB_MODULE='git submodule update --checkout --recursive --force' + COMPOSER_UPDATE='composer update --prefer-dist --no-suggest --optimize-autoloader' + + # Default Options + # + DEPENDENCY_PREFERENCES='highest' + PHP_VERSIONS='php74 php81 php82 php83' + PHP_TEST_RUNTIME='data/bin/symfony symfony:test --trace' + hasHelpOption=false + + parseOperands ${1+"$@"} + + if ${hasHelpOption}; then + printHelp + + exit 0 + else :; fi +} + +configureDockerComposeExecFlags () +{ + dockerComposeExecFlags="-u `id -u`:`id -g`" + + if hasTty; then + : + else + dockerComposeExecFlags="${dockerComposeExecFlags} -T" + fi +} + +hasTty () +{ + test -t 0 || { + return 1 + } -script () + test -t 1 || { + return 1 + } + + return 0 +} + +populatePHPVersions () { - echo - echo - echo $0 ${1} ${2} - echo - ${dcexec} ${1} php data/bin/check_configuration.php - ${dcexec} ${1} php ${phpTestRuntime} + if test x'all' = x"${PHP_VERSIONS}"; then + PHP_VERSIONS=`fetchAllPHPVersions` + else :; fi } -scriptAll () +fetchAllPHPVersions () { - for dependencyPreference in ${dependencyPreferences} - do - install_${dependencyPreference} + ${DOCKER_COMPOSE} 2>/dev/null ps --services --filter status=running \ + | grep php \ + | sort +} - for phpVersion in ${phpVersions} +runTests () +{ + for dependencyPreference in ${DEPENDENCY_PREFERENCES} do - script ${phpVersion} ${dependencyPreference} + for phpVersion in ${PHP_VERSIONS} + do + runTestsForOnePhpVersionAndOneDependencyPreference ${phpVersion} ${dependencyPreference} + done done - done } -fetchAllPHPVersions () +runTestsForOnePhpVersionAndOneDependencyPreference () { - docker-compose 2>/dev/null ps --services --filter status=running \ - | grep php \ - | sort \ - | grep -v ${skipPHPVersions} + a_phpVersion=${1} + a_dependencyPreference=${2} + + echo + echo + echo $0 ${a_phpVersion} ${a_dependencyPreference} + echo + + install_${a_dependencyPreference} ${a_phpVersion} + + ${DOCKER_COMPOSE_EXEC} ${a_phpVersion} php data/bin/check_configuration.php + ${DOCKER_COMPOSE_EXEC} ${a_phpVersion} php ${PHP_TEST_RUNTIME} } install_highest () { - ${installSubmodule} --remote - ${dcexec} composer ${composerUpdate} + b_service=${1} + + ${INSTALL_GIT_SUB_MODULE} --remote + + ${DOCKER_COMPOSE_EXEC} ${b_service} ${COMPOSER_UPDATE} } install_lowest () { - reset_submodules + c_service=${1} + + reset_submodules + ${INSTALL_GIT_SUB_MODULE} - ${installSubmodule} - ${dcexec} composer ${composerUpdate} --prefer-lowest + cp "${ROOT_DIR}/composer.json" "${ROOT_DIR}/composer.json~" + + if test 80 -le `echo "${c_service}" | sed 's/^php//'`; then + c_depFlags=`cat ${ROOT_DIR}/require_for_php8.txt` + + ${DOCKER_COMPOSE_EXEC} ${c_service} ${COMPOSER_REQUIRE} ${c_depFlags} --prefer-lowest --update-with-all-dependencies + else + ${DOCKER_COMPOSE_EXEC} ${c_service} ${COMPOSER_UPDATE} --prefer-lowest + fi + + reset_composer_json +} + +reset_composer_json () +{ + if test -f "${ROOT_DIR}/composer.json~"; then + mv "${ROOT_DIR}/composer.json~" "${ROOT_DIR}/composer.json" + else :; fi } reset_submodules () { - git submodule deinit --force --quiet -- . + git submodule deinit --force --quiet -- . + + git submodule init +} + +parseOperands () +{ + parseOperands_init + + for parseOperands_currentOperand + do + if parseOperands_previousOptionNeedsValue; then + parseOperands_assignValueToVariableToSet + + continue + else :; fi + + parseOperands_extractValueFromCurrentOperand + + case ${parseOperands_endOfOptions}${parseOperands_currentOperand} in #( + --) + parseOperands_endOfOptions='yes' + ;; #( + --help) + hasHelpOption=${optionValue} + ;; #( + --php-versions) + variableToSet=PHP_VERSIONS + ;; #( + --php-versions=*) + PHP_VERSIONS=${optionValue} + ;; #( + --dependency-preferences) + variableToSet=DEPENDENCY_PREFERENCES + ;; #( + --dependency-preferences=*) + DEPENDENCY_PREFERENCES=${optionValue} + ;; #( + --php-test-runtime) + variableToSet=PHP_TEST_RUNTIME + ;; #( + --php-test-runtime=*) + PHP_TEST_RUNTIME=${optionValue} + ;; #( + # --flag-option) + # hasFlagOption=${optionValue} + # ;; #( + # --value-option) + # variableToSet=valueOption + # ;; #( + # --value-option=*) + # valueOption=${optionValue} + # ;; #( + -*) + : + ;; #( + *) + parseOperands_argumentPosition=`expr 1 \+ ${parseOperands_argumentPosition}` + + case ${parseOperands_argumentPosition} in #( + # 1) + # firstArgument=${parseOperands_currentOperand} + # ;; #( + *) + : + ;; + esac + ;; + esac + done +} + +parseOperands_init () +{ + variableToSet= + optionValue= - git submodule init + parseOperands_endOfOptions= + parseOperands_argumentPosition=0 + parseOperands_operandEnabledValue=':' } -echo '+ docker-compose build' -docker-compose up -d --build --remove-orphans > /dev/null +parseOperands_assignValueToVariableToSet () +{ + eval ${variableToSet}=\"${parseOperands_currentOperand}\" + + variableToSet= +} -test x"" != x"${phpVersions}" || { - phpVersions=`fetchAllPHPVersions` +parseOperands_previousOptionNeedsValue () +{ + test x != x"${variableToSet}" +} + +parseOperands_extractValueFromCurrentOperand () +{ + case ${parseOperands_currentOperand} in #( + ?*=?*) + optionValue=`expr X"${parseOperands_currentOperand}" : X'[^=]*=\(.*\)'` + ;; #( + ?*=) + optionValue= + ;; #( + *) + optionValue=${parseOperands_operandEnabledValue} + ;; + esac +} + +tearDownRegisterFunction() +{ + test x"" != x"${tearDown_functions-}" || { + trap 'tearDown' 2 # CTRL-C + trap 'tearDown' QUIT TERM EXIT INT KILL SEGV + } + + case ${tearDown_functions-} in #( + ?*) tearDown_functions="${tearDown_functions} $1" ;; #( + *) tearDown_functions=$1 ;; + esac +} + +tearDown() +{ + test x"" != x"${tearDown_functions-}" || { + return 0 + } + + for tearDown_function in ${tearDown_functions} + do + ${tearDown_function} + done } -scriptAll +main ${1+"$@"}