Skip to content

Commit 74688e3

Browse files
committed
Use Makefile variables to clarfiy compose file scheme
1 parent ad1af56 commit 74688e3

File tree

2 files changed

+61
-32
lines changed

2 files changed

+61
-32
lines changed

Makefile

+61-26
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,40 @@
2828
xqueue_consumer-restart xqueue_consumer-shell xqueue-logs \
2929
xqueue-restart xqueue-shell
3030

31+
# Docker Compose files that define services.
32+
MAIN_COMPOSE_FILE=-f docker-compose.yml
33+
XQUEUE_COMPOSE_FILE=-f docker-compose-xqueue.yml
34+
WATCHERS_COMPOSE_FILE=-f docker-compose-watchers.yml
35+
WATCHERS_COMPOSE_FILE_FOR_NFS=-f docker-compose-watchers-nfs.yml
36+
ANALYTICS_COMPOSE_FILE=-f docker-compose-analytics-pipeline.yml
37+
MARKETING_COMPOSE_FILE=-f docker-compose-marketing-site.yml
38+
39+
# Supporting Docker Compose files to enable volume mounting (which allows us to use
40+
# source code from our host machine) as well as theming.
41+
SUPPORTING_COMPOSE_FILES=-f docker-compose-host.yml -f docker-compose-themes.yml
42+
SUPPORTING_COMPOSE_FILES_FOR_NFS=-f docker-compose-host-nfs.yml -f docker-compose-themes-nfs.yml
43+
SUPPORTING_COMPOSE_FILES_FOR_SYNC=-f docker-compose-sync.yml
44+
45+
# "Suites" of Docker Compose files that can be used together to run different
46+
# sets of services.
47+
STANDARD_COMPOSE_SUITE=$(MAIN_COMPOSE_FILE) $(SUPPORTING_COMPOSE_FILES)
48+
STANDARD_COMPOSE_SUITE_FOR_NFS=$(MAIN_COMPOSE_FILE) $(SUPPORTING_COMPOSE_FILES_FOR_NFS)
49+
STANDARD_COMPOSE_SUITE_FOR_SYNC=$(MAIN_COMPOSE_FILE) $(SUPPORTING_COMPOSE_FILES_FOR_SYNC)
50+
XQUEUE_COMPOSE_SUITE=$(MAIN_COMPOSE_FILE) $(XQUEUE_COMPOSE_FILE) $(SUPPORTING_COMPOSE_FILES)
51+
ANALYTICS_COMPOSE_SUITE=$(STANDARD_COMPOSE_SUITE) $(ANALYTICS_COMPOSE_FILE)
52+
53+
# All Docker Compose YAML files that contain service definitions.
54+
# Useful for Makefile targets like `dev.pull` and `down`
55+
ALL_SERVICE_COMPOSE_FILES=\
56+
$(MAIN_COMPOSE_FILE) \
57+
$(XQUEUE_COMPOSE_FILE) \
58+
$(WATCHERS_COMPOSE_FILE) \
59+
$(ANALYTICS_COMPOSE_FILE) \
60+
$(MARKETING_COMPOSE_FILE)
61+
62+
# All Docker Compose files (except those for NFS and Docker Sync).
63+
FULL_COMPOSE_SUITE=$(ALL_SERVICE_COMPOSE_FILES) $(SUPPORTING_COMPOSE_FILES)
64+
3165
# Include options (configurable through options.local.mk)
3266
include options.mk
3367
export
@@ -76,10 +110,10 @@ dev.clone.ssh: ## Clone service repos using SSH method to the parent directory
76110
./repo.sh clone_ssh
77111

78112
dev.provision.services: ## Provision all services with local mounted directories
79-
DOCKER_COMPOSE_FILES="$(STANDARD_COMPOSE_FILES)" $(WINPTY) bash ./provision.sh
113+
DOCKER_COMPOSE_FILES="$(STANDARD_COMPOSE_SUITE)" $(WINPTY) bash ./provision.sh
80114

81115
dev.provision.services.%: ## Provision specified services with local mounted directories, separated by plus signs
82-
DOCKER_COMPOSE_FILES="$(STANDARD_COMPOSE_FILES)" $(WINPTY) bash ./provision.sh $*
116+
DOCKER_COMPOSE_FILES="$(STANDARD_COMPOSE_SUITE)" $(WINPTY) bash ./provision.sh $*
83117

84118
dev.provision: | check-memory dev.clone.ssh dev.provision.services stop ## Provision dev environment with all services stopped
85119

@@ -89,7 +123,7 @@ dev.cache-programs: ## Copy programs from Discovery to Memcached for use in LMS.
89123
dev.provision.xqueue: | check-memory dev.provision.xqueue.run stop stop.xqueue # Provision XQueue; run after other services are provisioned
90124

91125
dev.provision.xqueue.run:
92-
DOCKER_COMPOSE_FILES="-f docker-compose.yml -f docker-compose-xqueue.yml" $(WINPTY) bash ./provision-xqueue.sh
126+
DOCKER_COMPOSE_FILES="$(MAIN_COMPOSE_FILE) $(XQUEUE_COMPOSE_FILE)" $(WINPTY) bash ./provision-xqueue.sh
93127

94128
dev.reset: | down dev.repo.reset pull dev.up static update-db ## Attempts to reset the local devstack to the master working state
95129

@@ -106,16 +140,16 @@ dev.pull-without-deps.%: ## Pull latest Docker images for services (separated by
106140
ARG=$* docker-compose $(ALL_SERVICE_COMPOSE_FILES) pull $$(echo $* | tr + " ")
107141

108142
dev.pull.%: ## Pull latest Docker images for services (separated by plus-signs) and all their dependencies.
109-
docker-compose pull --include-deps $$(echo $* | tr + " ")
143+
docker-compose $(ALL_SERVICE_COMPOSE_FILES) pull --include-deps $$(echo $* | tr + " ")
110144

111145
dev.up: | check-memory ## Bring up all services with host volumes
112-
bash -c 'docker-compose $(STANDARD_COMPOSE_FILES) up -d'
146+
bash -c 'docker-compose $(STANDARD_COMPOSE_SUITE) up -d'
113147
ifeq ($(ALWAYS_CACHE_PROGRAMS),true)
114148
make dev.cache-programs
115149
endif
116150

117151
dev.up.%: | check-memory ## Bring up specific services (separated by plus-signs) and their dependencies with host volumes.
118-
bash -c 'docker-compose $(STANDARD_COMPOSE_FILES) up -d $$(echo $* | tr + " ")'
152+
bash -c 'docker-compose $(STANDARD_COMPOSE_SUITE) up -d $$(echo $* | tr + " ")'
119153
ifeq ($(ALWAYS_CACHE_PROGRAMS),true)
120154
make dev.cache-programs
121155
endif
@@ -127,29 +161,29 @@ dev.up.with-programs.%: ## Bring up a service and its dependencies and cache pro
127161
make dev.cache-programs
128162

129163
dev.up.watchers: | check-memory ## Bring up asset watcher containers
130-
bash -c 'docker-compose -f docker-compose-watchers.yml up -d'
164+
bash -c 'docker-compose $(WATCHERS_COMPOSE_FILE) up -d'
131165

132166
dev.nfs.setup: ## set's up an nfs server on the /Users folder, allowing nfs mounting on docker
133167
./setup_native_nfs_docker_osx.sh
134168

135169
dev.nfs.up.watchers: | check-memory ## Bring up asset watcher containers
136-
docker-compose -f docker-compose-watchers-nfs.yml up -d
170+
docker-compose $(WATCHERS_COMPOSE_FILE_FOR_NFS) up -d
137171

138172
dev.nfs.up: | check-memory ## Bring up all services with host volumes
139-
docker-compose $(NFS_COMPOSE_FILES) up -d
173+
docker-compose $(STANDARD_COMPOSE_SUITE_FOR_NFS) up -d
140174

141175
dev.nfs.up.all: | dev.nfs.up dev.nfs.up.watchers ## Bring up all services with host volumes, including watchers
142176

143177
dev.nfs.provision: | check-memory dev.clone dev.nfs.provision.services stop ## Provision dev environment with all services stopped
144178

145179
dev.nfs.provision.services: ## Provision all services with local mounted directories
146-
DOCKER_COMPOSE_FILES="$(NFS_COMPOSE_FILES)" ./provision.sh
180+
DOCKER_COMPOSE_FILES="$(STANDARD_COMPOSE_SUITE_FOR_NFS)" ./provision.sh
147181

148182
dev.nfs.provision.services.%: ## Provision specified services with local mounted directories, separated by plus signs
149-
DOCKER_COMPOSE_FILES="$(NFS_COMPOSE_FILES)" ./provision.sh $*
183+
DOCKER_COMPOSE_FILES="$(STANDARD_COMPOSE_SUITE_FOR_NFS)" ./provision.sh $*
150184

151185
dev.up.xqueue: | check-memory ## Bring up xqueue, assumes you already have lms running
152-
bash -c 'docker-compose -f docker-compose.yml -f docker-compose-xqueue.yml -f docker-compose-host.yml -f docker-compose-themes.yml up -d'
186+
bash -c 'docker-compose $(XQUEUE_COMPOSE_SUITE) up -d'
153187

154188
dev.up.all: | dev.up dev.up.watchers ## Bring up all services with host volumes, including watchers
155189

@@ -162,7 +196,7 @@ dev.sync.requirements: ## Install requirements
162196
gem install docker-sync
163197

164198
dev.sync.up: dev.sync.daemon.start ## Bring up all services with docker-sync enabled
165-
docker-compose -f docker-compose.yml -f docker-compose-sync.yml up -d
199+
docker-compose $(STANDARD_COMPOSE_SUITE_FOR_SYNC) up -d
166200

167201
provision: | dev.provision ## This command will be deprecated in a future release, use dev.provision
168202
echo "\033[0;31mThis command will be deprecated in a future release, use dev.provision\033[0m"
@@ -172,31 +206,31 @@ stop: ## Stop all services
172206
docker-compose stop
173207

174208
stop.watchers: ## Stop asset watchers
175-
docker-compose -f docker-compose-watchers.yml stop
209+
docker-compose $(WATCHERS_COMPOSE_FILE) stop
176210

177211
stop.all: | stop.analytics_pipeline stop stop.watchers ## Stop all containers, including asset watchers
178212

179213
stop.xqueue: ## Stop the XQueue service container
180-
docker-compose -f docker-compose-xqueue.yml stop
214+
docker-compose $(XQUEUE_COMPOSE_FILE) stop
181215

182216
down: ## Remove all service containers and networks
183217
(test -d .docker-sync && docker-sync clean) || true ## Ignore failure here
184-
docker-compose -f docker-compose.yml -f docker-compose-watchers.yml -f docker-compose-xqueue.yml -f docker-compose-analytics-pipeline.yml down
218+
docker-compose $(ALL_SERVICE_COMPOSE_FILES) down
185219

186220
destroy: ## Remove all devstack-related containers, networks, and volumes
187221
$(WINPTY) bash ./destroy.sh
188222

189223
logs: ## View logs from containers running in detached mode
190-
docker-compose -f docker-compose.yml -f docker-compose-analytics-pipeline.yml logs -f
224+
docker-compose $(ALL_SERVICE_COMPOSE_FILES) logs -f
191225

192226
%-logs: ## View the logs of the specified service container
193-
docker-compose -f docker-compose.yml -f docker-compose-analytics-pipeline.yml logs -f --tail=500 $*
227+
docker-compose $(ALL_SERVICE_COMPOSE_FILES) logs -f --tail=500 $*
194228

195229
xqueue-logs: ## View logs from containers running in detached mode
196-
docker-compose -f docker-compose-xqueue.yml logs -f xqueue
230+
docker-compose $(XQUEUE_COMPOSE_FILE) logs -f xqueue
197231

198232
xqueue_consumer-logs: ## View logs from containers running in detached mode
199-
docker-compose -f docker-compose-xqueue.yml logs -f xqueue_consumer
233+
docker-compose $(XQUEUE_COMPOSE_FILE) logs -f xqueue_consumer
200234

201235
RED="\033[0;31m"
202236
YELLOW="\033[0;33m"
@@ -234,7 +268,7 @@ pull: dev.pull
234268
@echo -n $(NO_COLOR)
235269

236270
pull.xqueue: ## Update XQueue Docker images
237-
docker-compose -f docker-compose-xqueue.yml pull
271+
docker-compose $(XQUEUE_COMPOSE_FILE) pull
238272

239273
validate: ## Validate the devstack configuration
240274
docker-compose config
@@ -359,28 +393,27 @@ mongo-shell: ## Run a shell on the mongo container
359393

360394
### analytics pipeline commands
361395

362-
ANALYTICS_COMPOSE_FILES=$(STANDARD_COMPOSE_FILES) -f docker-compose-analytics-pipeline.yml
363396

364397
dev.provision.analytics_pipeline: | check-memory dev.provision.analytics_pipeline.run stop.analytics_pipeline stop ## Provision analyticstack dev environment with all services stopped
365398
echo "Ran dev.provision.analytics_pipeline"
366399

367400
dev.provision.analytics_pipeline.run:
368-
DOCKER_COMPOSE_FILES="$(ANALYTICS_COMPOSE_FILES)" ./provision-analytics-pipeline.sh
401+
DOCKER_COMPOSE_FILES="$(ANALYTICS_COMPOSE_SUITE)" ./provision-analytics-pipeline.sh
369402

370403
analytics-pipeline-shell: ## Run a shell on the analytics pipeline container
371404
docker exec -it edx.devstack.analytics_pipeline env TERM=$(TERM) /edx/app/analytics_pipeline/devstack.sh open
372405

373406
dev.up.analytics_pipeline: | check-memory ## Bring up analytics pipeline services
374-
bash -c 'docker-compose $(ANALYTICS_COMPOSE_FILES) up -d analyticspipeline'
407+
bash -c 'docker-compose $(ANALYTICS_COMPOSE_SUITE) up -d analyticspipeline'
375408

376409
pull.analytics_pipeline: ## Update analytics pipeline docker images
377-
docker-compose -f docker-compose.yml -f docker-compose-analytics-pipeline.yml pull
410+
docker-compose $(ANALYTICS_COMPOSE_SUITE) pull
378411

379412
analytics-pipeline-devstack-test: ## Run analytics pipeline tests in travis build
380413
docker exec -u hadoop -i edx.devstack.analytics_pipeline bash -c 'sudo chown -R hadoop:hadoop /edx/app/analytics_pipeline && source /edx/app/hadoop/.bashrc && make develop-local && make docker-test-acceptance-local ONLY_TESTS=edx.analytics.tasks.tests.acceptance.test_internal_reporting_database && make docker-test-acceptance-local ONLY_TESTS=edx.analytics.tasks.tests.acceptance.test_user_activity'
381414

382415
stop.analytics_pipeline: ## Stop analytics pipeline services
383-
docker-compose -f docker-compose.yml -f docker-compose-analytics-pipeline.yml stop
416+
docker-compose $(ANALYTICS_COMPOSE_SUITE) stop
384417
docker-compose up -d mysql ## restart mysql as other containers need it
385418

386419
hadoop-application-logs-%: ## View hadoop logs by application Id
@@ -407,3 +440,5 @@ stats: ## Get per-container CPU and memory utilization data
407440
feature-toggle-state: ## Gather the state of feature toggles configured for various IDAs
408441
$(WINPTY) bash ./gather-feature-toggle-state.sh
409442

443+
selfcheck: ## check that the Makefile is well-formed
444+
@echo "The Makefile is well-formed."

options.mk

-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ DEVSTACK_WORKSPACE ?= $(shell pwd)/..
1313
# Defaults to 'devstack'.
1414
COMPOSE_PROJECT_NAME=devstack
1515

16-
# Set of Docker Compose YAML files that we use for normal commands.
17-
STANDARD_COMPOSE_FILES=-f docker-compose.yml -f docker-compose-host.yml -f docker-compose-themes.yml
18-
19-
# Set of Docker Compose YAML files that we use for NFS commands.
20-
NFS_COMPOSE_FILES=-f docker-compose.yml -f docker-compose-host-nfs.yml -f docker-compose-themes-nfs.yml
21-
2216
# Whether we should always copy programs to LMS cache upon LMS startup.
2317
# If 'true', then run `make dev.cache-programs` whenever we bring up
2418
# containers.

0 commit comments

Comments
 (0)