2018-11-20 10:24:34 +00:00
|
|
|
|
.PHONY: all android configure build update migrate run
|
2018-09-29 15:08:39 +00:00
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
|
|
2017-12-26 00:16:35 +00:00
|
|
|
|
|
2018-09-04 10:13:18 +00:00
|
|
|
|
PWD ?= $$(pwd)
|
2018-04-30 07:01:40 +00:00
|
|
|
|
USERID ?= $$(id -u)
|
2018-05-16 17:02:44 +00:00
|
|
|
|
EDX_PLATFORM_SETTINGS ?= universal.production
|
2018-08-19 12:40:38 +00:00
|
|
|
|
DOCKER_COMPOSE = docker-compose -f docker-compose.yml
|
2018-09-29 13:51:48 +00:00
|
|
|
|
-include $(PWD)/config/Makefile.env
|
2018-08-19 12:40:38 +00:00
|
|
|
|
|
2018-09-18 18:17:42 +00:00
|
|
|
|
post_configure_targets =
|
|
|
|
|
ifneq ($(DISABLE_STATS), 1)
|
|
|
|
|
post_configure_targets += stats
|
|
|
|
|
endif
|
2018-08-19 12:40:38 +00:00
|
|
|
|
ifeq ($(ACTIVATE_HTTPS), 1)
|
|
|
|
|
post_configure_targets += https-certificate
|
|
|
|
|
endif
|
2018-12-24 07:54:32 +00:00
|
|
|
|
extra_migrate_targets =
|
2018-08-19 12:40:38 +00:00
|
|
|
|
ifeq ($(ACTIVATE_XQUEUE), 1)
|
|
|
|
|
extra_migrate_targets += migrate-xqueue
|
|
|
|
|
DOCKER_COMPOSE += -f docker-compose-xqueue.yml
|
|
|
|
|
endif
|
2018-09-15 13:19:57 +00:00
|
|
|
|
ifeq ($(ACTIVATE_NOTES), 1)
|
|
|
|
|
extra_migrate_targets += migrate-notes
|
|
|
|
|
DOCKER_COMPOSE += -f docker-compose-notes.yml
|
|
|
|
|
endif
|
2018-09-29 13:09:19 +00:00
|
|
|
|
ifeq ($(ACTIVATE_PORTAINER), 1)
|
|
|
|
|
DOCKER_COMPOSE += -f docker-compose-portainer.yml
|
|
|
|
|
endif
|
2018-08-19 12:40:38 +00:00
|
|
|
|
|
|
|
|
|
DOCKER_COMPOSE_RUN = $(DOCKER_COMPOSE) run --rm
|
2018-12-24 07:54:32 +00:00
|
|
|
|
DOCKER_COMPOSE_RUN_OPENEDX = $(DOCKER_COMPOSE_RUN) -e SETTINGS=$(EDX_PLATFORM_SETTINGS) \
|
|
|
|
|
--volume="$(PWD)/openedx/themes:/openedx/themes"
|
2018-04-09 17:16:58 +00:00
|
|
|
|
ifneq ($(EDX_PLATFORM_PATH),)
|
2018-11-23 12:44:47 +00:00
|
|
|
|
DOCKER_COMPOSE_RUN_OPENEDX += -e USERID=$(USERID) --volume="$(EDX_PLATFORM_PATH):/openedx/edx-platform"
|
2018-04-09 17:16:58 +00:00
|
|
|
|
endif
|
|
|
|
|
|
2018-05-27 11:30:23 +00:00
|
|
|
|
DOCKER_COMPOSE_RUN_LMS = $(DOCKER_COMPOSE_RUN_OPENEDX) -p 8000:8000 lms
|
|
|
|
|
DOCKER_COMPOSE_RUN_CMS = $(DOCKER_COMPOSE_RUN_OPENEDX) -p 8001:8001 cms
|
2018-04-09 17:16:58 +00:00
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
##################### Running Open edX
|
|
|
|
|
|
2018-09-29 15:08:39 +00:00
|
|
|
|
# other targets are not listed as requirements in order to reload the env file
|
|
|
|
|
all: configure ## Configure and run a full-featured platform
|
2018-09-29 13:51:48 +00:00
|
|
|
|
@$(MAKE) post_configure
|
|
|
|
|
@$(MAKE) update
|
2018-09-29 15:33:43 +00:00
|
|
|
|
@$(MAKE) databases
|
2018-09-29 13:51:48 +00:00
|
|
|
|
@$(MAKE) assets
|
|
|
|
|
@$(MAKE) daemonize
|
2018-07-16 17:42:39 +00:00
|
|
|
|
@echo "All set \o/ You can access the LMS at http://localhost and the CMS at http://studio.localhost"
|
2017-12-26 00:16:35 +00:00
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
run: ## Run the complete platform
|
|
|
|
|
$(DOCKER_COMPOSE) up
|
|
|
|
|
up: run
|
|
|
|
|
|
|
|
|
|
daemonize: ## Run the complete platform, with daemonization
|
|
|
|
|
$(DOCKER_COMPOSE) up -d
|
|
|
|
|
@echo "Daemon is up and running"
|
|
|
|
|
daemon: daemonize
|
|
|
|
|
|
|
|
|
|
stop: ## Stop all services
|
|
|
|
|
$(DOCKER_COMPOSE) rm --stop --force
|
|
|
|
|
|
|
|
|
|
##################### Configuration
|
2017-12-26 00:16:35 +00:00
|
|
|
|
|
2018-09-29 15:08:39 +00:00
|
|
|
|
configure: build-configurator ## Configure the environment prior to running the platform
|
2018-08-05 14:40:51 +00:00
|
|
|
|
docker run --rm -it --volume="$(PWD)/config:/openedx/config" \
|
2018-09-30 12:27:24 +00:00
|
|
|
|
-e USERID=$(USERID) -e SILENT=$(SILENT) $(CONFIGURE_OPTS) \
|
2018-09-15 14:19:35 +00:00
|
|
|
|
regis/openedx-configurator:hawthorn
|
2018-09-15 09:55:42 +00:00
|
|
|
|
|
2018-09-29 13:51:48 +00:00
|
|
|
|
post_configure: $(post_configure_targets)
|
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
##################### Database
|
2018-09-18 18:17:42 +00:00
|
|
|
|
|
2018-09-29 15:33:43 +00:00
|
|
|
|
databases: provision-databases migrate provision-oauth2 ## Bootstrap databases
|
|
|
|
|
|
|
|
|
|
provision-databases: ## Create necessary databases and users
|
2018-09-16 11:24:17 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN) lms /openedx/config/provision.sh
|
2018-09-29 15:08:39 +00:00
|
|
|
|
provision-oauth2: ## Create users for SSO between services
|
2018-09-15 13:19:57 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN) lms /openedx/config/oauth2.sh
|
2018-08-19 12:40:38 +00:00
|
|
|
|
|
2018-09-29 15:33:43 +00:00
|
|
|
|
migrate: migrate-openedx migrate-forum $(extra_migrate_targets) ## Perform all database migrations
|
2018-09-29 15:08:39 +00:00
|
|
|
|
migrate-openedx: ## Perform database migrations on LMS/CMS
|
2018-09-15 09:55:42 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN) lms bash -c "dockerize -wait tcp://mysql:3306 -timeout 20s && ./manage.py lms migrate"
|
|
|
|
|
$(DOCKER_COMPOSE_RUN) cms bash -c "dockerize -wait tcp://mysql:3306 -timeout 20s && ./manage.py cms migrate"
|
|
|
|
|
$(MAKE) reindex-courses
|
2018-09-29 15:08:39 +00:00
|
|
|
|
migrate-forum: ## Perform database migrations on discussion forums
|
2018-05-27 11:30:23 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN) forum bash -c "bundle exec rake search:initialize && \
|
|
|
|
|
bundle exec rake search:rebuild_index"
|
2018-09-29 15:08:39 +00:00
|
|
|
|
migrate-notes: ## Perform database migrations for the Notes service
|
2018-09-15 13:19:57 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN) notes ./manage.py migrate
|
2018-09-29 15:08:39 +00:00
|
|
|
|
migrate-xqueue: ## Perform database migrations for the XQueue service
|
2018-09-15 09:55:42 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN) xqueue ./manage.py migrate
|
2018-09-29 15:08:39 +00:00
|
|
|
|
reindex-courses: ## Refresh course index so they can be found in the LMS search engine
|
2018-09-15 09:55:42 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN) cms ./manage.py cms reindex_course --all --setup
|
2018-06-02 01:29:53 +00:00
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
##################### Static assets
|
|
|
|
|
|
2018-11-20 10:24:34 +00:00
|
|
|
|
# To collect assets we don't rely on the "paver update_assets" command because
|
|
|
|
|
# webpack collection incorrectly sets the NODE_ENV variable when using custom
|
|
|
|
|
# settings. Thus, each step must be performed separately. This should be fixed
|
|
|
|
|
# in the next edx-platform release thanks to https://github.com/edx/edx-platform/pull/18430/
|
|
|
|
|
|
2018-12-07 18:30:30 +00:00
|
|
|
|
assets: ## Generate production-ready static assets
|
|
|
|
|
docker-compose -f docker-compose-scripts.yml run --rm \
|
2018-12-24 07:54:32 +00:00
|
|
|
|
--volume=$(PWD)/data/openedx:/tmp/openedx/ openedx bash -c \
|
|
|
|
|
"rm -rf /tmp/openedx/staticfiles \
|
|
|
|
|
&& cp -r /openedx/staticfiles /tmp/openedx"
|
|
|
|
|
assets-development: ## Generate static assets for local development
|
|
|
|
|
$(DOCKER_COMPOSE_RUN_OPENEDX) --no-deps lms bash -c "openedx-assets build --env=dev"
|
2018-11-20 10:24:34 +00:00
|
|
|
|
assets-development-lms:
|
2018-12-24 07:54:32 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN_OPENEDX) --no-deps lms bash -c "openedx-assets build --env=dev --system lms"
|
2018-11-20 10:24:34 +00:00
|
|
|
|
assets-development-cms:
|
2018-12-24 07:54:32 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN_OPENEDX) --no-deps lms bash -c "openedx-assets build --env=dev --system cms"
|
|
|
|
|
watch-themes: ## Watch for changes in your themes and build development assets
|
|
|
|
|
$(DOCKER_COMPOSE_RUN_OPENEDX) --no-deps lms openedx-assets watch-themes --env dev
|
2017-12-26 00:16:35 +00:00
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
##################### Information
|
2017-12-26 00:16:35 +00:00
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
# Obtained by running "echo '\033' in a shell
|
|
|
|
|
ESCAPE =
|
|
|
|
|
help: ## Print this help
|
|
|
|
|
@grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \
|
|
|
|
|
| sed 's/######* \(.*\)/\n $(ESCAPE)[1;31m\1$(ESCAPE)[0m/g' \
|
|
|
|
|
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}'
|
2017-12-26 00:16:35 +00:00
|
|
|
|
|
2018-09-29 15:08:39 +00:00
|
|
|
|
info: ## Print some information about the current install, for debugging
|
2018-06-18 12:20:08 +00:00
|
|
|
|
uname -a
|
|
|
|
|
@echo "-------------------------"
|
2018-09-03 05:53:34 +00:00
|
|
|
|
git rev-parse HEAD
|
|
|
|
|
@echo "-------------------------"
|
2018-06-18 12:20:08 +00:00
|
|
|
|
docker version
|
|
|
|
|
@echo "-------------------------"
|
|
|
|
|
docker-compose --version
|
|
|
|
|
@echo "-------------------------"
|
|
|
|
|
echo $$EDX_PLATFORM_PATH
|
|
|
|
|
echo $$EDX_PLATFORM_SETTINGS
|
|
|
|
|
|
2018-09-29 16:01:08 +00:00
|
|
|
|
|
|
|
|
|
#################### Logging
|
|
|
|
|
|
|
|
|
|
logs: ## Print all logs from a service since it started. E.g: "make logs service=lms", "make logs service=nginx"
|
|
|
|
|
$(DOCKER_COMPOSE) logs $(service)
|
|
|
|
|
tail: ## Similar to "tail" on the logs of a service. E.g: "make tail service=lms", "make tail service=nginx"
|
|
|
|
|
$(DOCKER_COMPOSE) logs --tail=10 $(service)
|
|
|
|
|
tail-follow: ## Similar to "tail -f" on the logs of a service. E.g: "make tail-follow service=lms", "make tail-follow service=nginx"
|
|
|
|
|
$(DOCKER_COMPOSE) logs --tail=10 -f $(service)
|
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
#################### Docker image building & updating
|
2018-04-09 17:16:58 +00:00
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
update: ## Download most recent images
|
|
|
|
|
$(DOCKER_COMPOSE) pull
|
2018-04-09 17:16:58 +00:00
|
|
|
|
|
2018-09-29 15:27:38 +00:00
|
|
|
|
build: build-openedx build-configurator build-forum build-notes build-xqueue build-android ## Build all docker images
|
2018-11-26 11:07:58 +00:00
|
|
|
|
|
|
|
|
|
openedx_build_args =
|
|
|
|
|
ifdef EDX_PLATFORM_REPOSITORY
|
|
|
|
|
openedx_build_args += --build-arg="EDX_PLATFORM_REPOSITORY=$(EDX_PLATFORM_REPOSITORY)"
|
|
|
|
|
endif
|
|
|
|
|
ifdef EDX_PLATFORM_VERSION
|
|
|
|
|
openedx_build_args += --build-arg="EDX_PLATFORM_VERSION=$(EDX_PLATFORM_VERSION)"
|
|
|
|
|
endif
|
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
build-openedx: ## Build the Open edX docker image
|
2018-11-26 11:07:58 +00:00
|
|
|
|
docker build -t regis/openedx:latest -t regis/openedx:hawthorn $(openedx_build_args) openedx/
|
2018-09-29 15:22:55 +00:00
|
|
|
|
build-configurator: ## Build the configurator docker image
|
|
|
|
|
docker build -t regis/openedx-configurator:latest -t regis/openedx-configurator:hawthorn configurator/
|
|
|
|
|
build-forum: ## Build the forum docker image
|
|
|
|
|
docker build -t regis/openedx-forum:latest -t regis/openedx-forum:hawthorn forum/
|
|
|
|
|
build-notes: ## Build the Notes docker image
|
|
|
|
|
docker build -t regis/openedx-notes:latest -t regis/openedx-notes:hawthorn notes/
|
|
|
|
|
build-xqueue: ## Build the Xqueue docker image
|
|
|
|
|
docker build -t regis/openedx-xqueue:latest -t regis/openedx-xqueue:hawthorn xqueue/
|
2018-12-24 07:54:32 +00:00
|
|
|
|
build-android: ## Build the docker image for Android
|
2018-09-29 15:27:38 +00:00
|
|
|
|
docker build -t regis/openedx-android:latest android/
|
|
|
|
|
|
|
|
|
|
################### Pushing images to docker hub
|
|
|
|
|
|
2018-09-30 11:49:07 +00:00
|
|
|
|
push: push-openedx push-configurator push-forum push-notes push-xqueue push-android ## Push all images to dockerhub
|
2018-09-29 15:27:38 +00:00
|
|
|
|
push-openedx: ## Push Open edX images to dockerhub
|
|
|
|
|
docker push regis/openedx:hawthorn
|
|
|
|
|
docker push regis/openedx:latest
|
|
|
|
|
push-configurator: ## Push configurator image to dockerhub
|
|
|
|
|
docker push regis/openedx-configurator:hawthorn
|
|
|
|
|
docker push regis/openedx-configurator:latest
|
2018-10-02 16:14:39 +00:00
|
|
|
|
push-forum: ## Push forum image to dockerhub
|
2018-09-29 15:27:38 +00:00
|
|
|
|
docker push regis/openedx-forum:hawthorn
|
|
|
|
|
docker push regis/openedx-forum:latest
|
|
|
|
|
push-notes: ## Push notes image to dockerhub
|
|
|
|
|
docker push regis/openedx-notes:hawthorn
|
|
|
|
|
docker push regis/openedx-notes:latest
|
|
|
|
|
push-xqueue: ## Push Xqueue image to dockerhub
|
|
|
|
|
docker push regis/openedx-xqueue:hawthorn
|
|
|
|
|
docker push regis/openedx-xqueue:latest
|
2018-09-30 11:49:07 +00:00
|
|
|
|
push-android: ## Push the Android image to dockerhub
|
2018-09-29 15:27:38 +00:00
|
|
|
|
docker push regis/openedx-android:latest
|
|
|
|
|
|
|
|
|
|
dockerhub: build push ## Build and push all images to dockerhub
|
2018-08-16 13:59:31 +00:00
|
|
|
|
|
2018-04-09 17:16:58 +00:00
|
|
|
|
##################### Development
|
|
|
|
|
|
2018-09-29 15:08:39 +00:00
|
|
|
|
lms: ## Open a bash shell in the LMS
|
2018-04-09 17:16:58 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN_LMS) bash
|
2018-09-29 15:08:39 +00:00
|
|
|
|
cms: ## Open a bash shell in the CMS
|
2018-04-09 17:16:58 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN_CMS) bash
|
|
|
|
|
|
2018-09-29 15:40:58 +00:00
|
|
|
|
lms-python: ## Open a python shell in the LMS
|
2018-05-27 11:30:23 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN_OPENEDX) lms ./manage.py lms shell
|
2018-09-29 15:40:58 +00:00
|
|
|
|
lms-shell: lms-python
|
2018-12-24 07:54:32 +00:00
|
|
|
|
lms-runserver: ## Run a local webserver, useful for debugging
|
|
|
|
|
$(DOCKER_COMPOSE_RUN_LMS) ./manage.py lms runserver 0.0.0.0:8000
|
2018-09-29 15:40:58 +00:00
|
|
|
|
cms-python: ## Open a python shell in the CMS
|
2018-05-27 11:30:23 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN_OPENEDX) cms ./manage.py cms shell
|
2018-09-29 15:40:58 +00:00
|
|
|
|
cms-shell: cms-python
|
2018-12-24 07:54:32 +00:00
|
|
|
|
cms-runserver: ## Run a local webserver, useful for debugging
|
|
|
|
|
$(DOCKER_COMPOSE_RUN_CMS) ./manage.py cms runserver 0.0.0.0:8001
|
2018-05-16 17:02:44 +00:00
|
|
|
|
|
2018-11-13 19:27:00 +00:00
|
|
|
|
restart-openedx: ## Restart lms, cms, and workers
|
|
|
|
|
docker-compose restart lms lms_worker cms cms_worker
|
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
##################### SSL/TLS (HTTPS certificates)
|
|
|
|
|
|
|
|
|
|
https_command = docker run --rm -it \
|
|
|
|
|
--volume="$(PWD)/config/letsencrypt/:/openedx/letsencrypt/config/" \
|
|
|
|
|
--volume="$(PWD)/data/letsencrypt/:/etc/letsencrypt/" \
|
|
|
|
|
-p "80:80"
|
|
|
|
|
certbot_image = certbot/certbot:latest
|
2018-05-16 17:02:44 +00:00
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
https-certificate: ## Generate https certificates
|
|
|
|
|
$(https_command) --entrypoint "/openedx/letsencrypt/config/certonly.sh" $(certbot_image)
|
|
|
|
|
|
|
|
|
|
https-certificate-renew: ## Renew https certificates
|
|
|
|
|
$(https_command) $(certbot_image) renew
|
|
|
|
|
|
|
|
|
|
#################### Android application
|
2018-05-27 19:29:14 +00:00
|
|
|
|
|
2018-09-29 15:08:39 +00:00
|
|
|
|
android: ## Build the Android app, for development
|
2018-10-03 13:43:21 +00:00
|
|
|
|
@docker-compose -f docker-compose-android.yml run --rm android
|
|
|
|
|
@echo "Your APK file is ready: ./data/android/$(shell ls data/android/*.apk)"
|
2018-05-27 19:29:14 +00:00
|
|
|
|
|
2018-09-29 15:27:38 +00:00
|
|
|
|
android-release: ## Build the final Android app (beta)
|
2018-05-27 19:29:14 +00:00
|
|
|
|
# Note that this requires that you edit ./config/android/gradle.properties
|
|
|
|
|
docker-compose -f docker-compose-android.yml run --rm android ./gradlew assembleProdRelease
|
|
|
|
|
|
2018-09-29 15:22:55 +00:00
|
|
|
|
##################### Additional commands
|
|
|
|
|
|
|
|
|
|
stats: ## Collect anonymous information about the platform
|
|
|
|
|
@docker run --rm -it --volume="$(PWD)/config:/openedx/config" \
|
|
|
|
|
regis/openedx-configurator:hawthorn /openedx/config/openedx/stats 2> /dev/null|| true
|
|
|
|
|
|
|
|
|
|
import-demo-course: ## Import the demo course from edX
|
2018-12-08 17:55:40 +00:00
|
|
|
|
$(DOCKER_COMPOSE_RUN_OPENEDX) cms /bin/bash -c " \
|
|
|
|
|
git clone https://github.com/edx/edx-demo-course --branch open-release/hawthorn.2 --depth 1 ../edx-demo-course \
|
|
|
|
|
&& python ./manage.py cms import ../data ../edx-demo-course"
|
2018-09-29 15:22:55 +00:00
|
|
|
|
|
|
|
|
|
create-staff-user: ## Create a user with admin rights
|
|
|
|
|
$(DOCKER_COMPOSE_RUN_OPENEDX) lms /bin/bash -c "./manage.py lms manage_user --superuser --staff ${USERNAME} ${EMAIL} && ./manage.py lms changepassword ${USERNAME}"
|