Ejemplo n.º 1
0
def ddc_project():
    """Proxy for docker-compose: writes a docker-compose.yml file with the
    configuration of this project, and then run `docker-compose` on it.

    You probably want do run `ddc-project up -d` and `ddc-project logs -f`.
    """
    check_docker()
    setup_logging()
    try:
        project = Project()
    except ValueError:
        click.echo("You need to run this command in a derex project")
        sys.exit(1)
    compose_args, dry_run = ddc_parse_args(sys.argv)
    # If trying to start up containers, first check that needed services are running
    is_start_cmd = any(param in compose_args for param in ["up", "start"])
    if is_start_cmd and not check_services(["mysql", "mongodb", "rabbitmq"]):
        click.echo(
            "Mysql/mongo/rabbitmq services not found.\nMaybe you forgot to run\nddc-services up -d"
        )
        return
    run_compose(list(compose_args),
                project=project,
                dry_run=dry_run,
                exit_afterwards=True)
Ejemplo n.º 2
0
def ddc_services():
    """Derex docker-compose: run docker-compose with additional parameters.
    Adds docker compose file paths for services and administrative tools.
    If the environment variable DEREX_ADMIN_SERVICES is set to a falsey value,
    only the core ones will be started (mysql, mongodb etc) and the nice-to-have
    will not (portainer and adminer).

    Besides the regular docker-compose options it also accepts the --dry-run
    option; in case it's specified docker-compose will not be invoked, but
    a line will be printed showing what would have been invoked.
    """
    check_docker()
    setup_logging()
    args, dry_run = ddc_parse_args(sys.argv)
    run_compose(args, dry_run=dry_run, exit_afterwards=True)
Ejemplo n.º 3
0
def ddc_project():
    """Proxy for docker-compose: writes a docker-compose.yml file with the
    configuration of this project, and then run `docker-compose` on it.

    You probably want do run `ddc-project up -d` and `ddc-project logs -f`.
    """
    check_docker()
    setup_logging()
    try:
        project = Project()
    except ValueError as exc:
        click.echo(str(exc))
        sys.exit(1)
    compose_args, dry_run = ddc_parse_args(sys.argv)
    # If trying to start up containers, first check that needed services are running
    is_start_cmd = any(param in compose_args for param in ["up", "start"])
    if is_start_cmd:
        for service in ["mysql", "mongodb", "rabbitmq"]:
            try:
                wait_for_service(service)
            except (TimeoutError, RuntimeError, NotImplementedError) as exc:
                click.echo(click.style(str(exc), fg="red"))
                sys.exit(1)
    run_ddc_project(list(compose_args), project, dry_run=dry_run, exit_afterwards=True)