Commit 3949de3e by Renzo Lucioni

Mount service source code into corresponding containers

Also ties in the clone script: repos are cloned if they don't exist when starting and opening devstack.

ECOM-6583
parent 802e33a1
.PHONY: devstack.reset devstack.start devstack.stop help requirements validate
.PHONY: clone devstack.reset devstack.start devstack.stop help requirements validate
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.py
# 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
devstack.open.%: clone ## Open a shell into the specified service container
docker exec -it edx.devstack.$* env TERM=$(TERM) /edx/app/$*/devstack.sh open
devstack.reset: ## Remove all service containers
devstack.reset: ## Remove all service containers
docker-compose down
devstack.start: ## Start all services
devstack.start: clone ## Start all services
docker-compose up
devstack.stop: ## Stop all services
devstack.stop: ## Stop all services
docker-compose stop
requirements: ## Install requirements
requirements: ## Install requirements
pip install -r requirements.txt
validate: ## Validate the devstack configuration
validate: ## Validate the devstack configuration
docker-compose config
......@@ -11,6 +11,7 @@ above the one housing this file.
import concurrent.futures
import logging
from logging.config import dictConfig
import os
from os.path import join, abspath, dirname
import re
import subprocess
......@@ -52,27 +53,29 @@ class Repo:
match = re.match(r'.*edx/(?P<name>.*).git', self.clone_url)
self.name = match.group('name')
parent_path = dirname(dirname(abspath(__file__)))
self.path = join(parent_path, self.name)
def clone(self):
"""Clone the repo."""
parent_path = dirname(dirname(abspath(__file__)))
clone_path = join(parent_path, self.name)
subprocess.run(['git', 'clone', self.clone_url, clone_path], check=True)
subprocess.run(['git', 'clone', self.clone_url, self.path], check=True)
@property
def exists(self):
"""Determine if the repo is already checked out."""
return os.path.exists(self.path)
if __name__ == '__main__':
with open('settings.yml') as f:
settings = yaml.load(f)
repos = [Repo(clone_url) for clone_url in settings['repos']]
logger.info(
'Cloning. Target repos are: {}.'.format(
', '.join(repo.name for repo in repos)
)
)
with concurrent.futures.ThreadPoolExecutor() as executor:
for repo in repos:
executor.submit(repo.clone)
repos = [Repo(clone_url) for clone_url in settings['repos']]
logger.info('Cloning complete.')
for repo in repos:
if repo.exists:
logger.info('Repo [{name}] found at [{path}].'.format(name=repo.name, path=repo.path))
else:
logger.info('Repo [{name}] not found. Cloning to [{path}].'.format(name=repo.name, path=repo.path))
executor.submit(repo.clone)
......@@ -56,6 +56,8 @@ services:
image: edxops/credentials:latest
ports:
- "18150:18150"
volumes:
- ../credentials:/edx/app/credentials/credentials
discovery:
command: /edx/app/discovery/devstack.sh start
......@@ -70,6 +72,8 @@ services:
image: edxops/discovery:latest
ports:
- "18381:18381"
volumes:
- ../course-discovery:/edx/app/discovery/discovery
ecommerce:
command: /edx/app/ecommerce/devstack.sh start
......@@ -83,6 +87,8 @@ services:
image: edxops/ecommerce:latest
ports:
- "18130:18130"
volumes:
- ../ecommerce:/edx/app/ecommerce/ecommerce
programs:
command: /edx/app/programs/devstack.sh start
......@@ -95,3 +101,5 @@ services:
image: edxops/programs:latest
ports:
- "18140:18140"
volumes:
- ../programs:/edx/app/programs/programs
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