This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
136 lines (107 loc) · 3.56 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
include .env
# Variables
prod := -f docker-compose.yml -f docker-compose.production.yml
deploy := DOCKER_HOST=ssh://root@$(DEPLOY_HOST) APP_HOST=$(DEPLOY_HOST)
all:
@echo "【 $(APP_NAME)@$(APP_HOST) => $(DEPLOY_HOST) 】"
@echo " ‣ install ‣ upgrade ‣ packages"
@echo " ‣ assets ‣ build ‣ rebuild ‣ deploy-build ‣ deploy-rebuild"
@echo " ‣ plugin add=WP_PLUGIN ‣ theme add=WP_THEME ‣ package add=NPM_PACKAGE"
@echo " ‣ up ‣ upp"
@echo " ‣ deploy ‣ undeploy ‣ target ‣ logs"
@echo ""
# --------------
# UPDATE STEPS:
# --------------
# 1. npm: update all node modules necessary for webpack
# 2. Webpack: bundle static assets
# 3. Docker: add code, install composer packages, build image
# 4. WordPress: run database updates
up: assets build
docker-compose up --remove-orphans
# Launch in production mode
upp: assets build
docker-compose $(prod) up --remove-orphans web
# --------------
# DEPLOY STEPS:
# --------------
target:
docker-compose run --rm env deploy_host
deploy: assets deploy-build
$(deploy) docker-compose $(prod) up --remove-orphans -d web
$(deploy) docker-compose logs -f
undeploy:
$(deploy) docker-compose down --remove-orphans
logs:
$(deploy) docker-compose logs -f
# --------------
# INSTALL STEPS:
# --------------
# 1. Rename bedrock-site, build .env file, databases, and database user
.env:
docker run --rm -it \
-e APP_NAME=$(notdir $(shell pwd)) \
-e APP_HOST=$(shell hostname -f) \
-v $(PWD):/srv \
nonfiction/bedrock:env dotenv
# 2. Compile assets before building web image
assets:
docker-compose run --rm dev npm update --save-dev
docker-compose run --rm dev webpack --progress
# 3a. Build web image and perform any DB updates
build:
docker-compose build web
docker-compose run wp core update-db
# 3b. Build web image (fresh) and perform any DB updates
rebuild:
docker-compose build --pull --no-cache web
docker-compose run wp core update-db
# 4a. Build web image and perform any DB updates on deploy host
deploy-build:
$(deploy) docker-compose build web
$(deploy) docker-compose run wp core update-db
# 4b. Build web image (fresh) and perform any DB updates on deploy host
deploy-rebuild:
$(deploy) docker-compose build --pull --no-cache web
$(deploy) docker-compose run wp core update-db
# 4. Install WP database, activate plugins and theme
install: .env assets rebuild
docker-compose run wp core install \
--url=https://$(APP_NAME).$(APP_HOST) \
--title=$(APP_NAME) \
--admin_user=nf-$(APP_NAME) \
--admin_password=$(DB_PASSWORD)
docker-compose run wp plugin activate --all
docker-compose run wp theme activate theme
docker-compose run wp rewrite structure /%postname%/
@echo
@echo URL: https://$(APP_NAME).$(APP_HOST)/wp/wp-login.php
@echo Username: nf-$(APP_NAME)
@echo Password: $(DB_PASSWORD)
# 5. Upgrade after install plugins or themes
upgrade: .env packages assets rebuild
packages:
docker-compose run --rm dev npx ncu -u
docker-compose run --rm dev npm update --save-dev
# make plugin add=plugin_name
plugin:
@test $(add)
docker-compose run --rm web composer require --no-update wpackagist-plugin/$(add)
# make theme add=theme_name
theme:
@test $(add)
docker-compose run --rm web composer require --no-update wpackagist-theme/$(add)
# make package add=package_name
package:
@test $(add)
docker-compose run --rm dev npm install $(add) --save-dev
clean:
rm -rf data/* && touch data/.gitkeep
db:
docker-compose run --rm env db_create
# db-push:
# docker-compose run --rm env db_push
#
# db-pull:
# docker-compose run --rm env db_pull