Skip to content

Commit

Permalink
[FIX] add "USER root" to top of every Dockerfile (#306)
Browse files Browse the repository at this point in the history
* add "USER root" to top of every Dockerfile

* being singularity `%post` with root user

* update cache version

In #306, the circleci tests were failing for minc. This commit is an attempt to fix that, because the problem was not reproducible on jakub's local installation.

* try switching the order instructions are added

* switch back commands

* select working version of miniconda installer

* add missing comma

* change placement of miniconda version to singularity

* change if syntax

Co-authored-by: Jakub Kaczmarzyk <jakubk@mit.edu>
  • Loading branch information
2 people authored and kaczmarj committed Jan 9, 2020
1 parent 11f80f6 commit d890e05
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
18 changes: 8 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
*setup_kwds
- restore_cache:
keys:
- dfs-v0-{{ .Branch }}-{{ .Revision }}
- dfs-v0-{{ .Branch }}
- dfs-v0
- dfs-v1-{{ .Branch }}-{{ .Revision }}
- dfs-v1-{{ .Branch }}
- dfs-v1
- run:
name: Test docker image builds
no_output_timeout: 360m
Expand All @@ -45,8 +45,7 @@ jobs:
pytest --cov -k 'test_docker' neurodocker
codecov
- save_cache:
key: dfs-v0-{{ .Branch }}-{{ .Revision }}
when: always
key: dfs-v1-{{ .Branch }}-{{ .Revision }}
paths:
- /tmp/cache

Expand All @@ -61,9 +60,9 @@ jobs:
*setup_kwds
- restore_cache:
keys:
- srs-v0-{{ .Branch }}-{{ .Revision }}
- srs-v0-{{ .Branch }}
- srs-v0
- srs-v1-{{ .Branch }}-{{ .Revision }}
- srs-v1-{{ .Branch }}
- srs-v1
- run:
name: Install singularity
command: |
Expand All @@ -82,8 +81,7 @@ jobs:
pytest --cov -k 'test_singularity' neurodocker
codecov
- save_cache:
key: srs-v0-{{ .Branch }}-{{ .Revision }}
when: always
key: srs-v1-{{ .Branch }}-{{ .Revision }}
paths:
- ~/tmp/cache

Expand Down
9 changes: 6 additions & 3 deletions neurodocker/generators/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,16 @@ def _add_header(self):
# base, arg noninteractive frontend, ndfreeze, header, entrypoint.
offset = 1 if self._specs['instructions'][1][0] == 'ndfreeze' else 0
self._specs['instructions'].insert(
1, ('arg', {
1, ('user', 'root')
)
self._specs['instructions'].insert(
2, ('arg', {
'DEBIAN_FRONTEND': 'noninteractive'
}))
kwds = {'version': 'generic', 'method': 'custom'}
self._specs['instructions'].insert(2 + offset, ('_header', kwds))
self._specs['instructions'].insert(3 + offset, ('_header', kwds))
self._specs['instructions'].insert(
3 + offset, ('entrypoint', "/neurodocker/startup.sh"))
4 + offset, ('entrypoint', "/neurodocker/startup.sh"))

def _ispecs_to_dockerfile_str(self):
pkg_man = self._specs['pkg_manager']
Expand Down
2 changes: 2 additions & 0 deletions neurodocker/generators/singularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def _add_neurodocker_header(self):
if self._specs['instructions'][1][0] == 'ndfreeze':
offset = 1
self._specs['instructions'].insert(1 + offset, ('_header', kwds))
self._specs['instructions'].insert(1 + offset, ('user', 'root'))


def _fill_parts(self):
pkg_man = self._specs['pkg_manager']
Expand Down
1 change: 1 addition & 0 deletions neurodocker/interfaces/tests/test_miniconda.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def test_singularity(self):
(
'miniconda',
{
'version': '4.6.14',
'create_env': 'default',
'conda_install': ['python=3.6.5', 'traits'],
'pip_install': ['nipype'],
Expand Down
2 changes: 1 addition & 1 deletion neurodocker/templates/miniconda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ generic:
curl {{ miniconda.curl_opts }} -o "$conda_installer" {{ miniconda.binaries_url }}
bash "$conda_installer" -b -p {{ miniconda.install_path }}
rm -f "$conda_installer"
{%- if miniconda.version == "latest" %}
{% if miniconda.version == "latest" -%}
conda update -yq -nbase conda
{% endif -%}
conda config --system --prepend channels conda-forge
Expand Down

0 comments on commit d890e05

Please sign in to comment.