Ejemplo n.º 1
0
def main():

    parser = argparse.ArgumentParser(
        description='Generate documentation for a specific package',
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('documentation-package-dir')
    #parser.add_argument('command', nargs='*', default='')
    parser.add_argument('--nocache',
                        action='store_true',
                        help='Force a rebuild of the image')
    # parser.add_argument('--develop', action='store_true',
    #    help='Build the image locally not using the prebuilt image.')
    parser.add_argument('-v',
                        '--version',
                        action='version',
                        version='%(prog)s ' + get_rocker_version())
    parser.add_argument('--debug-inside', action='store_true')
    # TODO(tfoote) add verbose parser.add_argument('--verbose', action='store_true')

    extension_manager = RockerExtensionManager()
    default_args = {'doc_rocker': True, 'user': True}
    extension_manager.extend_cli_parser(parser, default_args)

    args = parser.parse_args()
    args_dict = vars(args)
    args_dict['documentation-package-dir'] = os.path.abspath(
        args_dict['documentation-package-dir'])

    args_dict['command'] = 'python3 /doc_root/build_docs.py'

    active_extensions = extension_manager.get_active_extensions(args_dict)
    print("Active extensions %s" % [e.get_name() for e in active_extensions])

    dig = DockerImageGenerator(active_extensions, args_dict, 'ubuntu:focal')

    exit_code = dig.build(**vars(args))
    if exit_code != 0:
        print("Build failed exiting")
        return exit_code

    if args.debug_inside:
        args_dict['command'] = 'bash'

    print(args_dict)
    return dig.run(**args_dict)
Ejemplo n.º 2
0
 def test_no_x11_xpdyinfo(self):
     for tag in self.dockerfile_tags:
         dig = DockerImageGenerator([], {}, tag)
         self.assertEqual(dig.build(), 0)
         self.assertNotEqual(dig.run(), 0)
Ejemplo n.º 3
0
 def test_no_nvidia_glmark2(self):
     for tag in self.dockerfile_tags:
         dig = DockerImageGenerator([], {}, tag)
         self.assertEqual(dig.build(), 0)
         self.assertNotEqual(dig.run(), 0)
Ejemplo n.º 4
0
 def test_device(self):
     dig = DockerImageGenerator([], {}, 'ubuntu:bionic')
     self.assertEqual(dig.build(), 0)
     self.assertEqual(dig.run('true', devices=['/dev/random']), 0)
     self.assertEqual(dig.run('true', devices=['/dev/does_not_exist']), 0)
Ejemplo n.º 5
0
 def test_non_interactive(self):
     dig = DockerImageGenerator([], {}, 'ubuntu:bionic')
     self.assertEqual(dig.build(), 0)
     self.assertEqual(dig.run('true', mode='non-interactive'), 0)
     self.assertEqual(dig.run('false', mode='non-interactive'), 1)
Ejemplo n.º 6
0
 def test_dry_run(self):
     dig = DockerImageGenerator([], {}, 'ubuntu:bionic')
     self.assertEqual(dig.build(), 0)
     self.assertEqual(dig.run('true', mode='dry-run'), 0)
     self.assertEqual(dig.run('false', mode='dry-run'), 0)
Ejemplo n.º 7
0
 def test_noexecute(self):
     dig = DockerImageGenerator([], {}, 'ubuntu:bionic')
     self.assertEqual(dig.build(), 0)
     self.assertEqual(dig.run('true', noexecute=True), 0)
Ejemplo n.º 8
0
 def test_return_code_no_extensions(self):
     dig = DockerImageGenerator([], {}, 'ubuntu:bionic')
     self.assertEqual(dig.build(), 0)
     self.assertEqual(dig.run('true'), 0)
     self.assertEqual(dig.run('false'), 1)
Ejemplo n.º 9
0
 def test_run_before_build(self):
     dig = DockerImageGenerator([], {}, 'ubuntu:bionic')
     self.assertEqual(dig.run('true'), 1)
     self.assertEqual(dig.build(), 0)
     self.assertEqual(dig.run('true'), 0)
Ejemplo n.º 10
0
 def test_network(self):
     dig = DockerImageGenerator([], {}, 'ubuntu:bionic')
     self.assertEqual(dig.build(), 0)
     networks = ['bridge', 'host', 'none']
     for n in networks:
         self.assertEqual(dig.run('true', network=n), 0)
Ejemplo n.º 11
0
def main():

    parser = argparse.ArgumentParser(
        description='A tool for building and testing gh-pages locally',
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('directory')
    #parser.add_argument('command', nargs='*', default='')
    parser.add_argument('--nocache',
                        action='store_true',
                        help='Force a rebuild of the image')
    # TODO(tfoote) add prebuilt images for faster operations
    # parser.add_argument('--develop', action='store_true',
    #    help='Build the image locally not using the prebuilt image.')
    parser.add_argument('--config',
                        type=str,
                        nargs="+",
                        action='append',
                        default=None)
    parser.add_argument('--port', type=int, action='store', default='4000')
    parser.add_argument('--baseurl', type=str, action='store', default=None)
    parser.add_argument('-v',
                        '--version',
                        action='version',
                        version='%(prog)s ' + get_rocker_version())
    parser.add_argument('--build-only', action='store_true')
    parser.add_argument('--debug-inside', action='store_true')
    # TODO(tfoote) add verbose parser.add_argument('--verbose', action='store_true')

    extension_manager = RockerExtensionManager()
    default_args = {'ghpages': True, 'user': True, 'network': 'host'}
    extension_manager.extend_cli_parser(parser, default_args)

    args = parser.parse_args()
    args_dict = vars(args)
    args_dict['directory'] = os.path.abspath(args_dict['directory'])

    if args.build_only and args.baseurl:
        parser.error("build and baseurl options are incompatible")

    if args.build_only:
        args_dict['command'] = 'jekyll build -V --trace'
        del args_dict['network']
    else:
        args_dict['command'] = 'jekyll serve -w'
        if args.baseurl is not None:
            # Don't output to the default location if generating using a modified baseurl
            args_dict[
                'command'] += ' --baseurl=\'{baseurl}\' -d /tmp/aliased_site'.format(
                    **args_dict)

    if args.config:
        config_args = ','.join(args.config[0])
        args_dict['command'] += ' --config={config_args}'.format(**locals())

    active_extensions = extension_manager.get_active_extensions(args_dict)
    print("Active extensions %s" % [e.get_name() for e in active_extensions])

    dig = DockerImageGenerator(active_extensions, args_dict, 'ubuntu:focal')

    exit_code = dig.build(**vars(args))
    if exit_code != 0:
        print("Build failed exiting")
        return exit_code

    if args.debug_inside:
        args_dict['command'] = 'bash'

    return dig.run(**args_dict)