Skip to content

Commit

Permalink
Add tests for Dockerfile instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Apr 18, 2022
1 parent c12596a commit 4e5f8fb
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<testsuites>
<testsuite name="Framework X test suite">
<directory>./tests/</directory>
<exclude>./tests/install-as-dep/</exclude>
</testsuite>
</testsuites>
<coverage>
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.legacy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<testsuites>
<testsuite name="Framework X test suite">
<directory>./tests/</directory>
<exclude>./tests/install-as-dep/</exclude>
</testsuite>
</testsuites>
<filter>
Expand Down
11 changes: 11 additions & 0 deletions tests/Dockerfile-basics
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions tests/Dockerfile-production
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tests/install-as-dep/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/composer.lock
/Dockerfile
/vendor/
1 change: 1 addition & 0 deletions tests/install-as-dep/LICENSE
7 changes: 7 additions & 0 deletions tests/install-as-dep/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": {
"clue/framework-x": "*@dev",
"react/async": "^4@dev || ^3@dev"
},
"repositories": []
}
1 change: 1 addition & 0 deletions tests/install-as-dep/public/index.php

0 comments on commit 4e5f8fb

Please sign in to comment.