Commit d31a6a32 by Brian Beggs Committed by Brian Beggs

Rename clone script, add reset and update db targets

parent 123c8aa1
########################################################################################################################
#
# When adding a new target:
# - If you are adding a new service make sure the dev.clean target will fully reset said service.
#
########################################################################################################################
.DEFAULT_GOAL := help .DEFAULT_GOAL := help
DEVSTACK_WORKSPACE ?= $(shell pwd)/.. DEVSTACK_WORKSPACE ?= $(shell pwd)/..
...@@ -17,13 +23,18 @@ requirements: ## Install requirements ...@@ -17,13 +23,18 @@ requirements: ## Install requirements
pip install -r requirements.txt pip install -r requirements.txt
dev.clone: ## Clone service repos to the parent directory dev.clone: ## Clone service repos to the parent directory
./clone.sh ./repo.sh clone
dev.provision.run: ## Provision all services with local mounted directories dev.provision.run: ## Provision all services with local mounted directories
DOCKER_COMPOSE_FILES="-f docker-compose.yml -f docker-compose-host.yml" ./provision.sh DOCKER_COMPOSE_FILES="-f docker-compose.yml -f docker-compose-host.yml" ./provision.sh
dev.provision: | check-memory dev.provision.run stop ## Provision dev environment with all services stopped dev.provision: | check-memory dev.provision.run stop ## Provision dev environment with all services stopped
dev.reset: | down dev.repo.reset pull dev.up static update-db ## Attempts to reset the local devstack to a the master working state
dev.repo.reset: ## Attempts to reset the local repo checkouts to the master working state
./repo.sh reset
dev.up: | check-memory ## Bring up all services with host volumes dev.up: | check-memory ## Bring up all services with host volumes
docker-compose -f docker-compose.yml -f docker-compose-host.yml up -d docker-compose -f docker-compose.yml -f docker-compose-host.yml up -d
...@@ -91,6 +102,20 @@ e2e-shell: ## Start the end-to-end tests container with a shell ...@@ -91,6 +102,20 @@ e2e-shell: ## Start the end-to-end tests container with a shell
forum-shell: ## Run a shell on the forum container forum-shell: ## Run a shell on the forum container
docker exec -it edx.devstack.forum env TERM=$(TERM) bash docker exec -it edx.devstack.forum env TERM=$(TERM) bash
%-update-db: ## Run migrations for the specified service container
docker exec -t edx.devstack.$* bash -c 'source /edx/app/$*/$*_env && cd /edx/app/$*/$*/ && make migrate'
studio-update-db: ## Run migrations for the Studio container
docker exec -t edx.devstack.studio bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && paver update_db'
lms-update-db: ## Run migrations LMS container
docker exec -t edx.devstack.lms bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && paver update_db'
credentials-update-db: ## Run migrations for the credentials container
docker exec -t edx.devstack.credentials bash -c 'make migrate'
update-db: | studio-update-db lms-update-db discovery-update-db ecommerce-update-db credentials-update-db ## Run the migrations for all services
lms-shell: ## Run a shell on the LMS container lms-shell: ## Run a shell on the LMS container
docker exec -it edx.devstack.lms env TERM=$(TERM) /edx/app/edxapp/devstack.sh open docker exec -it edx.devstack.lms env TERM=$(TERM) /edx/app/edxapp/devstack.sh open
...@@ -149,3 +174,4 @@ build-courses: ## NOTE: marketing course creation is not available for those out ...@@ -149,3 +174,4 @@ build-courses: ## NOTE: marketing course creation is not available for those out
check-memory: check-memory:
@if [ `docker info --format '{{json .}}' | python -c "from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['MemTotal'])"` -lt 2147483648 ]; then echo "\033[0;31mWarning, System Memory is set too low!!! Increase Docker memory to be at least 2 Gigs\033[0m"; fi || exit 0 @if [ `docker info --format '{{json .}}' | python -c "from __future__ import print_function; import sys, json; print(json.load(sys.stdin)['MemTotal'])"` -lt 2147483648 ]; then echo "\033[0;31mWarning, System Memory is set too low!!! Increase Docker memory to be at least 2 Gigs\033[0m"; fi || exit 0
...@@ -555,6 +555,21 @@ Sometimes containers end up in strange states and need to be rebuilt. Run ...@@ -555,6 +555,21 @@ Sometimes containers end up in strange states and need to be rebuilt. Run
``make down`` to remove all containers and networks. This will **NOT** remove your ``make down`` to remove all containers and networks. This will **NOT** remove your
data volumes. data volumes.
Reset
~~~~~
Somtimes you just aren't sure what's wrong, if you would like to hit the reset button
run ``make dev.reset``.
Running this command will perform the following steps:
* Bring down all containers
* Reset all git repositories to the HEAD of master
* Pull new images for all services
* Compile static assets for all services
* Run migrations for all services
It's good to run this before asking for help.
Start over Start over
~~~~~~~~~~ ~~~~~~~~~~
......
#!/usr/bin/env bash #!/usr/bin/env bash
# Script for cloning Git repos housing edX services. These repos are mounted as set -e
set -o pipefail
# Script for Git repos housing edX services. These repos are mounted as
# data volumes into their corresponding Docker containers to facilitate development. # data volumes into their corresponding Docker containers to facilitate development.
# Repos are cloned to the directory above the one housing this file. # Repos are cloned to/removed from the directory above the one housing this file.
if [ -z "$DEVSTACK_WORKSPACE" ]; then if [ -z "$DEVSTACK_WORKSPACE" ]; then
echo "need to set workspace dir" echo "need to set workspace dir"
...@@ -25,21 +28,51 @@ repos=( ...@@ -25,21 +28,51 @@ repos=(
name_pattern=".*edx/(.*).git" name_pattern=".*edx/(.*).git"
for repo in ${repos[*]} clone ()
do {
# Use Bash's regex match operator to capture the name of the repo. for repo in ${repos[*]}
# Results of the match are saved to an array called $BASH_REMATCH. do
[[ $repo =~ $name_pattern ]] # Use Bash's regex match operator to capture the name of the repo.
name="${BASH_REMATCH[1]}" # Results of the match are saved to an array called $BASH_REMATCH.
[[ $repo =~ $name_pattern ]]
if [ -d "$name" ]; then name="${BASH_REMATCH[1]}"
printf "The [%s] repo is already checked out. Continuing.\n" $name
else if [ -d "$name" ]; then
if [ "${SHALLOW_CLONE}" == "1" ]; then printf "The [%s] repo is already checked out. Continuing.\n" $name
git clone --depth=1 $repo
else else
git clone $repo if [ "${SHALLOW_CLONE}" == "1" ]; then
git clone --depth=1 $repo
else
git clone $repo
fi
fi fi
done
cd - &> /dev/null
}
reset ()
{
currDir=$(pwd)
for repo in ${repos[*]}
do
[[ $repo =~ $name_pattern ]]
name="${BASH_REMATCH[1]}"
if [ -d "$name" ]; then
cd $name;git reset --hard HEAD;git checkout master;git pull;cd "$currDir"
else
printf "The [%s] repo is not cloned. Continuing.\n" $name
fi
done
cd - &> /dev/null
}
if [ "$1" == "clone" ]; then
clone
elif [ "$1" == "reset" ]; then
read -p "This will override any uncommited changes in your local git checkouts. Would you like to proceed? [y/n] " -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
reset
fi fi
done fi
cd - &> /dev/null
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment