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 help: ## Display this help message
@echo "Please use \`make <target>' where <target> is one of" @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}' @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 # 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. # 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 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 docker-compose down
devstack.start: ## Start all services devstack.start: clone ## Start all services
docker-compose up docker-compose up
devstack.stop: ## Stop all services devstack.stop: ## Stop all services
......
...@@ -11,6 +11,7 @@ above the one housing this file. ...@@ -11,6 +11,7 @@ above the one housing this file.
import concurrent.futures import concurrent.futures
import logging import logging
from logging.config import dictConfig from logging.config import dictConfig
import os
from os.path import join, abspath, dirname from os.path import join, abspath, dirname
import re import re
import subprocess import subprocess
...@@ -52,27 +53,29 @@ class Repo: ...@@ -52,27 +53,29 @@ class Repo:
match = re.match(r'.*edx/(?P<name>.*).git', self.clone_url) match = re.match(r'.*edx/(?P<name>.*).git', self.clone_url)
self.name = match.group('name') self.name = match.group('name')
parent_path = dirname(dirname(abspath(__file__)))
self.path = join(parent_path, self.name)
def clone(self): def clone(self):
"""Clone the repo.""" """Clone the repo."""
parent_path = dirname(dirname(abspath(__file__))) subprocess.run(['git', 'clone', self.clone_url, self.path], check=True)
clone_path = join(parent_path, self.name)
subprocess.run(['git', 'clone', self.clone_url, clone_path], check=True) @property
def exists(self):
"""Determine if the repo is already checked out."""
return os.path.exists(self.path)
if __name__ == '__main__': if __name__ == '__main__':
with open('settings.yml') as f: with open('settings.yml') as f:
settings = yaml.load(f) settings = yaml.load(f)
with concurrent.futures.ThreadPoolExecutor() as executor:
repos = [Repo(clone_url) for clone_url in settings['repos']] 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: 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) executor.submit(repo.clone)
logger.info('Cloning complete.')
...@@ -56,6 +56,8 @@ services: ...@@ -56,6 +56,8 @@ services:
image: edxops/credentials:latest image: edxops/credentials:latest
ports: ports:
- "18150:18150" - "18150:18150"
volumes:
- ../credentials:/edx/app/credentials/credentials
discovery: discovery:
command: /edx/app/discovery/devstack.sh start command: /edx/app/discovery/devstack.sh start
...@@ -70,6 +72,8 @@ services: ...@@ -70,6 +72,8 @@ services:
image: edxops/discovery:latest image: edxops/discovery:latest
ports: ports:
- "18381:18381" - "18381:18381"
volumes:
- ../course-discovery:/edx/app/discovery/discovery
ecommerce: ecommerce:
command: /edx/app/ecommerce/devstack.sh start command: /edx/app/ecommerce/devstack.sh start
...@@ -83,6 +87,8 @@ services: ...@@ -83,6 +87,8 @@ services:
image: edxops/ecommerce:latest image: edxops/ecommerce:latest
ports: ports:
- "18130:18130" - "18130:18130"
volumes:
- ../ecommerce:/edx/app/ecommerce/ecommerce
programs: programs:
command: /edx/app/programs/devstack.sh start command: /edx/app/programs/devstack.sh start
...@@ -95,3 +101,5 @@ services: ...@@ -95,3 +101,5 @@ services:
image: edxops/programs:latest image: edxops/programs:latest
ports: ports:
- "18140:18140" - "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