[TOOLS] Update Makefile to support both the new and old container naming conventions, as of docker-compose v2

This commit is contained in:
Hugo Sales 2021-10-18 15:20:50 +01:00 committed by Diogo Peralta Cordeiro
parent b524c5bc90
commit 5eefea7a29
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
1 changed files with 10 additions and 7 deletions

View File

@ -1,5 +1,8 @@
DIR=$(strip $(notdir $(CURDIR))) # Seems a bit hack-ish, but `basename` works differently
translate-container-name = $$(if docker container inspect $(1) > /dev/null 2>&1; then echo $(1); else echo $(1) | sed 'y/_/-/' ; fi)
.PHONY:
@if ! docker info > /dev/null; then echo "Docker does not seem to be running"; exit 1; fi
@ -10,28 +13,28 @@ down: .PHONY
docker-compose down
redis-shell:
docker exec -it $(strip $(DIR))_redis_1 sh -c 'redis-cli'
docker exec -it $(call translate-container-name,$(strip $(DIR))_redis_1) sh -c 'redis-cli'
php-repl: .PHONY
docker exec -it $(strip $(DIR))_php_1 sh -c '/var/www/social/bin/console psysh'
docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) sh -c '/var/www/social/bin/console psysh'
php-shell: .PHONY
docker exec -it $(strip $(DIR))_php_1 sh -c 'cd /var/www/social; sh'
docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) sh -c 'cd /var/www/social; sh'
psql-shell: .PHONY
docker exec -it $(strip $(DIR))_db_1 sh -c "psql -U postgres social"
docker exec -it $(call translate-container-name,$(strip $(DIR))_db_1) sh -c "psql -U postgres social"
database-force-schema-update:
docker exec -it $(strip $(DIR))_php_1 sh -c "/var/www/social/bin/console doctrine:schema:update --dump-sql --force"
docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) sh -c "/var/www/social/bin/console doctrine:schema:update --dump-sql --force"
tooling-docker: .PHONY
@cd docker/tooling && docker-compose up -d > /dev/null 2>&1
test: tooling-docker
docker exec tooling_php_1 /var/tooling/coverage.sh
docker exec $(call translate-container-name,tooling_php_1) /var/tooling/coverage.sh
phpstan: tooling-docker
docker exec tooling_php_1 /var/tooling/phpstan.sh
docker exec $(call translate-container-name,tooling_php_1) /var/tooling/phpstan.sh
stop-tooling: .PHONY
cd docker/tooling && docker-compose down