6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-11-15 17:47:13 +00:00

Make it possible to override dev project name

This commit is contained in:
Régis Behmo 2020-01-08 14:36:51 +01:00
parent 49a7946d67
commit cc649e7378
2 changed files with 38 additions and 12 deletions

View File

@ -1,5 +1,6 @@
import click import click
from .. import config as tutor_config
from .. import env as tutor_env from .. import env as tutor_env
from .. import fmt from .. import fmt
from .. import utils from .. import utils
@ -27,6 +28,24 @@ edx_platform_development_settings_option = click.option(
) )
@click.command(
help="Run all or a selection of configured Open edX services in development mode"
)
@click.option("-d", "--detach", is_flag=True, help="Start in daemon mode")
@click.argument("services", metavar="service", nargs=-1)
@click.pass_obj
def start(context, detach, services):
"""
TODO document this
"""
command = ["up", "--remove-orphans"]
if detach:
command.append("-d")
config = tutor_config.load(context.root)
docker_compose(context.root, config, *command, *services)
@click.command( @click.command(
help="Run a command in one of the containers", help="Run a command in one of the containers",
context_settings={"ignore_unknown_options": True}, context_settings={"ignore_unknown_options": True},
@ -43,8 +62,10 @@ def run(context, edx_platform_path, edx_platform_settings, service, command, arg
run_command.append(command) run_command.append(command)
if args: if args:
run_command += args run_command += args
config = tutor_config.load(context.root)
docker_compose_run( docker_compose_run(
context.root, edx_platform_path, edx_platform_settings, *run_command context.root, config, edx_platform_path, edx_platform_settings, *run_command
) )
@ -61,7 +82,9 @@ def execute(context, service, command, args):
exec_command = ["exec", service, command] exec_command = ["exec", service, command]
if args: if args:
exec_command += args exec_command += args
docker_compose(context.root, *exec_command)
config = tutor_config.load(context.root)
docker_compose(context.root, config, *exec_command)
@click.command(help="Run a development server") @click.command(help="Run a development server")
@ -70,13 +93,15 @@ def execute(context, service, command, args):
@click.argument("service", type=click.Choice(["lms", "cms"])) @click.argument("service", type=click.Choice(["lms", "cms"]))
@click.pass_obj @click.pass_obj
def runserver(context, edx_platform_path, edx_platform_settings, service): def runserver(context, edx_platform_path, edx_platform_settings, service):
port = service_port(service) port = 8000 if service == "lms" else 8001
fmt.echo_info( fmt.echo_info(
"The {} service will be available at http://localhost:{}".format(service, port) "The {} service will be available at http://localhost:{}".format(service, port)
) )
config = tutor_config.load(context.root)
docker_compose_run( docker_compose_run(
context.root, context.root,
config,
edx_platform_path, edx_platform_path,
edx_platform_settings, edx_platform_settings,
"-p", "-p",
@ -92,33 +117,33 @@ def runserver(context, edx_platform_path, edx_platform_settings, service):
@click.command(help="Stop a running development platform") @click.command(help="Stop a running development platform")
@click.pass_obj @click.pass_obj
def stop(context): def stop(context):
docker_compose(context.root, "rm", "--stop", "--force") config = tutor_config.load(context.root)
docker_compose(context.root, config, "rm", "--stop", "--force")
def docker_compose_run(root, edx_platform_path, edx_platform_settings, *command): def docker_compose_run(
root, config, edx_platform_path, edx_platform_settings, *command
):
run_command = ["run", "--rm", "-e", "SETTINGS={}".format(edx_platform_settings)] run_command = ["run", "--rm", "-e", "SETTINGS={}".format(edx_platform_settings)]
if edx_platform_path: if edx_platform_path:
run_command += ["--volume={}:/openedx/edx-platform".format(edx_platform_path)] run_command += ["--volume={}:/openedx/edx-platform".format(edx_platform_path)]
run_command += command run_command += command
docker_compose(root, *run_command) docker_compose(root, config, *run_command)
def docker_compose(root, *command): def docker_compose(root, config, *command):
return utils.docker_compose( return utils.docker_compose(
"-f", "-f",
tutor_env.pathjoin(root, "local", "docker-compose.yml"), tutor_env.pathjoin(root, "local", "docker-compose.yml"),
"-f", "-f",
tutor_env.pathjoin(root, "dev", "docker-compose.yml"), tutor_env.pathjoin(root, "dev", "docker-compose.yml"),
"--project-name", "--project-name",
"tutor_dev", config["DEV_PROJECT_NAME"],
*command *command
) )
def service_port(service): dev.add_command(start)
return 8000 if service == "lms" else 8001
dev.add_command(run) dev.add_command(run)
dev.add_command(execute) dev.add_command(execute)
dev.add_command(runserver) dev.add_command(runserver)

View File

@ -27,6 +27,7 @@ OPENEDX_AWS_SECRET_ACCESS_KEY: ""
ANDROID_RELEASE_STORE_PASSWORD: "android store password" ANDROID_RELEASE_STORE_PASSWORD: "android store password"
ANDROID_RELEASE_KEY_PASSWORD: "android release key password" ANDROID_RELEASE_KEY_PASSWORD: "android release key password"
ANDROID_RELEASE_KEY_ALIAS: "android release key alias" ANDROID_RELEASE_KEY_ALIAS: "android release key alias"
DEV_PROJECT_NAME: "tutor_dev"
DOCKER_IMAGE_OPENEDX: "overhangio/openedx:{{ TUTOR_VERSION }}" DOCKER_IMAGE_OPENEDX: "overhangio/openedx:{{ TUTOR_VERSION }}"
DOCKER_IMAGE_OPENEDX_DEV: "overhangio/openedx-dev:{{ TUTOR_VERSION }}" DOCKER_IMAGE_OPENEDX_DEV: "overhangio/openedx-dev:{{ TUTOR_VERSION }}"
DOCKER_IMAGE_ANDROID: "overhangio/openedx-android:{{ TUTOR_VERSION }}" DOCKER_IMAGE_ANDROID: "overhangio/openedx-android:{{ TUTOR_VERSION }}"