Subdir support
@@ -62,6 +62,16 @@ class Repo2Docker(Application):
"""
)
+ subdir = Unicode(
+ '',
+ config=True,
+ help="""
+ Subdirectory of the git repository to examine.
+
+ Defaults to ''.
+ """
+ )
+
buildpacks = List(
[
LegacyBinderDockerBuildPack,
@@ -345,6 +355,12 @@ class Repo2Docker(Application):
help=self.traits()['appendix'].help,
)
+ argparser.add_argument(
+ '--subdir',
+ type=str,
+ help=self.traits()['subdir'].help,
+ )
+
argparser.add_argument(
'--version',
dest='version',
@@ -482,6 +498,9 @@ class Repo2Docker(Application):
'the container')
sys.exit(1)
+ if args.subdir:
+ self.subdir = args.subdir
+
self.environment = args.environment
def push_image(self):
@@ -644,7 +663,7 @@ class Repo2Docker(Application):
if self.repo_type == 'remote':
self.fetch(self.repo, self.ref, checkout_path)
- os.chdir(checkout_path)
+ os.chdir(os.path.join(checkout_path, self.subdir).rstrip('/'))
for BP in self.buildpacks:
bp = BP()
