Skip to content

Instantly share code, notes, and snippets.

@jotapepinheiro
Created December 6, 2024 19:45
Show Gist options
  • Save jotapepinheiro/db895f354b3d4f5801603acfd5bc779a to your computer and use it in GitHub Desktop.
Save jotapepinheiro/db895f354b3d4f5801603acfd5bc779a to your computer and use it in GitHub Desktop.
PATH := $(PATH):$(PWD)/bin:
SHELL := /bin/bash
.PHONY: help
.DEFAULT_GOAL = help
phpmd := vendor/bin/phpmd
phpcs := vendor/bin/phpcs
phpcbf := vendor/bin/phpcbf
phpunit := vendor/bin/phpunit
phpstan := vendor/bin/phpstan
pest := vendor/bin/pest
CONTAINER := microservice-global-auth-server-external
CONTAINER_REDIS := auth-server-redis
PATH_CONTAINER := /var/www/html
## β€”β€” Docker 🐳 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
docker-start: ## Iniciar Docker
docker compose up -d
docker-build: ## Iniciar Docker com build
docker compose up -d --build
docker-stop: ## Desligar Docker
docker compose down
docker-shell: ## Acessar container do php
docker exec -it $(CONTAINER) sh
docker-rebuild-all: ## Rebuild em todos os containers
make docker-stop docker-build
reload-nginx: ## Reload no nginx
docker exec -it $(CONTAINER) nginx -s reload
redis-clear: ## Limpar cache do redis
docker exec -it $(CONTAINER_REDIS) redis-cli flushall
show-php-memory: ## Exibir memoria do PHP
docker exec -it $(CONTAINER) sh -c "php -i | grep memory_limit"
## β€”β€” Pest 🐞 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
pest: ## Executar testes com Pest
docker exec -it $(CONTAINER) sh -c "cd $(PATH_CONTAINER) \
&& $(pest)"
coverage: ## Executar testes com Pest e gerar relatΓ³rio de cobertura
docker exec -it $(CONTAINER) sh -c "cd $(PATH_CONTAINER) \
&& $(pest) --coverage"
generate-coverage: ## Gerar relatΓ³rio de cobertura
docker exec -it $(CONTAINER) sh -c "cd $(PATH_CONTAINER) \
&& $(pest) --coverage --coverage-html ./coverage"
## β€”β€” Lumen 🎢 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
composer-install: ## Instalar composer
docker compose run --rm $(CONTAINER) composer install --ignore-platform-reqs
composer-update: ## Atualizar dependencias do composer
docker compose run --rm $(CONTAINER) composer update --ignore-platform-reqs
composer-validate: ## Validar dependencias do composer
docker exec -it $(CONTAINER) composer validate
composer-show: ## Exibir pacotes do composer
docker exec -it $(CONTAINER) composer show -l --direct --outdated
pa-migrate: ## Executar Migrate
docker exec -it $(CONTAINER) sh -c "cd $(PATH_CONTAINER) \
&& php artisan migrate"
pa-seed: ## Executar os Seeds
docker exec -it $(CONTAINER) sh -c "cd $(PATH_CONTAINER) \
&& php artisan db:seed"
pa-migrate-fresh: ## Executar Migrate Refresh
docker exec -it $(CONTAINER) sh -c "cd $(PATH_CONTAINER) \
&& php artisan migrate:fresh --seed"
pa-migrate-fresh-file: ## Executar Migrate Refresh
docker exec -it $(CONTAINER) sh -c "cd $(PATH_CONTAINER) \
&& php artisan db:seed --class=UserTypesTableSeeder --force"
pa-dump-autoload: ## Limpar Lumen
docker exec -it $(CONTAINER) sh -c "cd $(PATH_CONTAINER) \
&& composer dump-autoload \
&& php artisan cache:clear"
pa-update-password: ## Atualizar senha do usuΓ‘rio
docker exec -it $(CONTAINER) sh -c "cd $(PATH_CONTAINER) \
&& php artisan update:password"
phpstan: ## Analisar cΓ³digo PHP usando PHPSTAN (https://phpstan.org/)
docker exec -it $(CONTAINER) php -d memory_limit=-1 $(phpstan) analyse --level=0 app public
phpstan-neon: ## Analisar cΓ³digo PHP usando PHPSTAN (https://phpstan.org/)
docker exec -it $(CONTAINER) php -d memory_limit=-1 $(phpstan) analyse -c phpstan.neon
phpstan-neon-local: ## Analisar cΓ³digo PHP usando PHPSTAN (https://phpstan.org/)
php -d memory_limit=-1 $(phpstan) analyse -c phpstan.neon
## β€”β€” Outros πŸ› οΈοΈ β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
help: ## Lista de commandos
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-24s\033[0m %s\n", $$1, $$2}' \
| sed -e 's/\[32m## /[33m/' && printf "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment