Add a dockerfile based BuildPack
Great escape hatch
MODIFY
builder/app.py
builder/app.py
@@ -9,7 +9,7 @@ import docker
import subprocess
-from .detectors import BuildPack, PythonBuildPack
+from .detectors import BuildPack, PythonBuildPack, DockerBuildPack
class Builder(Application):
config_file = Unicode(
@@ -42,7 +42,7 @@ class Builder(Application):
buildpacks = List(
None,
- [PythonBuildPack],
+ [DockerBuildPack, PythonBuildPack],
config=True
)
@@ -77,6 +77,10 @@ class Builder(Application):
bp = bp_class()
if bp.detect(output_path):
bp.build(output_path, self.output_image_spec)
+ break
+ else:
+ raise Exception("No compatible builders found")
+
client = docker.from_env(version='1.23')
for line in client.images.push(self.output_image_spec, stream=True):

MODIFY
builder/detectors.py
builder/detectors.py
import os
import subprocess
+import docker
+
from traitlets import Unicode, Dict
from traitlets.config import LoggingConfigurable
@@ -20,6 +22,21 @@ class BuildPack(LoggingConfigurable):
+class DockerBuildPack(BuildPack):
+ def detect(self, workdir):
+ return os.path.exists(os.path.join(workdir, 'Dockerfile'))
+
+ def build(self, workdir, output_image_spec):
+ client = docker.APIClient(base_url='unix://var/run/docker.sock', version='auto')
+ for progress in client.build(
+ path=workdir,
+ tag=output_image_spec,
+ decode=True
+ ):
+ # FIXME: Properly stream back useful information only
+ pass
+
+
class PythonBuildPack(BuildPack):
runtime_builder_map = Dict({
'python-2.7': 'jupyterhub/singleuser-builder-venv-2.7:v0.1.4',

Add a dockerfile based BuildPack

Great escape hatch