Skip to content

Commit a7f7eb1

Browse files
committed
Add MrLoop event loop
1 parent a532330 commit a7f7eb1

4 files changed

Lines changed: 52 additions & 8 deletions

File tree

Dockerfile-nts-alpine

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN apk update \
2323
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
2424

2525
FROM base AS base-build
26-
RUN apk add --no-cache $PHPIZE_DEPS git libuv-dev
26+
RUN apk add --no-cache $PHPIZE_DEPS git libuv-dev liburing-dev linux-headers
2727

2828
FROM base-build AS build-uv
2929
RUN git clone https://github.com/amphp/ext-uv uv
@@ -37,9 +37,26 @@ RUN git fetch \
3737
&& cp "$EXTENSION_DIR/uv.so" /uv.so \
3838
&& sha256sum /uv.so
3939

40+
FROM base-build AS build-mrloop
41+
42+
RUN git clone https://github.com/ace411/mrloop.git /mrloop \
43+
&& git clone https://github.com/h2o/picohttpparser.git /picohttpparser \
44+
&& git clone https://github.com/ringphp/php-mrloop.git /ext-mrloop
45+
WORKDIR /ext-mrloop
46+
RUN git fetch \
47+
&& git pull \
48+
&& phpize \
49+
&& ./configure --with-mrloop=/mrloop --with-picohttp=/picohttpparser \
50+
&& make \
51+
&& make install \
52+
&& EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` \
53+
&& cp "$EXTENSION_DIR/mrloop.so" /mrloop.so \
54+
&& sha256sum /mrloop.so
55+
4056
FROM base AS nts-slim-root
4157

4258
COPY --from=build-uv /uv.so /uv.so
59+
COPY --from=build-mrloop /mrloop.so /mrloop.so
4360

4461
# Install docker help scripts
4562
COPY src/php/utils/docker/ /usr/local/bin/
@@ -51,6 +68,7 @@ RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
5168
mv /*.so "$EXTENSION_DIR/" && \
5269
apk add --no-cache \
5370
libuv-dev \
71+
liburing-dev \
5472
icu-dev \
5573
libevent-dev \
5674
openssl-dev \
@@ -69,6 +87,7 @@ RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
6987
# To ensure ext-socket loads before ext-event
7088
&& docker-php-ext-enable --ini-name zzzzz-event.ini event \
7189
&& docker-php-ext-enable uv \
90+
&& docker-php-ext-enable mrloop \
7291
&& apk del $PHPIZE_DEPS \
7392
&& wget -q -O - https://raw.githubusercontent.com/eficode/wait-for/master/wait-for > /bin/wait-for \
7493
&& chmod +x /bin/wait-for \

Dockerfile-zts-alpine

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN apk update \
2323
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
2424

2525
FROM base AS base-build
26-
RUN apk add --no-cache $PHPIZE_DEPS git libuv-dev
26+
RUN apk add --no-cache $PHPIZE_DEPS git libuv-dev liburing-dev linux-headers
2727

2828
FROM base-build AS build-uv
2929
RUN git clone https://github.com/amphp/ext-uv uv
@@ -37,9 +37,26 @@ RUN git fetch \
3737
&& cp "$EXTENSION_DIR/uv.so" /uv.so \
3838
&& sha256sum /uv.so
3939

40+
FROM base-build AS build-mrloop
41+
42+
RUN git clone https://github.com/ace411/mrloop.git /mrloop \
43+
&& git clone https://github.com/h2o/picohttpparser.git /picohttpparser \
44+
&& git clone https://github.com/ringphp/php-mrloop.git /ext-mrloop
45+
WORKDIR /ext-mrloop
46+
RUN git fetch \
47+
&& git pull \
48+
&& phpize \
49+
&& ./configure --with-mrloop=/mrloop --with-picohttp=/picohttpparser \
50+
&& make \
51+
&& make install \
52+
&& EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` \
53+
&& cp "$EXTENSION_DIR/mrloop.so" /mrloop.so \
54+
&& sha256sum /mrloop.so
55+
4056
FROM base AS zts-slim-root
4157

4258
COPY --from=build-uv /uv.so /uv.so
59+
COPY --from=build-mrloop /mrloop.so /mrloop.so
4360

4461
# Install docker help scripts
4562
COPY src/php/utils/docker/alpine/ /usr/local/bin/
@@ -52,6 +69,7 @@ RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
5269
mv /*.so "$EXTENSION_DIR/" && \
5370
apk add --no-cache \
5471
libuv-dev \
72+
liburing-dev \
5573
icu-dev \
5674
libevent-dev \
5775
openssl-dev \
@@ -75,6 +93,7 @@ RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
7593
# To ensure ext-socket loads before ext-event
7694
&& docker-php-ext-enable --ini-name zzzzz-event.ini event \
7795
&& docker-php-ext-enable uv \
96+
&& docker-php-ext-enable mrloop \
7897
&& apk del $PHPIZE_DEPS \
7998
&& wget -q -O - https://raw.githubusercontent.com/eficode/wait-for/master/wait-for > /bin/wait-for \
8099
&& chmod +x /bin/wait-for \

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ ENTRYPOINT ["php", "/opt/app/app.php"]
7777

7878
NTS, or non-thread safe is the PHP version most people use. This image comes with the following extensions:
7979

80-
| Extension | Description |
81-
|-----------|------------------------------------------|
82-
| ext-eio | Provides interface to the libeio library |
83-
| ext-pcntl | PCNTL OS signals |
84-
| ext-uv | LibUV event loop |
85-
| ext-event | Libevent event loop |
80+
| Extension | Description |
81+
|------------|------------------------------------------|
82+
| ext-eio | Provides interface to the libeio library |
83+
| ext-pcntl | PCNTL OS signals |
84+
| ext-uv | LibUV event loop |
85+
| ext-event | Libevent event loop |
86+
| ext-mrloop | MrLoop event loop |
8687

8788
### ZTS
8889

test/container/test_php_ext.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ def test_pgsql_is_loaded(host):
5959
def test_uv_is_loaded(host):
6060
assert 'uv' in host.run('php -m').stdout
6161

62+
@pytest.mark.php_zts
63+
@pytest.mark.php_nts
64+
def test_mrloop_is_loaded(host):
65+
assert 'mrloop' in host.run('php -m').stdout
66+
6267
@pytest.mark.php_not_slim_amd64
6368
def test_vips_is_loaded(host):
6469
assert 'vips' in host.run('php -m').stdout

0 commit comments

Comments
 (0)