Пример #1
0
    def get_url(self, service_url: str, service: str):
        """Build URL to be displayed."""
        proxy_conf = self.config['proxy']
        # By default our URL is the IP
        url = docker.get_ct_item(service, 'ip')
        # If proxy enabled, display nice urls
        if bool(proxy_conf['enabled']):
            http_port = int(proxy_conf['http_port'])
            url = docker.get_ct_item(service, 'traefik_host').lower()
            url += '' if http_port == 80 else ':{}'.format(http_port)
        elif os_name() in ['Windows', 'Darwin']:
            puts(colored.yellow('[WARNING]') + ' Under Win and Mac, you need the proxy enabled')

        return service_url.format(url)
Пример #2
0
def get_url(service_url: str, service: str, dns_started: bool):
    """Build URL to be displayed"""

    service_name = docker_actions.get_ct_name(service)
    service_ip = docker_actions.get_ct_item(service, 'ip')

    return service_url.format(service_name if dns_started else service_ip)
Пример #3
0
def get_url(service_url: str, service: str, dns_started: bool):
    """Build URL to be displayed"""

    service_name = docker_actions.get_ct_name(service)
    service_ip = docker_actions.get_ct_item(service, 'ip')

    return service_url.format(service_name if dns_started else service_ip)
Пример #4
0
    def get_url(self, service_url: str, service: str):
        """Build URL to be displayed."""
        proxy_conf = self.config['proxy']
        # By default our URL is the IP
        url = docker.get_ct_item(service, 'ip')
        # If proxy enabled, display nice urls
        if bool(proxy_conf['enabled']):
            http_port = int(proxy_conf['http_port'])
            url = docker.get_ct_item(service, 'traefik_host').lower()
            url += '' if http_port == 80 else ':{}'.format(http_port)
        elif os_name() in ['Windows', 'Darwin']:
            puts(
                colored.yellow('[WARNING]') +
                ' Under Win and Mac, you need the proxy enabled')

        return service_url.format(url)
Пример #5
0
 def _call_service_post_script(self, service: str):
     service_script = package_utils.get_file(
         'static', 'services/{}.sh'.format(service))
     if os.path.isfile(service_script) is True:
         cmd = ['bash', service_script, docker.get_ct_item(service, 'name')]
         subprocess.call(cmd)
         command.verbose(self.context['VERBOSE'],
                         'Service Script : ' + ' '.join(cmd))
Пример #6
0
def get_url(ports: list, service_url: str, service: str):
    """Build URL to be displayed"""

    # If not linux, I can't use IPs so display only exposed ports
    if ports and os_name() in ['Windows', 'Darwin']:
        main_port = ports[0]
        ports.remove(main_port)
        return 'http://localhost:{}'.format(main_port) + ' or '.join(ports)

    return service_url.format(docker_actions.get_ct_item(service, 'ip'))
Пример #7
0
def sugarcli(ctx, run_args: tuple):
    run_args = ' '.join(run_args)

    stakkr = ctx.obj['STAKKR']
    docker_actions.check_cts_are_running(stakkr.project_name)

    if stakkr.cwd_abs.find(stakkr.stakkr_base_dir) != 0:
        raise Exception('You are not in a sub-directory of your stakkr instance')

    sugarcli_wrapper.run(docker_actions.get_ct_item('php', 'name'), stakkr.cwd_relative, run_args)
Пример #8
0
    def _is_up(self, container: str):
        try:
            docker.check_cts_are_running(self.project_name)
        except SystemError:
            return

        if container is None:
            puts(colored.yellow('[INFO]') + ' stakkr is already started ...')
            sys.exit(0)

        # If single container : check if that specific one is running
        ct_name = docker.get_ct_item(container, 'name')
        if docker.container_running(ct_name):
            puts(colored.yellow('[INFO]') + ' service {} is already started ...'.format(container))
            sys.exit(0)
Пример #9
0
    def _is_containers_running(self, container: str):

        try:
            docker_actions.check_cts_are_running(self.project_name)
        except SystemError:
            return

        if container is None:
            puts(colored.yellow('[INFO]') + ' stakkr is already started ...')
            sys.exit(0)

        # If single container : check if that specific one is running
        ct_name = docker_actions.get_ct_item(container, 'name')
        if docker_actions.container_running(ct_name):
            puts(colored.yellow('[INFO]') + ' service {} is already started ...'.format(container))
            sys.exit(0)
Пример #10
0
def run(stakkr, composer_cmd: str):
    ct_name = docker_actions.get_ct_item('php', 'name')
    relative_dir = stakkr.cwd_relative

    if relative_dir.startswith('www') is False:
        print(click.style('You can run composer only from a subdirectory of www', fg='red'))
        sys.exit(1)

    home = get_venv_basedir() + '/home/www-data'
    if os.path.isdir(home) and not os.path.isdir(home + '/bin'):
        os.mkdir(home + '/bin')

    download_composer(home + '/bin', ct_name)

    tty = 't' if sys.stdin.isatty() else ''
    cmd = ['docker', 'exec', '-u', 'www-data', '-i' + tty, ct_name]
    cmd += ['bash', '-c', '--']
    cmd += ['cd /var/' + relative_dir + '; exec /usr/bin/php ~/bin/composer {}'.format(composer_cmd)]
    subprocess.call(cmd, stdin=sys.stdin, stderr=subprocess.STDOUT)
Пример #11
0
def run(stakkr, composer_cmd: str):
    ct_name = docker_actions.get_ct_item('php', 'name')
    relative_dir = stakkr.cwd_relative

    if relative_dir.startswith('www') is False:
        print(
            click.style('You can run composer only from a subdirectory of www',
                        fg='red'))
        sys.exit(1)

    home = get_venv_basedir() + '/home/www-data'
    if os.path.isdir(home) and not os.path.isdir(home + '/bin'):
        os.mkdir(home + '/bin')

    download_composer(home + '/bin', ct_name)

    tty = 't' if sys.stdin.isatty() else ''
    cmd = ['docker', 'exec', '-u', 'www-data', '-i' + tty, ct_name]
    cmd += ['bash', '-c', '--']
    cmd += [
        'cd /var/' + relative_dir +
        '; exec /usr/bin/php ~/bin/composer {}'.format(composer_cmd)
    ]
    subprocess.call(cmd, stdin=sys.stdin, stderr=subprocess.STDOUT)
Пример #12
0
 def _call_service_post_script(self, service: str):
     service_script = package_utils.get_file('static', 'services/{}.sh'.format(service))
     if os.path.isfile(service_script) is True:
         cmd = ['bash', service_script, docker_actions.get_ct_item(service, 'name')]
         subprocess.call(cmd)
         command.verbose(self.context['VERBOSE'], 'Service Script : ' + ' '.join(cmd))