#!make
.DEFAULT_GOAL := help

.PHONY: help
help: ## Help
	@grep -E '^[0-9a-zA-Z_/()$$-]+:.*?## .*$$' $(lastword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-18s\033[0m %s\n", $$1, $$2}'
	@printf '\n\nTo get up and running quickly for the first time, run the following in order:\n\n'
	@printf " $$\033[32m %s \033[0m \n" 'cp config-dev.php config.php'
	@printf " $$\033[32m %s \033[0m \n" 'make build'
	@printf "\n\nOn subsequent runs, just use\n"
	@printf " $$\033[32m %s \033[0m \n\n" 'make start'


.PHONY: start
start: ## Spin up the containers
	docker-compose up -d

.PHONY: stop
stop: ## Stop the containers
	docker-compose down

.PHONY: restart
restart: ## Restart the containers
	docker-compose down  && docker-compose up -d

.PHONY: enter
enter: ## SSH into the container
	docker-compose exec -u root app_zazi bash

.PHONY: show_logs
show_logs: ## Display container logs
	docker-compose logs

.PHONY: build
build: ## Build and spin up the containers
	docker-compose up --build -d

CMD1='chown -R 1000:1000 *'
.PHONY: change-owner
change-owner: ## SSH into the container
	docker-compose exec -u root app_zazi bash -c $(CMD1)

CMD='php artisan migrate'
.PHONY: migrate
migrate: ## SSH into the container
	docker-compose exec -u root app_zazi bash -c $(CMD)

