Skip to content

Commit

Permalink
Add MrLoop event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Dec 23, 2024
1 parent a532330 commit a7f7eb1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
21 changes: 20 additions & 1 deletion Dockerfile-nts-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN apk update \
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

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

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

FROM base-build AS build-mrloop

RUN git clone https://github.com/ace411/mrloop.git /mrloop \
&& git clone https://github.com/h2o/picohttpparser.git /picohttpparser \
&& git clone https://github.com/ringphp/php-mrloop.git /ext-mrloop
WORKDIR /ext-mrloop
RUN git fetch \
&& git pull \
&& phpize \
&& ./configure --with-mrloop=/mrloop --with-picohttp=/picohttpparser \
&& make \
&& make install \
&& EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` \
&& cp "$EXTENSION_DIR/mrloop.so" /mrloop.so \
&& sha256sum /mrloop.so

FROM base AS nts-slim-root

COPY --from=build-uv /uv.so /uv.so
COPY --from=build-mrloop /mrloop.so /mrloop.so

# Install docker help scripts
COPY src/php/utils/docker/ /usr/local/bin/
Expand All @@ -51,6 +68,7 @@ RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
mv /*.so "$EXTENSION_DIR/" && \
apk add --no-cache \
libuv-dev \
liburing-dev \
icu-dev \
libevent-dev \
openssl-dev \
Expand All @@ -69,6 +87,7 @@ RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
# To ensure ext-socket loads before ext-event
&& docker-php-ext-enable --ini-name zzzzz-event.ini event \
&& docker-php-ext-enable uv \
&& docker-php-ext-enable mrloop \
&& apk del $PHPIZE_DEPS \
&& wget -q -O - https://raw.githubusercontent.com/eficode/wait-for/master/wait-for > /bin/wait-for \
&& chmod +x /bin/wait-for \
Expand Down
21 changes: 20 additions & 1 deletion Dockerfile-zts-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN apk update \
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

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

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

FROM base-build AS build-mrloop

RUN git clone https://github.com/ace411/mrloop.git /mrloop \
&& git clone https://github.com/h2o/picohttpparser.git /picohttpparser \
&& git clone https://github.com/ringphp/php-mrloop.git /ext-mrloop
WORKDIR /ext-mrloop
RUN git fetch \
&& git pull \
&& phpize \
&& ./configure --with-mrloop=/mrloop --with-picohttp=/picohttpparser \
&& make \
&& make install \
&& EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` \
&& cp "$EXTENSION_DIR/mrloop.so" /mrloop.so \
&& sha256sum /mrloop.so

FROM base AS zts-slim-root

COPY --from=build-uv /uv.so /uv.so
COPY --from=build-mrloop /mrloop.so /mrloop.so

# Install docker help scripts
COPY src/php/utils/docker/alpine/ /usr/local/bin/
Expand All @@ -52,6 +69,7 @@ RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
mv /*.so "$EXTENSION_DIR/" && \
apk add --no-cache \
libuv-dev \
liburing-dev \
icu-dev \
libevent-dev \
openssl-dev \
Expand All @@ -75,6 +93,7 @@ RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
# To ensure ext-socket loads before ext-event
&& docker-php-ext-enable --ini-name zzzzz-event.ini event \
&& docker-php-ext-enable uv \
&& docker-php-ext-enable mrloop \
&& apk del $PHPIZE_DEPS \
&& wget -q -O - https://raw.githubusercontent.com/eficode/wait-for/master/wait-for > /bin/wait-for \
&& chmod +x /bin/wait-for \
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ ENTRYPOINT ["php", "/opt/app/app.php"]

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

| Extension | Description |
|-----------|------------------------------------------|
| ext-eio | Provides interface to the libeio library |
| ext-pcntl | PCNTL OS signals |
| ext-uv | LibUV event loop |
| ext-event | Libevent event loop |
| Extension | Description |
|------------|------------------------------------------|
| ext-eio | Provides interface to the libeio library |
| ext-pcntl | PCNTL OS signals |
| ext-uv | LibUV event loop |
| ext-event | Libevent event loop |
| ext-mrloop | MrLoop event loop |

### ZTS

Expand Down
5 changes: 5 additions & 0 deletions test/container/test_php_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def test_pgsql_is_loaded(host):
def test_uv_is_loaded(host):
assert 'uv' in host.run('php -m').stdout

@pytest.mark.php_zts
@pytest.mark.php_nts
def test_mrloop_is_loaded(host):
assert 'mrloop' in host.run('php -m').stdout

@pytest.mark.php_not_slim_amd64
def test_vips_is_loaded(host):
assert 'vips' in host.run('php -m').stdout
Expand Down

0 comments on commit a7f7eb1

Please sign in to comment.