-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
58 lines (42 loc) · 1.89 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
apache: ## Open a terminal in the "apache" container
@docker compose exec apache sh
build: ## Build the environment
@docker compose build --pull
cache: ## Flush cache stored in Redis
@docker compose exec -T redis sh -c "redis-cli FLUSHALL"
install: build start ## Install the environment
logs: ## Follow logs generated by all containers
@docker compose logs -f --tail=0
logs-full: ## Follow logs generated by all containers from the containers creation
@docker compose logs -f
mysql: ## Open a terminal in the "mysql" container
@docker compose exec mysql bash
php: ## Open a terminal in the "php" container
@docker compose exec php sh
ps: ## List all containers managed by the environment
@docker compose ps
purge: ## Purge all services, associated volumes
@docker compose down --volumes
restart: stop start ## Restart the environment
start: ## Start the environment
@if [[ ! -f docker-env ]]; then \
echo 'The default configuration has been applied because the "docker-env" file was not configured.'; \
cp docker-env.dist docker-env; \
fi
@docker compose up --detach --remove-orphans
stats: ## Print real-time statistics about containers ressources usage
@docker stats $(docker ps --format={{.Names}})
ssh: ## Copy all SSH keys from the host to the "php" container
docker compose exec -T php sh -c "mkdir -p /root/.ssh"
docker cp $(HOME)/.ssh $(shell docker-compose ps -q php):/root/
docker compose exec -T php sh -c "echo 'eval \$$(ssh-agent) && ssh-add' >> /root/.bashrc"
docker compose exec -T php sh -c "rm /root/.ssh/config"
stop: ## Stop the environment
@docker compose stop
.PHONY: apache build cache install logs logs-full mysql php ps purge restart start stats ssh stop
.DEFAULT_GOAL := help
help:
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' \
| sed -e 's/\[32m##/[33m/'
.PHONY: help