kopia lustrzana https://github.com/jupyterhub/repo2docker
Usability improvements for manual usage
- Name no longer needs to be specified, isn't really used anywhere - Cleans up checkout by defaultpull/6/head
rodzic
b59c8f5886
commit
f571371b37
|
@ -3,11 +3,13 @@ import json
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
import uuid
|
||||||
|
import shutil
|
||||||
from pythonjsonlogger import jsonlogger
|
from pythonjsonlogger import jsonlogger
|
||||||
|
|
||||||
|
|
||||||
from traitlets.config import Application, LoggingConfigurable, Unicode, Dict, List
|
from traitlets.config import Application, LoggingConfigurable
|
||||||
from traitlets import Type
|
from traitlets import Type, Bool, Unicode, Dict, List
|
||||||
import docker
|
import docker
|
||||||
from docker.utils import kwargs_from_env
|
from docker.utils import kwargs_from_env
|
||||||
|
|
||||||
|
@ -23,12 +25,6 @@ class Builder(Application):
|
||||||
config=True
|
config=True
|
||||||
)
|
)
|
||||||
|
|
||||||
build_name = Unicode(
|
|
||||||
None,
|
|
||||||
allow_none=True,
|
|
||||||
config=True
|
|
||||||
)
|
|
||||||
|
|
||||||
source_url = Unicode(
|
source_url = Unicode(
|
||||||
None,
|
None,
|
||||||
allow_none=True,
|
allow_none=True,
|
||||||
|
@ -58,12 +54,22 @@ class Builder(Application):
|
||||||
config=True
|
config=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cleanup_checkout = Bool(
|
||||||
|
True,
|
||||||
|
config=True,
|
||||||
|
help="""
|
||||||
|
Set to True to clean up the checked out directory after building is done.
|
||||||
|
|
||||||
|
Will only clean up after a successful build - failed builds will still leave their
|
||||||
|
checkouts intact.
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
aliases = Dict({
|
aliases = Dict({
|
||||||
'source': 'Builder.source_url',
|
'source': 'Builder.source_url',
|
||||||
'ref': 'Builder.source_ref',
|
'ref': 'Builder.source_ref',
|
||||||
'output': 'Builder.output_image_spec',
|
'output': 'Builder.output_image_spec',
|
||||||
'f': 'Builder.config_file',
|
'f': 'Builder.config_file',
|
||||||
'n': 'Builder.build_name'
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +123,8 @@ class Builder(Application):
|
||||||
# image not found, proceed to build
|
# image not found, proceed to build
|
||||||
pass
|
pass
|
||||||
|
|
||||||
output_path = os.path.join(self.git_workdir, self.build_name)
|
|
||||||
|
output_path = os.path.join(self.git_workdir, str(uuid.uuid4()))
|
||||||
self.fetch(
|
self.fetch(
|
||||||
self.source_url,
|
self.source_url,
|
||||||
self.source_ref,
|
self.source_ref,
|
||||||
|
@ -148,6 +155,8 @@ class Builder(Application):
|
||||||
self.log.info('Pushing image', extra=dict(progress=layers, phase='pushing'))
|
self.log.info('Pushing image', extra=dict(progress=layers, phase='pushing'))
|
||||||
last_emit_time = time.time()
|
last_emit_time = time.time()
|
||||||
|
|
||||||
|
shutil.rmtree(output_path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
f = Builder()
|
f = Builder()
|
||||||
|
|
Ładowanie…
Reference in New Issue