예제 #1
0
파일: deploy.py 프로젝트: timfeirg/eru-core
def build_image_v2():
    # form post
    appname = request.form.get('appname', default='')
    version = request.form.get('version', default='')
    base = request.form.get('base', default='')
    if not base:
        abort(400, 'base image must be set')
    _, version = _get_app_and_version(appname, version)

    if ':' not in base:
        base = base + ':latest'

    host = Host.get_random_public_host()
    if not host:
        abort(406, 'no host is available')

    # if no artifacts.zip is set
    # ignore and just do the cloning and building
    file_path = None
    if 'artifacts.zip' in request.files:
        f = request.files['artifacts.zip']
        file_path = os.path.join(tempfile.mkdtemp(), secure_filename(f.filename))
        f.save(file_path)

    task = Task.create(TASK_BUILD, version, host, {'base': base})
    build_docker_image.apply_async(
        args=(task.id, base, file_path),
        task_id='task:%d' % task.id
    )
    return {'task': task.id, 'watch_key': task.result_key}
예제 #2
0
파일: deploy.py 프로젝트: CMGS/eru-core
def build_image(group_name, pod_name, appname):
    data = request.get_json()
    group, pod, _, version = validate_instance(group_name, pod_name, appname, data['version'])

    base = data['base']
    if ':' not in base:
        base = base + ':latest'

    host = Host.get_random_public_host() or pod.get_random_host()
    task = Task.create(consts.TASK_BUILD, version, host, {'base': base})
    build_docker_image.apply_async(
        args=(task.id, base),
        task_id='task:%d' % task.id
    )
    return {'r': 0, 'msg': 'ok', 'task': task.id, 'watch_key': task.result_key}
예제 #3
0
파일: deploy.py 프로젝트: timfeirg/eru-core
def build_image():
    data = request.get_json()
    _, version = _get_app_and_version(**data)

    base = data['base']
    if ':' not in base:
        base = base + ':latest'

    host = Host.get_random_public_host()
    if not host:
        abort(406, 'no host is available')

    task = Task.create(TASK_BUILD, version, host, {'base': base})
    build_docker_image.apply_async(
        args=(task.id, base, None),
        task_id='task:%d' % task.id
    )
    return {'task': task.id, 'watch_key': task.result_key}