From 9cc463e7599de15c55c984604859cda672d512a3 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Mon, 13 May 2019 23:06:58 +0200 Subject: [PATCH] # This is a combination of 4 commits. # This is the 1st commit message: # This is a combination of 2 commits. # This is the 1st commit message: Add ext-meminfo to -dev images # The commit message #2 will be skipped: # Test for ext-meminfo existence on -dev images # The commit message #2 will be skipped: # Test for ext-meminfo existence on -dev images # The commit message #3 will be skipped: # expose_php=off # The commit message #4 will be skipped: # Add missing helper script on NTS --- Dockerfile-nts | 23 ++++++++++++++++++++++- Dockerfile-zts | 20 +++++++++++++++++++- src/php/conf/default.ini | 1 + test-nts.sh | 2 +- test-zts.sh | 2 +- test/container/test_php_dev.py | 10 ++++++++++ 6 files changed, 54 insertions(+), 4 deletions(-) diff --git a/Dockerfile-nts b/Dockerfile-nts index 11052afc..c5fd4ec4 100644 --- a/Dockerfile-nts +++ b/Dockerfile-nts @@ -12,7 +12,20 @@ RUN git fetch \ cp "$EXTENSION_DIR/uv.so" /uv.so RUN sha256sum /uv.so -FROM php:7.3-cli-alpine3.10 AS nts +FROM php:7.3-cli-alpine AS build-meminfo +RUN apk update && \ + apk add --no-cache $PHPIZE_DEPS git libuv-dev && \ + git clone https://github.com/BitOne/php-meminfo.git +WORKDIR /php-meminfo/extension/php7 +RUN phpize +RUN ./configure --enable-meminfo +RUN make install +RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \ + cp "$EXTENSION_DIR/meminfo.so" /meminfo.so +RUN sha256sum /meminfo.so + +FROM php:7.3-alpine AS nts + RUN set -x \ && addgroup -g 1000 app \ && adduser -u 1000 -D -G app app @@ -75,6 +88,14 @@ RUN apk add \ bash \ strace +# Install docker help scripts +COPY src/php/utils/docker/ /usr/local/bin/ + +COPY --from=build-meminfo /meminfo.so /meminfo.so +RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \ + mv /*.so "$EXTENSION_DIR/" && \ + docker-php-ext-enable meminfo + # Install Xdebug and development specific configuration RUN docker-php-dev-mode xdebug \ && docker-php-dev-mode config diff --git a/Dockerfile-zts b/Dockerfile-zts index 18bb8873..a5e73cdf 100644 --- a/Dockerfile-zts +++ b/Dockerfile-zts @@ -26,7 +26,20 @@ RUN git fetch \ cp "$EXTENSION_DIR/uv.so" /uv.so RUN sha256sum /uv.so -FROM php:7.3-zts-alpine3.10 AS zts +FROM php:7.3-zts-alpine AS build-meminfo +RUN apk update && \ + apk add --no-cache $PHPIZE_DEPS git libuv-dev && \ + git clone https://github.com/BitOne/php-meminfo.git +WORKDIR /php-meminfo/extension/php7 +RUN phpize +RUN ./configure --enable-meminfo +RUN make install +RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \ + cp "$EXTENSION_DIR/meminfo.so" /meminfo.so +RUN sha256sum /meminfo.so + +FROM php:7.3-zts-alpine AS zts + RUN set -x \ && addgroup -g 1000 app \ && adduser -u 1000 -D -G app app @@ -99,6 +112,11 @@ RUN apk add \ # Install docker help scripts COPY src/php/utils/docker/ /usr/local/bin/ +COPY --from=build-meminfo /meminfo.so /meminfo.so +RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \ + mv /*.so "$EXTENSION_DIR/" && \ + docker-php-ext-enable meminfo + # Install Xdebug and development specific configuration RUN docker-php-dev-mode xdebug \ && docker-php-dev-mode config diff --git a/src/php/conf/default.ini b/src/php/conf/default.ini index 494cfc81..2d4ccbfc 100644 --- a/src/php/conf/default.ini +++ b/src/php/conf/default.ini @@ -1,2 +1,3 @@ date.timezone=UTC memory_limit=-1 +expose_php=off \ No newline at end of file diff --git a/test-nts.sh b/test-nts.sh index 8cfb90c2..c363dfae 100755 --- a/test-nts.sh +++ b/test-nts.sh @@ -16,7 +16,7 @@ declare TEST_SUITE if [[ $DOCKER_TAG == *"-dev" ]]; then TEST_SUITE="php_nts or php_dev" else - TEST_SUITE="php_nts and not php_dev" + TEST_SUITE="php_nts or php_no_dev and not php_dev" fi printf "Starting a container for '%s'\\n" "$DOCKER_TAG" diff --git a/test-zts.sh b/test-zts.sh index 271ee136..c392bf8f 100755 --- a/test-zts.sh +++ b/test-zts.sh @@ -16,7 +16,7 @@ declare TEST_SUITE if [[ $DOCKER_TAG == *"-dev" ]]; then TEST_SUITE="php_zts or php_dev" else - TEST_SUITE="php_zts and not php_dev" + TEST_SUITE="php_zts or php_no_dev and not php_dev" fi printf "Starting a container for '%s'\\n" "$DOCKER_TAG" diff --git a/test/container/test_php_dev.py b/test/container/test_php_dev.py index e5473b2d..fb9acccc 100644 --- a/test/container/test_php_dev.py +++ b/test/container/test_php_dev.py @@ -29,3 +29,13 @@ def test_configuration_is_not_effective(host): @pytest.mark.php_no_dev def test_xdebug_is_not_loaded(host): assert 'Xdebug' not in host.run('php -m').stdout + +@pytest.mark.php_dev +def test_php_meminfo_is_enabled(host): + output = host.run('php -r "exit(function_exists(\'meminfo_dump\') ? 0 : 255);"') + assert output.rc == 0 + +@pytest.mark.php_no_dev +def test_php_meminfo_is_not_enabled(host): + output = host.run('php -r "exit(function_exists(\'meminfo_dump\') ? 0 : 255);"') + assert output.rc == 255