-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
106 lines (81 loc) · 2.61 KB
/
Makefile
File metadata and controls
106 lines (81 loc) · 2.61 KB
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
#!make
include .env
$(eval export $(shell sed -ne 's/ *#.*$$//; /./ s/=.*$$// p' .env))
DOCKER_COMPOSE_FILE?=${DOCKER_COMPOSE_FILE}
CONTAINER?=${PROJECT_NAME}-wordpress-1
BUILDCHAIN?=${PROJECT_NAME}-node-1
COMPOSE=UID=${UID} GID=${GID} APP_UID=${APP_UID} docker compose -p ${PROJECT_NAME} -f $(DOCKER_COMPOSE_FILE)
.PHONY: default clean composer composer-install npm npm-install npm-dev craft restoredb bash update-clean stop start restart rebuild-wordpress logs
default: build composer-install npm-install npm-dev
clean:
${COMPOSE} down -v
${COMPOSE} up --build --remove-orphans -d
${COMPOSE} logs -f -t
composer:
docker exec -it ${CONTAINER} composer \
$(filter-out $@,$(MAKECMDGOALS))
composer-install:
${COMPOSE} run composer bash -c 'composer install'
composer-update:
${COMPOSE} run composer bash -c 'composer update'
npm:
docker exec -it ${BUILDCHAIN} npm \
$(filter-out $@,$(MAKECMDGOALS))
npm-install:
${COMPOSE} run node bash -c 'npm install'
npm-dev:
${COMPOSE} run node bash -c 'npm run dev'
npm-build:
${COMPOSE} run node bash -c 'npm run build'
prod:
${COMPOSE} run node bash -c 'npm run build'
rm -rf theme
mkdir theme
cp -a wp-content/themes/wp-starter/. theme
rm -rf theme/node_modules
rm -rf theme/assets/js
rm -rf theme/assets/css
rm -f theme/vite.config.js
rm -f theme/tailwind.config.js
rm -f theme/postcss.config.js
rm -f theme/main.js
upload:
rsync -avz -e "ssh -p ${SERVER_PORT}" theme/ ${SEVER_USER}@${SERVER_NAME}:${REMOTE_PATH}/wp-content/themes/wp-starter
rsync -avz -e "ssh -p ${SERVER_PORT}" vendor/ ${SEVER_USER}@${SERVER_NAME}:${REMOTE_PATH}/vendor
# Create an alias of prod
theme-build: prod
dev:
${COMPOSE} run node bash -c 'npm run dev'
node-version:
docker exec -it ${BUILDCHAIN} node -v && npm -v
bash:
docker exec -it ${CONTAINER} /bin/sh
update-clean:
${COMPOSE} stop
rm -f composer.lock
rm -rf vendor/
rm -f package-lock.json
rm -rf node_modules/
${COMPOSE} start
stop:
if [ "$$(docker ps -q -f name=${CONTAINER})" ]; then \
${COMPOSE} stop; \
fi
start:
if [ ! "$$(docker ps -q -f name=${CONTAINER})" ]; then \
${COMPOSE} up -d --remove-orphans; \
fi
build:
if [ ! "$$(docker ps -q -f name=${CONTAINER})" ]; then \
${COMPOSE} up --remove-orphans --build; \
fi
restart: stop start
# Rebuild WordPress image (picks up nginx/php-fpm timeout fixes) and restart container. Use after code changes in build/docker/ so refresh/504 issues are fixed.
rebuild-wordpress:
${COMPOSE} build wordpress
${COMPOSE} up -d wordpress
logs:
${COMPOSE} logs -f -t
%:
@:
# ref: https://stackoverflow.com/questions/6273608/how-to-pass-argument-to-makefile-from-command-line