diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7eb8f28..73bce7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,29 @@ jobs: - run: bash tests/await.sh - run: bash tests/acceptance.sh + Docker: + name: Docker (${{ matrix.dockerfile }}) + runs-on: ubuntu-20.04 + strategy: + matrix: + dockerfile: + - "Dockerfile-basics" + - "Dockerfile-production" + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + - run: cp tests/${{ matrix.dockerfile }} tests/install-as-dep/Dockerfile + - run: cd tests/install-as-dep && composer config --unset repositories.0 && composer install && tar -czh . | docker build - + - run: docker run -d -p 8080:8080 $(docker images -q | head -n1) + - run: docker exec -u root $(docker ps -qn1) touch LICENSE composer.json && docker exec -u root $(docker ps -qn1) mkdir tests/ + - run: bash tests/await.sh + - run: bash tests/acceptance.sh + - run: docker stop $(docker ps -qn1) + - run: docker logs $(docker ps -qn1) + if: ${{ always() }} + nginx-webserver: name: nginx + PHP-FPM (PHP ${{ matrix.php }}) runs-on: ubuntu-20.04 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a7580a3..6eb0fab 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,6 +9,7 @@ ./tests/ + ./tests/install-as-dep/ diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy index cb0fd89..4b0eafb 100644 --- a/phpunit.xml.legacy +++ b/phpunit.xml.legacy @@ -8,6 +8,7 @@ ./tests/ + ./tests/install-as-dep/ diff --git a/tests/Dockerfile-basics b/tests/Dockerfile-basics new file mode 100644 index 0000000..dfdb3b8 --- /dev/null +++ b/tests/Dockerfile-basics @@ -0,0 +1,11 @@ +# syntax=docker/dockerfile:1 +FROM php:8.1-cli + +WORKDIR /app/ +COPY public/ public/ +COPY vendor/ vendor/ + +ENV X_LISTEN 0.0.0.0:8080 +EXPOSE 8080 + +ENTRYPOINT php public/index.php diff --git a/tests/Dockerfile-production b/tests/Dockerfile-production new file mode 100644 index 0000000..c5127c7 --- /dev/null +++ b/tests/Dockerfile-production @@ -0,0 +1,26 @@ +# syntax=docker/dockerfile:1 +FROM composer:2 AS build + +WORKDIR /app/ +COPY composer.json composer.lock ./ +RUN composer install --no-dev --ignore-platform-reqs --optimize-autoloader + +FROM php:8.1-alpine + +# recommended: install optional extensions ext-ev and ext-sockets +RUN apk --no-cache add ${PHPIZE_DEPS} libev \ + && pecl install ev \ + && docker-php-ext-enable ev \ + && docker-php-ext-install sockets \ + && apk del ${PHPIZE_DEPS} + +WORKDIR /app/ +COPY public/ public/ +# COPY src/ src/ +COPY --from=build /app/vendor/ vendor/ + +ENV X_LISTEN 0.0.0.0:8080 +EXPOSE 8080 + +USER nobody:nobody +ENTRYPOINT php public/index.php diff --git a/tests/install-as-dep/.gitignore b/tests/install-as-dep/.gitignore new file mode 100644 index 0000000..52242db --- /dev/null +++ b/tests/install-as-dep/.gitignore @@ -0,0 +1,3 @@ +/composer.lock +/Dockerfile +/vendor/ diff --git a/tests/install-as-dep/LICENSE b/tests/install-as-dep/LICENSE new file mode 120000 index 0000000..30cff74 --- /dev/null +++ b/tests/install-as-dep/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/tests/install-as-dep/composer.json b/tests/install-as-dep/composer.json new file mode 100644 index 0000000..2fd43e7 --- /dev/null +++ b/tests/install-as-dep/composer.json @@ -0,0 +1,7 @@ +{ + "require": { + "clue/framework-x": "*@dev", + "react/async": "^4@dev || ^3@dev" + }, + "repositories": [] +} diff --git a/tests/install-as-dep/public/index.php b/tests/install-as-dep/public/index.php new file mode 120000 index 0000000..56f7c77 --- /dev/null +++ b/tests/install-as-dep/public/index.php @@ -0,0 +1 @@ +../../../examples/index.php \ No newline at end of file