-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
150 lines (115 loc) · 3.83 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
#!/usr/bin/make
.SILENT:
include ./sh/utils/colors
include ./config/environment/.env.main
SHELL = /bin/sh
# Share current user and group ID with container
CURRENT_UID := $(shell id -u)
CURRENT_GID := $(shell id -g)
# Check if CURRENT_UID and CURRENT_GID are less than 1000 (Fix Mac users ID)
ifeq ($(shell expr $(CURRENT_UID) \< 1000), 1)
CURRENT_UID := 1000
endif
ifeq ($(shell expr $(CURRENT_GID) \< 1000), 1)
CURRENT_GID := 1000
endif
#if [ ! "${CURRENT_GID}" ] || [ ! "${CURRENT_UID}" ]; then
# CURRENT_GID="${DEFAULT_GID}"
# CURRENT_UID="${DEFAULT_UID}"
#fi
export CURRENT_UID
export CURRENT_GID
export DOCKER_BUILDKIT=1
# Default values
LOGO_SH=bash ./sh/logo.sh
# https://stackoverflow.com/questions/6273608/how-to-pass-argument-to-makefile-from-command-line/6273809#6273809
# $(MAKECMDGOALS) is the list of targets passed to make
PARAMS = $(filter-out $@,$(MAKECMDGOALS))
# Go!
# Install project. Generate secrets, run composer and npm dependencies install
# `make install dev composer` - will run only composer update
# `make install dev npm` - will run only npm install and run dev mode
install:
$(LOGO_SH)
# Generate .env.secret
bash ./sh/env/secret-gen.sh
# Init root .env file
bash ./sh/env/init.sh $(PARAMS)
# Composer and npm build
bash ./sh/install.sh
# Run main project docker containers
docker compose up -d
# Check database is up
bash ./sh/database/check.sh
# Setup WordPress database
docker compose exec php su -c "bash /shell/wp-cli/core-install.sh" $(DEFAULT_USER)
# Generate .env.secret file
secret:
$(LOGO_SH)
bash ./sh/env/secret-gen.sh
env:
$(LOGO_SH)
bash ./sh/env/init.sh $(PARAMS)
core-install:
docker compose exec php su -c "bash /shell/wp-cli/core-install.sh" $(DEFAULT_USER)
# Run mix watch with browserSync
watch:
$(LOGO_SH)
bash ./sh/npm-watch.sh $(PARAMS)
# Regular docker compose up with root .env file concatenation
up:
$(LOGO_SH)
bash ./sh/env/init.sh $(PARAMS)
docker compose up -d --build
# docker compose up with root .env file concatenation without `-d`
upd:
$(LOGO_SH)
bash ./sh/env/init.sh $(PARAMS)
docker compose up --build
# Just docker compose down
down:
docker compose down -v
restart:
bash ./sh/env/init.sh $(PARAMS)
docker compose restart
recreate:
bash ./sh/env/init.sh $(PARAMS)
docker compose up -d --build --force-recreate
# Run database import script with first argument as file name and second as database name
import:
bash ./sh/database/import.sh $(PARAMS)
# Run database export script with first argument as file name and second as database name
export:
bash ./sh/database/export.sh $(PARAMS)
# Run database replacements script with first argument as search string and second as replace string
replace:
docker compose run --rm --build php su -c "bash /shell/wp-cli/search-replace.sh $(PARAMS)" $(DEFAULT_USER)
# Run phpMyAdmin docker container
pma:
docker compose -f docker-compose.build.yml run --service-ports --rm --build phpmyadmin
mailhog:
docker-compose -f docker-compose.build.yml run --service-ports --rm --name mailhog mailhog
log:
docker compose logs -f $(PARAMS)
run:
$(LOGO_SH)
bash ./sh/run.sh run $(PARAMS)
exec:
$(LOGO_SH)
bash ./sh/run.sh exec $(PARAMS)
lint:
docker compose -f docker-compose.build.yml run -it --rm --build composer su -c "cd web/wp-content/themes/${WP_DEFAULT_THEME} && composer lint" $(DEFAULT_USER)
docker compose -f docker-compose.build.yml run -it --rm --build node su -c "cd wp-content/themes/${WP_DEFAULT_THEME} && npm run lint" $(DEFAULT_USER)
# IasC
terraform:
terraform -chdir=iac/terraform $(PARAMS)
ansible:
ansible-playbook -i iac/ansible/inventory.yml iac/ansible/playbook.yml $(PARAMS)
# docker build|docker push|docker clean
docker:
bash ./sh/docker.sh $(PARAMS)
# This is a hack to allow passing arguments to the make command
# % is a wildcard. If no rule is matched (for arguments), this goal will be run
%:
# Do nothing
@: