-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
172 lines (137 loc) · 5.05 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
161
162
163
164
165
166
167
168
169
170
171
172
### Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-xeu -o pipefail -O inherit_errexit -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules
CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`
# Folder containing this Makefile
PROJECT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# Versions
PLONE_VERSION=$$(cat ${PROJECT_DIR}/backend/version.txt)
#VOLTO_VERSION=$$(cat ${PROJECT_DIR}/frontend/version.txt)
PROJECT_VERSION=$$(cat version.txt)
.PHONY: all
all: build
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
.PHONY: help
help: ## This help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: install-frontend
install-frontend: ## Install React Frontend
$(MAKE) -C "./frontend/" install
.PHONY: build-frontend
build-frontend: ## Build React Frontend
$(MAKE) -C "./frontend/" build
.PHONY: start-frontend
start-frontend: ## Start React Frontend
$(MAKE) -C "./frontend/" start
.PHONY: install-backend
install-backend: ## Create virtualenv and install Plone
$(MAKE) -C "./backend/" build-dev
$(MAKE) create-site
.PHONY: build-backend
build-backend: ## Build Backend
$(MAKE) -C "./backend/" build-dev
.PHONY: create-site
create-site: ## Create a Plone site with default content
$(MAKE) -C "./backend/" create-site
.PHONY: start-backend
start-backend: ## Start Plone Backend
$(MAKE) -C "./backend/" start
.PHONY: install
install: ## Install
@echo "Install Backend & Frontend"
$(MAKE) install-backend
$(MAKE) install-frontend
# TODO production build
.PHONY: build
build: ## Build in development mode
@echo "Build"
$(MAKE) build-backend
$(MAKE) install-frontend
.PHONY: start
start: ## Start
@echo "Starting application"
$(MAKE) start-backend
$(MAKE) start-frontend
.PHONY: clean
clean: ## Clean installation
@echo "Clean installation"
$(MAKE) -C "./backend/" clean
$(MAKE) -C "./frontend/" clean
.PHONY: format
format: ## Format codebase
@echo "Format codebase"
$(MAKE) -C "./backend/" format
$(MAKE) -C "./frontend/" format
.PHONY: i18n
i18n: ## Update locales
@echo "Update locales"
$(MAKE) -C "./backend/" i18n
$(MAKE) -C "./frontend/" i18n
.PHONY: test-backend
test-backend: ## Test backend codebase
@echo "Test backend"
$(MAKE) -C "./backend/" test
.PHONY: test-frontend
test-frontend: ## Test frontend codebase
@echo "Test frontend"
$(MAKE) -C "./frontend/" test
.PHONY: test
test: test-backend test-frontend ## Test codebase
.PHONY: build-images
build-images: ## Build docker images
@echo "Build"
$(MAKE) -C "./backend/" build-image
$(MAKE) -C "./frontend/" build-image
## Docker stack
.PHONY: start-stack
start-stack: ## Start local stack
@echo "Start local Docker stack"
@docker-compose -f docker-compose.yml up -d --build
.PHONY: stop-stack
stop-stack: ## Stop local stack
@echo "Stop local Docker stack"
@docker-compose -f docker-compose.yml down
## Acceptance
.PHONY: build-acceptance-servers
build-acceptance-servers: ## Build Acceptance Servers
@echo "Build acceptance backend"
@docker build backend -t plone/plone.org-backend:acceptance -f backend/Dockerfile.acceptance
@echo "Build acceptance frontend"
@docker build frontend -t plone/plone.org-frontend:acceptance -f frontend/Dockerfile
.PHONY: start-acceptance-servers
start-acceptance-servers: build-acceptance-servers ## Start Acceptance Servers
@echo "Start acceptance backend"
@docker run --rm -p 55001:55001 --name plone.org-backend-acceptance -d plone/plone.org-backend:acceptance
@echo "Start acceptance frontend"
@docker run --rm -p 3000:3000 --name plone.org-frontend-acceptance --link plone.org-backend-acceptance:backend -e RAZZLE_API_PATH=http://localhost:55001/plone -e RAZZLE_INTERNAL_API_PATH=http://backend:55001/plone -d plone/plone.org-frontend:acceptance
.PHONY: stop-acceptance-servers
stop-acceptance-servers: ## Stop Acceptance Servers
@echo "Stop acceptance containers"
@docker stop plone.org-frontend-acceptance
@docker stop plone.org-backend-acceptance
.PHONY: run-acceptance-tests
run-acceptance-tests: ## Run Acceptance tests
$(MAKE) start-acceptance-servers
npx wait-on --httpTimeout 20000 http-get://localhost:55001/plone http://localhost:3000
$(MAKE) -C "./frontend/" test-acceptance-headless
$(MAKE) stop-acceptance-servers
create-tag: # Create a new tag using git
@echo "Creating new tag $(PROJECT_VERSION)"
if git show-ref --tags v$(PROJECT_VERSION) --quiet; then echo "$(PROJECT_VERSION) already exists";else git tag -a v$(PROJECT_VERSION) -m "Release $(PROJECT_VERSION)" && git push && git push --tags;fi
commit-and-release: # Commit new version change and create tag
@echo "Commiting changes"
@git commit -am "Tag release as $(PROJECT_VERSION) to deploy"
make create-tag