Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Dockerfile instructions #149

Merged
merged 1 commit into from
Apr 20, 2022
Merged
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
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,28 @@ 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: composer install -d tests/install-as-dep/
- run: docker build -f tests/${{ matrix.dockerfile }} tests/install-as-dep/
- run: docker run -d -p 8080:8080 -v "$PWD/examples/index.php":/app/public/index.php -v "$PWD/composer.json":/app/composer.json -v "$PWD/LICENSE":/app/LICENSE -v "$PWD/tests/":/app/tests/ $(docker images -q | head -n1)
- 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
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
29 changes: 29 additions & 0 deletions tests/Dockerfile-production
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# syntax=docker/dockerfile:1
FROM composer:2 AS build

WORKDIR /app/
COPY composer.json composer.lock ./
# production environment should install optimized dependencies:
# RUN composer install --no-dev --ignore-platform-reqs --optimize-autoloader
# dev environment already has dependencies installed:
COPY vendor/ vendor/

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