Skip to content

Commit

Permalink
FIX add default header and entrypoint to docker and singularity files
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdoc committed Jun 22, 2024
1 parent e4a3eed commit 6f3eb4b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
10 changes: 10 additions & 0 deletions neurodocker/cli/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 6f3eb4b

Please sign in to comment.