From 4d928698842451e8af1ad65aa5814f10c17415e6 Mon Sep 17 00:00:00 2001 From: Marc Wolf Date: Tue, 11 Jun 2024 15:48:06 +0200 Subject: [PATCH] [TASK] Update to use compose.yml and integrate PHPUnit - Rename docker-compose.yml to compose.yml - Add PHPUnit 11.2.1 to composer.json - Update README.md with setup instructions for Docker Compose and PHPUnit - Ensure .gitignore includes vendor directory - Adjust GitHub Actions workflow to use compose.yml --- .../{docker-compose-test.yml => ci.yml} | 16 ++++++++-------- README.md | 10 +++++----- docker-compose.yml => compose.yml | 0 3 files changed, 13 insertions(+), 13 deletions(-) rename .github/workflows/{docker-compose-test.yml => ci.yml} (81%) rename docker-compose.yml => compose.yml (100%) diff --git a/.github/workflows/docker-compose-test.yml b/.github/workflows/ci.yml similarity index 81% rename from .github/workflows/docker-compose-test.yml rename to .github/workflows/ci.yml index 45381ec..6292b9d 100644 --- a/.github/workflows/docker-compose-test.yml +++ b/.github/workflows/ci.yml @@ -27,11 +27,11 @@ jobs: - name: Build and test services run: | - docker-compose -f docker-compose.yml up --build -d + docker compose -f compose.yml up --build -d - name: Test Xdebug run: | - sleep 10 # Wait for the containers to fully initialize + sleep 5 # Wait for the containers to fully initialize XDEBUG_OUTPUT=$(curl -s http://localhost/index.php) if [[ ! "$XDEBUG_OUTPUT" =~ "Xdebug" ]]; then echo "Xdebug test failed. Not found in phpinfo() output." @@ -42,16 +42,16 @@ jobs: - name: Install Composer dependencies run: | - docker-compose exec -T php-fpm composer install + docker compose exec -T php-fpm composer install - name: Run PHPUnit tests run: | - docker-compose exec -T php-fpm ./vendor/bin/phpunit tests + docker compose exec -T php-fpm ./vendor/bin/phpunit tests - name: Test Redis run: | sleep 5 # Wait for Redis to fully initialize - REDIS_TEST=$(docker-compose exec -T redis redis-cli ping) + REDIS_TEST=$(docker compose exec -T redis redis-cli ping) if [[ "$REDIS_TEST" != "PONG" ]]; then echo "Redis test failed. No PONG response." exit 1 @@ -65,8 +65,8 @@ jobs: MARIADB_PASSWORD: ${{ secrets.MARIADB_PASSWORD }} MARIADB_DATABASE: ${{ secrets.MARIADB_DATABASE }} run: | - sleep 10 # Wait for MariaDB to fully initialize - MARIADB_TEST=$(docker-compose exec -T mariadb mariadb -u${MARIADB_USER} -p${MARIADB_PASSWORD} -e "SHOW DATABASES LIKE '${MARIADB_DATABASE}';") + sleep 5 # Wait for MariaDB to fully initialize + MARIADB_TEST=$(docker compose exec -T mariadb mariadb -u${MARIADB_USER} -p${MARIADB_PASSWORD} -e "SHOW DATABASES LIKE '${MARIADB_DATABASE}';") if [[ "$MARIADB_TEST" != *"${MARIADB_DATABASE}"* ]]; then echo "MariaDB test failed. Database not found." exit 1 @@ -76,4 +76,4 @@ jobs: - name: Cleanup run: | - docker-compose -f docker-compose.yml down + docker compose -f compose.yml down diff --git a/README.md b/README.md index 51eddd3..35b4f2a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Docker compose PHP 8.3.8, Xdebug 3.4.0, Nginx 1.27.0, Redis 7.2.5 and MariaDB 11.4.2 +# Docker compose PHP 8.3.8, Xdebug 3.3.2, Nginx 1.27.0, Redis 7.2.5 and MariaDB 11.4.2 ![docker](https://img.shields.io/badge/Docker-compose-brightgreen.svg) ![nginx](https://img.shields.io/badge/nginx-1.27.0-brightgreen.svg) @@ -8,7 +8,7 @@ ![redis](https://img.shields.io/badge/Redis-7.2.5-brightgreen.svg) ![mariadb](https://img.shields.io/badge/MariaDB-11.4.2-brightgreen.svg) -* Easy setup with [docker-compose](https://docs.docker.com/compose/) and [Dockerfile](https://docs.docker.com/engine/reference/builder/) under usage from [Docker](https://www.docker.com) +* Easy setup with [docker compose](https://docs.docker.com/compose/) and [Dockerfile](https://docs.docker.com/engine/reference/builder/) under usage from [Docker](https://www.docker.com) * Uses [PHP 8.3.8](https://www.php.net) for better performance, lower CPU and memory usage * And [composer the dependency manager for PHP](https://getcomposer.org) to start easy your project * Built on the lightweight [nginx 1.27.0](https://nginx.org) webserver @@ -27,17 +27,17 @@ 2. **Build and start the Docker containers:** ```sh - docker-compose up --build -d + docker compose up --build -d ``` 3. **Install Composer dependencies:** ```sh - docker-compose exec -T php-fpm composer install + docker compose exec -T php-fpm composer install ``` 4. **Run PHPUnit tests:** ```sh - docker-compose exec -T php-fpm ./vendor/bin/phpunit tests + docker compose exec -T php-fpm ./vendor/bin/phpunit tests ``` ## Example PHPUnit Test diff --git a/docker-compose.yml b/compose.yml similarity index 100% rename from docker-compose.yml rename to compose.yml