def build_docker_image(task_id, base, file_path): task = Task.get(task_id) if not task: _log.error('Task (id=%s) not found, quit', task_id) return _log.info('Task<id=%s>: Start on host %s', task_id, task.host.ip) notifier = TaskNotifier(task) app = task.app host = task.host version = task.version try: repo, tag = base.split(':', 1) repo = repo if repo.startswith('eru/') else 'eru/' + repo.strip('/') _log.info('Task<id=%s>: Pull base image (base=%s)', task_id, base) notifier.store_and_broadcast(dockerjob.pull_image(host, repo, tag)) _log.info('Task<id=%s>: Build image (base=%s)', task_id, base) notifier.store_and_broadcast(dockerjob.build_image(host, version, base, file_path)) _log.info('Task<id=%s>: Push image (base=%s)', task_id, base) last_line = notifier.store_and_broadcast(dockerjob.push_image(host, version)) dockerjob.remove_image(version, host) except Exception, e: task.finish(consts.TASK_FAILED) task.reason = str(e.message) notifier.pub_fail() _log.error('Task<id=%s>, exception', task_id) _log.exception(e)
def build_docker_image(task_id, base, file_path): task = Task.get(task_id) if not task: _log.error('Task (id=%s) not found, quit', task_id) return _log.info('Task<id=%s>: Start on host %s', task_id, task.host.ip) notifier = TaskNotifier(task) app = task.app host = task.host version = task.version try: repo, tag = base.split(':', 1) repo = repo if repo.startswith('eru/') else 'eru/' + repo.strip('/') _log.info('Task<id=%s>: Pull base image (base=%s)', task_id, base) notifier.store_and_broadcast(dockerjob.pull_image(host, repo, tag)) _log.info('Task<id=%s>: Build image (base=%s)', task_id, base) notifier.store_and_broadcast( dockerjob.build_image(host, version, base, file_path)) _log.info('Task<id=%s>: Push image (base=%s)', task_id, base) last_line = notifier.store_and_broadcast( dockerjob.push_image(host, version)) dockerjob.remove_image(version, host) except Exception, e: task.finish(consts.TASK_FAILED) task.reason = str(e.message) notifier.pub_fail() _log.error('Task<id=%s>, exception', task_id) _log.exception(e)
def build_docker_image(task_id, base): task = Task.get(task_id) if not task: current_flask.logger.error('Task (id=%s) not found, quit', task_id) return current_flask.logger.info('Task<id=%s>: Start on host %s' % (task_id, task.host.ip)) notifier = TaskNotifier(task) try: repo, tag = base.split(':', 1) current_flask.logger.info('Task<id=%s>: Pull base image (base=%s)', task_id, base) notifier.store_and_broadcast(dockerjob.pull_image(task.host, repo, tag)) current_flask.logger.info('Task<id=%s>: Build image (base=%s)', task_id, base) notifier.store_and_broadcast(dockerjob.build_image(task.host, task.version, base)) current_flask.logger.info('Task<id=%s>: Push image (base=%s)', task_id, base) last_line = notifier.store_and_broadcast(dockerjob.push_image(task.host, task.version)) dockerjob.remove_image(task.version, task.host) except Exception, e: task.finish_with_result(consts.TASK_FAILED) notifier.pub_fail() current_flask.logger.error('Task<id=%s>: Exception (e=%s)', task_id, e)
def build_docker_image(task_id, base): task = Task.get(task_id) notifier = TaskNotifier(task) try: repo, tag = base.split(':', 1) notifier.store_and_broadcast(dockerjob.pull_image(task.host, repo, tag)) notifier.store_and_broadcast(dockerjob.build_image(task.host, task.version, base)) notifier.store_and_broadcast(dockerjob.push_image(task.host, task.version)) try: dockerjob.remove_image(task.version, task.host) except: pass except Exception, e: logger.exception(e) task.finish_with_result(code.TASK_FAILED) notifier.pub_fail()