Пример #1
0
def docker(obj, docker_host, docker_username, docker_password, name, tag,
           variant, no_variant, arch, system, distro):
    """Subcommand to build docker images for the docker builders

    It loads the docker images defined in the master's configuration.
    MasterConfig aggregates the available docker images from the passed
    projects.
    """
    config = obj['config']
    if obj['verbose']:
        logging.getLogger('dockermap').setLevel(logging.INFO)

    client = DockerClientWrapper(docker_host)
    if docker_username is not None:
        client.login(username=docker_username, password=docker_password)

    if no_variant:
        variant = None

    image_filter = Filter(name=Matching(name),
                          tag=Matching(tag),
                          variant=Matching(variant),
                          platform=Filter(arch=Matching(arch),
                                          system=Matching(system),
                                          distro=Matching(distro)))
    filtered = ImageCollection(i for i in config.images if image_filter(i))

    obj['client'] = client
    obj['images'] = filtered
Пример #2
0
Файл: cli.py Проект: kou/ursabot
def docker(obj, docker_host, docker_username, docker_password, **kwargs):
    """Subcommand to build docker images for the docker builders

    It loads the docker images defined in the master's configuration.
    MasterConfig aggregates the available docker images from the passed
    projects.
    """
    config = obj['config']
    if obj['verbose']:
        logging.getLogger('dockermap').setLevel(logging.INFO)

    client = DockerClientWrapper(docker_host)
    if docker_username is not None:
        client.login(username=docker_username, password=docker_password)

    def match(value, filter):
        """Enable glob-style pattern matching on docker proerties"""
        if isinstance(value, str):
            return fnmatch(value, filter)
        else:
            return value == filter

    images = config.images.filter(**{
        k: partial(match, filter=f)
        for k, f in kwargs.items() if f is not None
    })

    obj['client'] = client
    obj['images'] = images
Пример #3
0
def docker(ctx, docker_host, docker_username, docker_password, **kwargs):
    """Subcommand to build docker images for the docker builders"""
    if ctx.obj['verbose']:
        logging.getLogger('dockermap').setLevel(logging.INFO)

    client = DockerClientWrapper(docker_host)
    if docker_username is not None:
        client.login(username=docker_username, password=docker_password)

    filters = toolz.valfilter(lambda x: x is not None, kwargs)
    docker_images = images.filter(**filters)

    ctx.obj['client'] = client
    ctx.obj['images'] = docker_images
Пример #4
0
def locally():
    """Local development environment"""
    env.docker = DockerClientWrapper('unix://var/run/docker.sock')
    bootstrap_environment('local')
    env.project_path = '/home/{user}/{{cookiecutter.app_name}}'.format(**env)
    env.map_client = MappingDockerClient(
        env.container_map,
        env.container_config,
        clients={'__default__': env.container_config})
    env.run = local
Пример #5
0
def testing():
    """Local testing environment"""
    env.docker = DockerClientWrapper('unix://var/run/docker.sock')
    bootstrap_environment('testing')
    env.project_path = '/home/{user}/jenkins-test'.format(**env)
    env.map_client = MappingDockerClient(
        env.container_map,
        env.container_config,
        clients={'__default__': env.container_config})
    env.run = local
Пример #6
0
    def build(self, client=None, **kwargs):
        """Build the docker images

        Parameters
        ----------
        client : dockermap.api.DockerClientWrapper, default None
            Docker client to build the images with. For example it can be
            used to build images on another host.
        """
        if client is None:
            client = DockerClientWrapper()

        # wrap it in a try catch and serialize the failing dockerfile
        # also consider to use add an `org` argument to directly tag the image
        # TODO(kszucs): pass platform argument
        logger.info(f'Start building {self.fqn}')
        client.build_from_file(self.dockerfile, self.fqn, **kwargs)
        logger.info(f'Image has been built successfully: {self.fqn}')

        return self
Пример #7
0
    def push(self, client=None, **kwargs):
        if client is None:
            client = DockerClientWrapper()

        client.push(self.fqn, **kwargs)
        return self
Пример #8
0
 def _client(self, client=None):
     if client is None:
         with DockerClientWrapper() as client:
             yield client
     else:
         yield client
Пример #9
0
def test_docker_image_build(image):
    with DockerClientWrapper() as client:
        image.build(client=client)
        assert len(client.images(image.fqn))
Пример #10
0
def startContainer():
         client = DockerClientWrapper('unix://var/run/docker.sock')
         client.start('aadebuger/lightingthrift', expose={9092: 9090})
Пример #11
0
def startContainer():
    client = DockerClientWrapper('unix://var/run/docker.sock')
    client.start('aadebuger/lightingthrift', expose={9092: 9090})