Add a docker-in-docker container that will run the build server.

This commit is contained in:
yackob03 2013-10-24 14:57:05 -04:00
parent 5d5d027cc0
commit 9dc9e0c940
5 changed files with 109 additions and 17 deletions

View file

@ -54,16 +54,6 @@ def prepare_dockerfile(request_file):
return build_dir
MIME_PROCESSORS = {
'application/zip': prepare_zip,
'text/plain': prepare_dockerfile,
}
builds = {}
pool = ThreadPool(1)
def build_image(build_dir, tag_name, num_steps, result_object):
try:
logger.debug('Does this show up?')
@ -106,11 +96,8 @@ def build_image(build_dir, tag_name, num_steps, result_object):
current_image = 0
image_progress = 0
for status in resp:
logger.debug(status)
if u'status' in status:
status_msg = status[u'status']
next_image = r'(Pushing|Image) [a-z0-9]+( already pushed, skipping)?$'
match = re.match(next_image, status_msg)
if match:
@ -141,7 +128,18 @@ def build_image(build_dir, tag_name, num_steps, result_object):
result_object['message'] = e.message
@app.route('/build', methods=['POST'])
MIME_PROCESSORS = {
'application/zip': prepare_zip,
'text/plain': prepare_dockerfile,
'application/octet-stream': prepare_dockerfile,
}
builds = {}
pool = ThreadPool(1)
@app.route('/build/', methods=['POST'])
def start_build():
docker_input = request.files['dockerfile']
c_type = docker_input.content_type
@ -180,7 +178,7 @@ def start_build():
return redirect(url_for('get_status', job_id=job_id))
@app.route('/status/<job_id>')
@app.route('/build/<job_id>')
def get_status(job_id):
if job_id not in builds:
abort(400)
@ -188,6 +186,13 @@ def get_status(job_id):
return jsonify(builds[job_id])
@app.route('/build/', methods=['GET'])
def get_all_status():
return jsonify({
'builds': builds,
})
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
app.run(host='0.0.0.0', port=5002, debug=True)