Skip to content

Commit

Permalink
Use official meminfo git repo again
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Nov 27, 2020
1 parent c537d64 commit a815933
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 4 deletions.
23 changes: 22 additions & 1 deletion Dockerfile-nts-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ RUN git fetch \
cp "$EXTENSION_DIR/uv.so" /uv.so
RUN sha256sum /uv.so

## Build ext-meminfo
FROM php:7.4-cli-alpine3.11 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.4-cli-alpine3.11 AS nts-root

# Build-time metadata as defined at http://label-schema.org
Expand Down Expand Up @@ -85,7 +98,15 @@ RUN touch /.you-are-in-a-wyrihaximus.net-php-docker-image-dev
# Install docker help scripts
COPY src/php/utils/docker/alpine/ /usr/local/bin/

RUN apk add --no-cache \
# Copy in meminfo extension
RUN true
COPY --from=build-meminfo /meminfo.so /meminfo.so
RUN true

RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` \
&& mv /*.so "$EXTENSION_DIR/" \
&& docker-php-ext-enable meminfo\
&& apk add --no-cache \
make \
git \
openssh-client \
Expand Down
23 changes: 22 additions & 1 deletion Dockerfile-nts-debian
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ RUN git fetch \
cp "$EXTENSION_DIR/uv.so" /uv.so
RUN sha256sum /uv.so

## Build ext-meminfo
FROM php:7.4-zts-alpine3.11 AS build-meminfo
RUN apk update && \
yes | apt-get install $PHPIZE_DEPS git && \
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.4-cli-buster AS nts-root

# Build-time metadata as defined at http://label-schema.org
Expand Down Expand Up @@ -95,7 +108,15 @@ RUN touch /.you-are-in-a-wyrihaximus.net-php-docker-image-dev
# Install docker help scripts
COPY src/php/utils/docker/ /usr/local/bin/

RUN apt-get update \
# Copy in meminfo extension
RUN true
COPY --from=build-meminfo /meminfo.so /meminfo.so
RUN true

RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` \
&& mv /*.so "$EXTENSION_DIR/" \
&& docker-php-ext-enable meminfo \
&& apt-get update \
&& yes | apt-get install \
make \
git \
Expand Down
23 changes: 22 additions & 1 deletion Dockerfile-zts-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ RUN git fetch \
cp "$EXTENSION_DIR/uv.so" /uv.so
RUN sha256sum /uv.so

## Build ext-meminfo
FROM php:7.4-zts-alpine3.11 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.4-zts-alpine3.11 AS zts-root

# Build-time metadata as defined at http://label-schema.org
Expand Down Expand Up @@ -92,7 +105,15 @@ RUN touch /.you-are-in-a-wyrihaximus.net-php-docker-image-dev
# Install docker help scripts
COPY src/php/utils/docker/alpine/ /usr/local/bin/

RUN apk add --no-cache \
# Copy in meminfo extension
RUN true
COPY --from=build-meminfo /meminfo.so /meminfo.so
RUN true

RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` \
&& mv /*.so "$EXTENSION_DIR/" \
&& docker-php-ext-enable meminfo \
&& apk add --no-cache \
make \
git \
openssh-client \
Expand Down
23 changes: 22 additions & 1 deletion Dockerfile-zts-debian
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ RUN git fetch \
cp "$EXTENSION_DIR/uv.so" /uv.so
RUN sha256sum /uv.so

## Build ext-meminfo
FROM php:7.4-zts-alpine3.11 AS build-meminfo
RUN apk update && \
yes | apt-get install $PHPIZE_DEPS git && \
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.4-zts-buster AS zts-root

# Build-time metadata as defined at http://label-schema.org
Expand Down Expand Up @@ -111,7 +124,15 @@ RUN touch /.you-are-in-a-wyrihaximus.net-php-docker-image-dev
# Install docker help scripts
COPY src/php/utils/docker/ /usr/local/bin/

RUN apt-get update \
# Copy in meminfo extension
RUN true
COPY --from=build-meminfo /meminfo.so /meminfo.so
RUN true

RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` \
&& mv /*.so "$EXTENSION_DIR/" \
&& docker-php-ext-enable meminfo \
&& apt-get update \
&& yes | apt-get install \
make \
git \
Expand Down
23 changes: 23 additions & 0 deletions test/container/functional/meminfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

const MEMINFO_DUMP_FILE = '/tmp/my_dump_file.json';

meminfo_dump(fopen(MEMINFO_DUMP_FILE, 'w'));

sleep(1);

if (!file_exists(MEMINFO_DUMP_FILE)) {
exit(1);
}

$json = json_decode(file_get_contents(MEMINFO_DUMP_FILE), true);

if (!is_array($json)) {
exit(1);
}

if (count($json) === 0) {
exit(1);
}

echo 'meminfo';
16 changes: 16 additions & 0 deletions test/container/test_php_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,19 @@ def test_configuration_is_not_effective(host):
configuration = host.run('php -i').stdout

assert u'expose_php => Off => Off' in configuration

@pytest.mark.php_dev
def test_php_meminfo_is_enabled(host):
output = host.run('if [ $(php -v | grep 7.4 | wc -l) != 0 ] ; then php -r "echo(\'meminfo\');"; else php -r "exit(function_exists(\'meminfo_dump\') ? 0 : 255);"; fi')
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

@pytest.mark.php_dev
def test_php_ext_meminfo_is_functional(host):
output = host.run('if [ $(php -v | grep 7.4 | wc -l) != 0 ] ; then php -r "echo(\'meminfo\');"; else php /tests/container/functional/meminfo.php; fi')
assert output.stdout == 'meminfo'
assert output.rc == 0
4 changes: 4 additions & 0 deletions test/container/test_php_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def test_gmp_is_loaded(host):
def test_iconv_is_loaded(host):
assert 'iconv' in host.run('php -m').stdout

@pytest.mark.php_dev
def test_meminfo_is_loaded(host):
assert 'meminfo' in host.run('php -m').stdout

@pytest.mark.php_zts
def test_parallel_is_loaded(host):
assert 'parallel' in host.run('php -m').stdout
Expand Down

0 comments on commit a815933

Please sign in to comment.