def build(target_image):
    build = Build()
    build.playbook_path = basic_playbook_path
    build.base_image = base_image
    build.target_image = target_image
    build.metadata = ImageMetadata()
    build.state = BuildState.NEW
    build.builder_name = "buildah"  # test with all builders
    return build
Beispiel #2
0
    def _build(self):
        metadata = ImageMetadata()
        if self.args.workdir:
            metadata.working_dir = self.args.workdir
        if self.args.labels:
            for label in self.args.labels:
                err_msg = "Label variable {} doesn't seem to be " + \
                          "specified in format 'KEY=VALUE'.".format(label)
                k, v = split_once_or_fail_with(label, "=", err_msg)
                metadata.labels[k] = v
        if self.args.env_vars:
            for e_v in self.args.env_vars:
                err_msg = "Environment variable {} doesn't seem to be " + \
                    "specified in format 'KEY=VALUE'.".format(e_v)
                k, v = split_once_or_fail_with(e_v, "=", err_msg)
                metadata.env_vars[k] = v
        if self.args.cmd:
            metadata.cmd = self.args.cmd
        if self.args.user:
            metadata.user = self.args.user
        if self.args.ports:
            metadata.ports = self.args.ports
        if self.args.runtime_volumes:
            metadata.volumes = self.args.runtime_volumes

        build = Build()  # we should have a helper for this
        build.playbook_path = self.args.playbook_path
        build.build_volumes = self.args.build_volumes
        build.metadata = metadata
        build.state = BuildState.NEW
        build.base_image = self.args.base_image
        build.target_image = self.args.target_image
        build.builder_name = self.args.builder
        build.cache_tasks = not self.args.no_cache

        self.app.build(build)