Exemple #1
0
    ],
                     stderr=subprocess.DEVNULL,
                     stdout=subprocess.DEVNULL).wait()


if __name__ == '__main__':
    """
    Run avatao solvable and controller docker images. Simply add the challenge repository path as the first
    argument and the script does the rest.

    Python dependencies:
        - PyYAML (http://pyyaml.org/) or simply `pip3 install PyYAML`
          (on Ubuntu you additionally need `apt-get install python3-yaml`)
    """
    init_logger()
    repo_path, repo_name = get_sys_args()

    os.chdir(repo_path)
    atexit.register(remove_containers)

    proc_list = []
    first = None

    if 'crp_config' not in read_config(repo_path):
        logging.warning('There is no crp_config in the config.yml, if this is '
                        'a static challenge you don\'t need to run it.')
        sys.exit(0)

    for short_name, crp_config_item in get_crp_config(repo_path,
                                                      repo_name).items():
        proc, container = run_container(short_name,
Exemple #2
0

def build_image(repo_path, repo_name):
    for dockerfile, image in yield_dockerfiles(repo_path, repo_name):
        try:
            build_cmd = [
                'docker', 'build', '-t', image, '-f', dockerfile, repo_path
            ]
            if os.environ.get('PULL_BASEIMAGES', '0') == '1':
                build_cmd.append('--pull')
            run_cmd(build_cmd)
        except subprocess.CalledProcessError:
            logging.error('Failed to build %s!' % dockerfile)
            sys.exit(1)

        time.sleep(1)


if __name__ == '__main__':
    """
    Build solvable and controller docker images from an avatao challenge repository.

    Simply add the challenge repository path as the first argument and the script does the rest.
    If a controller or solvable is missing, we skip it.

    After a successful build you can use the start.py to run your containers.
    """
    init_logger()
    build_image(*get_sys_args())
    logging.info('Finished. Everything is built.')