Skip to content

Commit

Permalink
Clean up Make targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Renzo Lucioni committed Apr 5, 2017
1 parent 0e4c0e0 commit 84cd85c
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
.PHONY: clone devstack.provision devstack.reset devstack.start devstack.stop help requirements update-images validate

backup-volumes: ## Backup all data volumes to the local host
docker run --rm --volumes-from edx.devstack.mysql -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/mysql.tar.gz /var/lib/mysql
docker run --rm --volumes-from edx.devstack.mongo -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/mongo.tar.gz /data/db
docker run --rm --volumes-from edx.devstack.elasticsearch -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/elasticsearch.tar.gz /usr/share/elasticsearch/data

restore-volumes: ## WARNING: THIS WILL OVERWRITE ALL EXISTING DATA!!! Restore all data volumes from the local host.
docker run --rm --volumes-from edx.devstack.mysql -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/mysql.tar.gz
docker run --rm --volumes-from edx.devstack.mongo -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/mongo.tar.gz
docker run --rm --volumes-from edx.devstack.elasticsearch -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/elasticsearch.tar.gz

.DEFAULT_GOAL := help

# Generates a help message. Borrowed from https://github.com/pydanny/cookiecutter-djangopackage.
help: ## Display this help message
@echo "Please use \`make <target>' where <target> is one of"
@perl -nle'print $& if m{^[\.a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'

clone: ## Clone service repos
./clone.sh

devstack.destroy: ## Destroy all containers and volumes
./destroy.sh

# TODO Print out help for this target. Even better if we can iterate over the services in docker-compose.yml, and
# print the actual service names.
devstack.open.%: ## Open a shell into the specified service container
docker exec -it edx.devstack.$* env TERM=$(TERM) /edx/app/$*/devstack.sh open

devstack.open.lms: ## Open a shell into the LMS container
docker exec -it edx.devstack.lms env TERM=$(TERM) /edx/app/edxapp/devstack.sh open
requirements: ## Install requirements
pip install -r requirements.txt

devstack.open.studio: ## Open a shell into the Studio container
docker exec -it edx.devstack.studio env TERM=$(TERM) /edx/app/edxapp/devstack.sh open
clone: ## Clone service repos to the parent directory
./clone.sh

devstack.provision: ## Provision all services
provision: ## Provision all services
./provision.sh

devstack.reset: ## Remove all service containers
docker-compose down

devstack.start: ## Start all services (with host volumes)
up: ## Bring up all services with host volumes
docker-compose -f docker-compose.yml -f docker-compose-host.yml up

devstack.start.sync: ## Start all services (with docker-sync)
up-sync: ## Bring up all services with docker-sync
docker-sync-stack start

devstack.stop: ## Stop all services
stop: ## Stop all services
docker-compose stop

requirements: ## Install requirements
pip install -r requirements.txt
down: ## Remove all service containers and networks
docker-compose down

destroy: ## Remove all devstack-related containers, networks, and volumes
./destroy.sh

update-images: ## Update the Docker images
pull: ## Update Docker images
docker-compose pull

validate: ## Validate the devstack configuration
docker-compose config

backup: ## Write all data volumes to the host.
docker run --rm --volumes-from edx.devstack.mysql -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/mysql.tar.gz /var/lib/mysql
docker run --rm --volumes-from edx.devstack.mongo -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/mongo.tar.gz /data/db
docker run --rm --volumes-from edx.devstack.elasticsearch -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/elasticsearch.tar.gz /usr/share/elasticsearch/data

restore: ## Restore all data volumes from the host. WARNING: THIS WILL OVERWRITE ALL EXISTING DATA!
docker run --rm --volumes-from edx.devstack.mysql -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/mysql.tar.gz
docker run --rm --volumes-from edx.devstack.mongo -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/mongo.tar.gz
docker run --rm --volumes-from edx.devstack.elasticsearch -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/elasticsearch.tar.gz

# TODO: Print out help for this target. Even better if we can iterate over the
# services in docker-compose.yml, and print the actual service names.
%-shell: ## Run a shell on the specified service container
docker exec -it edx.devstack.$* env TERM=$(TERM) /edx/app/$*/devstack.sh open

lms-shell: ## Run a shell on the LMS container
docker exec -it edx.devstack.lms env TERM=$(TERM) /edx/app/edxapp/devstack.sh open

studio-shell: ## Run a shell on the Studio container
docker exec -it edx.devstack.studio env TERM=$(TERM) /edx/app/edxapp/devstack.sh open

0 comments on commit 84cd85c

Please sign in to comment.