diff --git a/neurodocker/cli/generate.py b/neurodocker/cli/generate.py index 26267923..94271e54 100644 --- a/neurodocker/cli/generate.py +++ b/neurodocker/cli/generate.py @@ -327,6 +327,16 @@ def _params_to_renderer_dict(ctx: click.Context, pkg_manager) -> dict: renderer_dict["instructions"].append(d) if not renderer_dict["instructions"]: ctx.fail("not enough instructions to generate a container specification") + # Add header to the instructions, after the base image. + renderer_dict["instructions"].insert( + 1, {"name": "_default", "kwds": {}} + ) + # Use default entrypoint if user did not specify one. + if "entrypoint" not in [param.name for param, _ in cmd._options]: + renderer_dict["instructions"].append( + {"name": "entrypoint", "kwds": {"args": ["/neurodocker/startup.sh"]}} + ) + return renderer_dict diff --git a/neurodocker/templates/_header.yaml b/neurodocker/templates/_default.yaml similarity index 69% rename from neurodocker/templates/_header.yaml rename to neurodocker/templates/_default.yaml index 6a09a4bb..98a401ff 100644 --- a/neurodocker/templates/_header.yaml +++ b/neurodocker/templates/_default.yaml @@ -4,7 +4,7 @@ # TODO: read this about locales http://jaredmarkell.com/docker-and-locales/ -name: _header +name: _default url: n/a # Not actually source, but we do not want to provide URLs. source: @@ -28,14 +28,14 @@ source: LC_ALL: en_US.UTF-8 ND_ENTRYPOINT: /neurodocker/startup.sh instructions: | - export ND_ENTRYPOINT="{{ _header._env['ND_ENTRYPOINT'] }}" - {{ _header.install_dependencies() }} - {%- if _header.pkg_manager == "apt" %} - sed -i -e 's/# {{ _header._env['LC_ALL'] }} UTF-8/{{ _header._env['LC_ALL'] }} UTF-8/' /etc/locale.gen + export ND_ENTRYPOINT="{{ self.env['ND_ENTRYPOINT'] }}" + {{ self.install_dependencies() }} + {%- if self.pkg_manager == "apt" %} + sed -i -e 's/# {{ self.env['LC_ALL'] }} UTF-8/{{ self.env['LC_ALL'] }} UTF-8/' /etc/locale.gen dpkg-reconfigure --frontend=noninteractive locales - update-locale LANG="{{ _header._env['LANG'] }}" - {%- elif _header.pkg_manager == "yum" %} - localedef -i {{ _header._env['LC_ALL'].split('.')[0] }} -f {{ _header._env['LC_ALL'].split('.')[1] }} {{ _header._env['LC_ALL'] }} + update-locale LANG="{{ self.env['LANG'] }}" + {%- elif self.pkg_manager == "yum" %} + localedef -i {{ self.env['LC_ALL'].split('.')[0] }} -f {{ self.env['LC_ALL'].split('.')[1] }} {{ self.env['LC_ALL'] }} {%- endif %} chmod 777 /opt && chmod a+s /opt mkdir -p /neurodocker