-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
160 lines (123 loc) · 4 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# autogenerated script from
.PHONY: help fixtures
-include custom.Makefile
# User Id
UNAME = $(shell uname)
ifeq ($(UNAME), Linux)
UID = $(shell id -u)
else
UID = 1000
endif
ifneq ("$(wildcard .env)","")
include .env
export
endif
INTERACTIVE:=$(shell [ -t 0 ] && echo 1)
ifdef INTERACTIVE
# is a terminal
TTY_DOCKER=-it
TTY_COMPOSE=
else
# bash job
TTY_DOCKER=
TTY_COMPOSE=-T
endif
COMPOSE=docker-compose
ifneq ("$(wildcard /.dockerenv)","")
echo "Should not be used inside a container"
exit 1
else
COMPOSE_PHP_CMD=$(COMPOSE) exec $(TTY_COMPOSE) -u www-data php
endif
## Display this help text
help:
$(info ---------------------------------------------------------------------)
$(info - Available targets -)
$(info ---------------------------------------------------------------------)
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
nb = sub( /^## /, "", helpMsg ); \
if(nb == 0) { \
helpMsg = $$0; \
nb = sub( /^[^:]*:.* ## /, "", helpMsg ); \
} \
if (nb) \
printf "\033[1;31m%-" width "s\033[0m %s\n", $$1, helpMsg; \
} \
{ helpMsg = $$0 }' \
$(MAKEFILE_LIST) | column -ts:
#==============================================================================
# Auto conf
#==============================================================================
.env:
cp .env.dist .env
.php.env:
cp .php.env.dist .php.env
docker-compose.yml:
cp docker-compose.yml.dist docker-compose.yml
autoconf: .env .php.env docker-compose.yml
#==============================================================================
# Standard docker dev commands
#==============================================================================
## Pull images used in docker-compose config
pull: autoconf
docker-compose pull --no-parallel
## Start all the containers
up: autoconf
docker-compose up -d
## Alias -> up
start: up
## Stop all the containers
stop:
docker-compose stop
## Stop, then... start
restart: stop start
## Down all the containers
down:
docker-compose down --remove-orphans --volumes
## Logs for all containers of the project
logs:
docker-compose logs -tf --tail=1000
## Status of containers
ps:
docker-compose ps
#==============================================================================
# Interactive shells
#==============================================================================
## Enter interactive shell into php container
php: hooks
docker-compose exec --user www-data php bash
## Enter interactive shell into nginx container
nginx:
docker-compose exec nginx sh
#==============================================================================
# Shortcuts
#==============================================================================
## Symfony cache clear
cc:
$(COMPOSE_PHP_CMD) ./bin/console cache:clear
## CS Fixer
fix:
$(COMPOSE_PHP_CMD) vendor/bin/php-cs-fixer fix src
## Run phpcsfixer
fix-hook:
# Install git hooks
hooks:
# @ln -s -f "./../../.dev/git/pre-commit" ".git/hooks/pre-commit"
# Just wait php ready
wait:
@$(COMPOSE) run php echo "Container : php is now ready"
## Upgrade sources + rebuild container + launch migrations
upgrade: pull up wait internal_update
## composer + upgrade (migrations,...)
internal_update:
$(COMPOSE_PHP_CMD) composer install
$(COMPOSE_PHP_CMD) ./bin/console doctrine:migrations:migrate -n
## Load fixtures (without migrations)
fixtures:
$(COMPOSE_PHP_CMD) ./scripts/dev/fixtures.sh
## Load fixtures (with migrations)
fixtures-with-migrations:
$(COMPOSE_PHP_CMD) ./scripts/dev/fixtures.sh --with-migrations
## Prepare database to generate migration
prepare-migration:
$(COMPOSE_PHP_CMD) ./scripts/dev/fixtures.sh --with-migrations --without-fixtures