Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM ubuntu:24.04

ARG PHP_VERSION=8.4
ARG NGINX_VERSION=1.31.4

ENV DEBIAN_FRONTEND=noninteractive \
PHP_SRC_VERSION=${PHP_VERSION} \
NGINX_SRC_VERSION=${NGINX_VERSION} \
TRAVIS_BUILD_DIR=/src

WORKDIR /src

RUN PHP_OPCACHE_PACKAGE=php${PHP_VERSION}-opcache \
&& if [ "${PHP_VERSION}" >= "8.5" ]; then PHP_OPCACHE_PACKAGE=; fi \
&& apt-get update \
&& apt-get install -y --no-install-recommends software-properties-common ca-certificates wget curl \
&& add-apt-repository ppa:ondrej/php \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
bash build-essential cpanminus gdb libargon2-dev libkrb5-dev libpcre3-dev libxml2-dev psmisc \
libxslt1-dev libsodium-dev libtool memcached mysql-server redis-server systemtap-sdt-dev \
zlib1g-dev php${PHP_VERSION}-cli php${PHP_VERSION}-dbg php${PHP_VERSION}-dev libphp${PHP_VERSION}-embed \
php${PHP_VERSION}-mysql ${PHP_OPCACHE_PACKAGE} \
&& rm -rf /var/lib/apt/lists/*

COPY . /src

RUN wget -q http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
&& tar -xzf nginx-${NGINX_VERSION}.tar.gz \
&& find config src third_party .github -type f -exec sed -i 's/\r$//' {} + \
&& ./.github/ngx-php/compile-ngx.sh \
&& cpanm -n Test::Nginx \
&& chmod +x .github/ngx-php/docker-test-entrypoint.sh \
&& rm -f nginx-${NGINX_VERSION}.tar.gz

ENTRYPOINT ["/src/.github/ngx-php/docker-test-entrypoint.sh"]
CMD ["./.github/ngx-php/test.sh"]
11 changes: 11 additions & 0 deletions Dockerfile.test.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*
!config
!src/
!src/**
!third_party/
!t
!t/
!t/**
!/.github
!/.github/
!/.github/**
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,40 @@ $ docker run -p 80:80 -v $PWD/app.conf:/etc/nginx/conf.d/default.conf nginx-php7
```


Only to developers of ngx-php code !!

To build and run the Ubuntu 24.04 regression tests locally:

```sh
$ docker build --file Dockerfile.test --tag ngx-php-test .
$ docker run --rm ngx-php-test
```

The test image accepts the same version dimensions as CI:

```sh
$ docker build --file Dockerfile.test --build-arg PHP_VERSION=8.4 --build-arg NGINX_VERSION=1.27.3 --tag ngx-php-test .
```

To test locally all tests

```sh
docker run --rm ngx-php-test:local bash -c "export PATH=/src/nginx/sbin:/usr/bin:/bin; export TRAVIS_BUILD_DIR=/src; prove -r t"
```

To test only 1 test locally

```sh
docker run --rm ngx-php-test:local bash -c "export PATH=/src/nginx/sbin:/usr/bin:/bin; export TRAVIS_BUILD_DIR=/src; prove -v t/024-ngx_request_body.t"
```

We can also pass the arguments in the docker build

```sh
docker build --no-cache --build-arg PHP_VERSION=8.5 --build-arg NGINX_VERSION=1.31.4 ...
```


Synopsis
--------

Expand Down