strawman implementation of launch script
MODIFY
repo2docker/buildpacks/base.py
repo2docker/buildpacks/base.py
@@ -118,6 +118,14 @@ RUN ./{{ s }}
{% endfor %}
{% endif -%}
+# Run launch script
+{% if launch_scripts -%}
+{% for s in launch_scripts -%}
+RUN chmod +x {{ s }}
+ENTRYPOINT ./{{ s }}
+{% endfor %}
+{% endif -%}
+
# Specify the default command to run
CMD ["jupyter", "notebook", "--ip", "0.0.0.0"]
@@ -283,6 +291,21 @@ class BuildPack:
"""
return []
+ def get_launch_scripts(self):
+ """
+ An ordered list of executable scripts to be executated at runtime.
+ These scripts are added as an `ENTRYPOINT` to the container.
+
+ Is run as a non-root user, and must be executable. Used for doing
+ things that are currently not supported by other means and need to be
+ applied at runtime (set environment variables).
+
+ The scripts should be as deterministic as possible - running it twice
+ should not produce different results.!
+
+ """
+ return []
+
def binder_path(self, path):
"""Locate a file"""
if os.path.exists('binder'):
@@ -329,6 +352,7 @@ class BuildPack:
build_script_files=self.get_build_script_files(),
base_packages=sorted(self.get_base_packages()),
post_build_scripts=self.get_post_build_scripts(),
+ launch_scripts=self.get_launch_scripts(),
appendix=self.appendix,
)
@@ -432,3 +456,9 @@ class BaseImage(BuildPack):
if os.path.exists(post_build):
return [post_build]
return []
+
+ def get_launch_scripts(self):
+ launch = self.binder_path('launch')
+ if os.path.exists(launch):
+ return [launch]
+ return []

strawman implementation of launch script