From 90cc56841dc6c72aab86dd2c9ea4e9082244004e Mon Sep 17 00:00:00 2001 From: Mikk Tendermann Date: Wed, 26 Feb 2025 12:48:37 +0200 Subject: [PATCH 1/3] add docker-compose to simplify running tests --- .env-example | 2 ++ .gitignore | 1 + Dockerfile | 11 +++++++++++ docker-compose.yml | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 .env-example create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.env-example b/.env-example new file mode 100644 index 0000000..8a64187 --- /dev/null +++ b/.env-example @@ -0,0 +1,2 @@ +COMPOSER_HOME=~/.config/composer +UID=1000 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 31a345f..43b2d94 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ tests/_support tests/_output tests/cases/yii2-app-advanced/_data/db.sqlite +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bf3b009 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +ARG PHP_VERSION="8.3-alpine" + +FROM php:$PHP_VERSION + +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ + +RUN chmod +x /usr/local/bin/install-php-extensions \ + && apk add --no-cache git \ + && install-php-extensions gd intl zip intl pcov @composer + +WORKDIR /var/www/html \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b7c6d25 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,41 @@ +services: + + php80: &phpbase + user: ${UID} + volumes: + - ${COMPOSER_HOME}:/.config/composer:delegated + # Mount source-code for development + - ./:/var/www/html + env_file: + - .env + environment: + - XDEBUG_CONFIG=client_host=host.docker.internal + extra_hosts: + - "host.docker.internal:host-gateway" + build: + context: ./ + dockerfile: Dockerfile + args: + - PHP_VERSION=8.0-alpine + + php81: + <<: *phpbase + build: + args: + - PHP_VERSION=8.1-alpine + php82: + <<: *phpbase + build: + args: + - PHP_VERSION=8.2-alpine + + php83: + <<: *phpbase + build: + args: + - PHP_VERSION=8.3-alpine + php84: + <<: *phpbase + build: + args: + - PHP_VERSION=8.4-alpine \ No newline at end of file From 6c97206ebfbbe0327c4db9c412005924b18df8e7 Mon Sep 17 00:00:00 2001 From: Mikk Tendermann Date: Wed, 26 Feb 2025 13:01:00 +0200 Subject: [PATCH 2/3] we do not technically need to delegate composer in container --- .env-example | 1 - docker-compose.yml | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.env-example b/.env-example index 8a64187..a4df111 100644 --- a/.env-example +++ b/.env-example @@ -1,2 +1 @@ -COMPOSER_HOME=~/.config/composer UID=1000 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b7c6d25..a65684b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,7 @@ services: - php80: &phpbase - user: ${UID} + user: ${UID:-1000} volumes: - - ${COMPOSER_HOME}:/.config/composer:delegated # Mount source-code for development - ./:/var/www/html env_file: From e0574c4032202fb76b5c403a0c9a74766c23bb3b Mon Sep 17 00:00:00 2001 From: Mikk Tendermann Date: Wed, 26 Feb 2025 13:09:05 +0200 Subject: [PATCH 3/3] add readme how to test using docker-compose --- docker-compose.yml | 10 +++++----- readme.md | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a65684b..477f02d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ services: - php80: &phpbase + php8.0: &phpbase user: ${UID:-1000} volumes: # Mount source-code for development @@ -16,23 +16,23 @@ services: args: - PHP_VERSION=8.0-alpine - php81: + php8.1: <<: *phpbase build: args: - PHP_VERSION=8.1-alpine - php82: + php8.2: <<: *phpbase build: args: - PHP_VERSION=8.2-alpine - php83: + php8.3: <<: *phpbase build: args: - PHP_VERSION=8.3-alpine - php84: + php8.4: <<: *phpbase build: args: diff --git a/readme.md b/readme.md index 4040366..704251e 100644 --- a/readme.md +++ b/readme.md @@ -24,3 +24,11 @@ composer require "codeception/module-yii2" --dev `Codeception Module Yii2` is open-sourced software licensed under the [MIT](/LICENSE) License. © Codeception PHP Testing Framework + +## Test with docker-compose + +```bash +docker-compose run php8.4 composer install +docker-compose run php8.4 vendor/bin/codecept build +docker-compose run php8.4 vendor/bin/codecept run +```