From e4e038361d4780e0d97c8763be4ac1a7b032498b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Sun, 12 Jan 2025 21:25:23 -0300 Subject: [PATCH] PHPAY-55: adding docker and makefile to dev env --- .docker/php/Dockerfile | 9 +++++++++ Makefile | 39 +++++++++++++++++++++++++++++++++++++++ composer.json | 20 +++++++++++++++++--- composer.lock | 2 +- docker-compose.yml | 11 +++++++++++ phpstan.neon | 1 - 6 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 .docker/php/Dockerfile create mode 100644 Makefile create mode 100644 docker-compose.yml diff --git a/.docker/php/Dockerfile b/.docker/php/Dockerfile new file mode 100644 index 0000000..b39fe4b --- /dev/null +++ b/.docker/php/Dockerfile @@ -0,0 +1,9 @@ +FROM php:8.2-cli-alpine + +COPY --from=composer /usr/bin/composer /usr/bin/composer +RUN composer self-update + +WORKDIR /usr/src/app +COPY . . + +RUN composer install --prefer-dist \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9889bee --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +DEFAULT_GOAL := help +help: + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-40s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +##@ [Docker] +start: ## Spin up the container + docker compose up -d + +stop: ## Shutdown the containers + docker compose down + +build: ## Build all docker images + docker compose build + +##@ [Application] +composer: ## Run composer commands. Specify the command e.g. via "make composer ARGS="install|update|require " + docker compose run --rm app composer $(ARGS) + +install: + docker compose run --rm app composer install + +lint: ## Run the Linter + docker compose run --rm app composer lint + +test-lint: ## Run the Linter Test + docker compose run --rm app composer test:lint + +test-types: ## Run the PHPStan analysis + docker compose run --rm app composer test:types + +test-unit: ## Run the Pest Test Suite + docker compose run --rm app composer test:unit + +test: ## Run the tests. Apply arguments via make test ARGS="--init" + docker compose run --rm app composer test + +##@ [Gateway Asaas] +asaas: ## Run resource asaas. Apply arguments via make asaas ARGS="charge|customer|pix|webhook" + @docker compose exec -it app php examples/asaas/$(resource).php \ No newline at end of file diff --git a/composer.json b/composer.json index 553cb8f..a799faa 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,11 @@ "PHPay\\Efi\\": "src/Gateways/Efi/", "Efi\\": "src/Gateways/Efi/", "AsaasCustomer\\": "src/Gateways/Asaas/Resources/Customer/" + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } } }, "authors": [ @@ -19,7 +24,8 @@ "require-dev": { "pestphp/pest": "3.5", "laravel/pint": "^1.18", - "phpstan/phpstan": "^2.0" + "phpstan/phpstan": "^2.0", + "nunomaduro/termwind": "^2.3" }, "config": { "allow-plugins": { @@ -32,6 +38,14 @@ "guzzlehttp/guzzle": "^7.0" }, "scripts": { - "test": "vendor/bin/pest" + "lint": "pint -v", + "test:lint": "pint --test -v", + "test:unit": "pest --colors=always", + "test:types": "phpstan analyse --level=9", + "test": [ + "@test:lint", + "@test:unit", + "@test:types" + ] } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index bd1ade6..572994a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3b6113a7486abd90043b0a699f4c7754", + "content-hash": "2eba1dd2f86a8cd366f11e884d89b843", "packages": [ { "name": "guzzlehttp/guzzle", diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2d5a2c3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +services: + app: + image: phpay-docker + container_name: phpay-docker + stdin_open: true + tty: true + build: + context: . + dockerfile: .docker/php/Dockerfile + volumes: + - .:/usr/src/app diff --git a/phpstan.neon b/phpstan.neon index e05e39d..5db244d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,4 @@ parameters: - level: 6 paths: - src - tests \ No newline at end of file