-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
187 lines (155 loc) · 4.85 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
EDXAPP_IMAGE="fundocker/edxapp:dogwood.3-fun-2.0.0"
# Get local user ids
DOCKER_UID = $(shell id -u)
DOCKER_GID = $(shell id -g)
# Docker
COMPOSE = \
DOCKER_UID=$(DOCKER_UID) \
DOCKER_GID=$(DOCKER_GID) \
EDXAPP_IMAGE=$(EDXAPP_IMAGE) \
docker-compose \
-f docker-compose.cypress.yml \
-f docker-compose.edx.yml \
-f docker-compose.keycloak.yml \
-f docker-compose.yml
COMPOSE_RUN = $(COMPOSE) run --rm -e HOME="/tmp"
WAIT_DB = $(COMPOSE_RUN) dockerize -wait tcp://edx_mysql:3306 -timeout 60s
# -- Node
# We must run node with a /home because yarn tries to write to ~/.yarnrc. If the
# ID of our host user (with which we run the container) does not exist in the
# container (e.g. 1000 exists but 1009 does not exist by default), then yarn
# will try to write to "/.yarnrc" at the root of the system and will fail with a
# permission error.
COMPOSE_RUN_NODE = $(COMPOSE_RUN) node
YARN = $(COMPOSE_RUN_NODE) yarn
# Terminal colors
COLOR_DEFAULT = \033[0;39m
COLOR_ERROR = \033[0;31m
COLOR_INFO = \033[0;36m
COLOR_RESET = \033[0m
COLOR_SUCCESS = \033[0;32m
COLOR_WARNING = \033[0;33m
default: help
# Target release expected tree
data/edx/media/.keep:
mkdir -p data/edx/media
touch data/edx/media/.keep
data/edx/store/.keep:
mkdir -p data/edx/store
touch data/edx/store/.keep
e2e/data/video.mp4: ## generate a 5 second long video and put it in e2e/data directory
mkdir -p e2e/data
$(COMPOSE_RUN) ffmpeg -y -f lavfi -i testsrc=size=1920x1080:rate=1 -vf hue=s=0 \
-vcodec libx264 -preset superfast -tune zerolatency -pix_fmt yuv420p -t 5 \
-movflags +faststart "/e2e/data/video.mp4"
# Make commands
bootstrap: ## bootstrap the project
bootstrap: \
migrate \
run \
realm
.PHONY: bootstrap
clean: \
remove-edx-courses
clean: ## remove temporary data
rm -rf data/edx e2e/cypress/videos e2e/cypress/screenshots
.PHONY: clean
clean-db: \
remove-edx-courses \
stop
clean-db: ## remove LMS databases
$(COMPOSE) rm edx_mongodb edx_mysql edx_redis keycloak_postgres
.PHONY: clean-db
install: ## install tests dependencies
$(YARN) install
.PHONY: install
lint-test: ## run tests "linters"
lint-test: \
install\
lint-test-eslint \
lint-test-prettier
.PHONY: lint-test
lint-test-eslint: ## lint js sources
$(YARN) lint --fix
.PHONY: lint-test-eslint
lint-test-prettier: ## run prettier over js files
$(YARN) prettier-write
.PHONY: lint-test-prettier
logs: ## get development logs
$(COMPOSE) logs -f
.PHONY: logs
migrate: \
tree
migrate: ## perform database migrations
@echo "Booting mysql service..."
$(COMPOSE) up -d edx_mysql
$(WAIT_DB)
$(COMPOSE_RUN) edx_lms python manage.py lms migrate
$(COMPOSE_RUN) edx_lms python /usr/local/bin/auth_init
$(COMPOSE_RUN) edx_cms python manage.py cms migrate
.PHONY: migrate
run: ## start graylog/keycloak services
run: \
run-keycloak \
run-graylog
.PHONY: run
run-graylog: \
tree
run-graylog: ## start graylog service
$(COMPOSE) up -d graylog
@echo "Wait for graylog to be up..."
$(COMPOSE_RUN) dockerize -wait tcp://graylog:9000 -timeout 60s
.PHONY: run-graylog
run-keycloak: \
tree
run-keycloak: ## start keycloak service
$(COMPOSE) up -d keycloak
@echo "Wait for keycloak to be up..."
$(COMPOSE_RUN) dockerize -wait tcp://keycloak:8080 -timeout 60s
.PHONY: run-keycloak
run-edx: \
tree
run-edx: ## start edx services
$(COMPOSE) up -d edx_cms
@echo "Wait for service to be up..."
$(WAIT_DB)
$(COMPOSE_RUN) dockerize -wait tcp://edx_redis:6379 -timeout 60s
$(COMPOSE_RUN) dockerize -wait tcp://edx_lms:8000 -timeout 60s
$(COMPOSE_RUN) dockerize -wait tcp://edx_cms:8000 -timeout 60s
.PHONY: run-edx
realm: ## import configured keycloak realm
$(COMPOSE) exec \
keycloak \
/opt/jboss/keycloak/local/bin/realm
.PHONY: realm
status: ## alias for "docker-compose ps"
$(COMPOSE) ps
.PHONY: status
stop: ## stop the development servers
$(COMPOSE) stop
.PHONY: stop
down: ## stop and remove docker containers
@echo "This will remove the containers and networks related to this project."
@echo -n "Are you sure to proceed? [y/N] " && read ans && [ $${ans:-N} = y ]
$(COMPOSE) down
.PHONY: down
test: \
e2e/data/video.mp4 \
remove-edx-courses
test: ## run tests
$(COMPOSE_RUN) cypress run --config-file false
.PHONY: test
tree: \
data/edx/media/.keep \
data/edx/store/.keep
tree: ## create data directories mounted as volumes
.PHONY: tree
remove-edx-courses: ## remove all edX courses
rm -f e2e/edx_courses_config.json
$(COMPOSE_RUN) edx_lms python manage.py lms dump_course_ids | \
grep -Eo 'course-v1:[0-9A-Za-z_-]+\+[0-9A-Za-z_-]+\+[0-9A-Za-z_-]+' | \
xargs -I{} bash -c "yes | $(COMPOSE_RUN) edx_cms python manage.py cms delete_course {}"
.PHONY: remove-edx-courses
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: help