-
Notifications
You must be signed in to change notification settings - Fork 2
Gentoo based Dockerfile (presumably reproducible) to provide bids-app #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yarikoptic
wants to merge
18
commits into
nimh-dsst:main
Choose a base branch
from
yarikoptic:enh-container
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
85b0be6
Prototype of a neurodocker invocation script to produce a container
yarikoptic 0b37ac2
Perspective neurodocker invocation + produced Dockerfile (broken)
yarikoptic 828184e
Fixed up Dockerfile
yarikoptic 73ac16b
Add shebang to src/run.py and make it executable
yarikoptic a4e7112
Announce a string with unescaped backslash to be raw
yarikoptic def7630
One more fix to Dockerfile -- there must be no \ at the end of ARG lines
yarikoptic a072028
Do configured default branch in gentoo so that git has a chance to op…
yarikoptic 8f7ea20
remove trailing \ after popd before many lines of comments
yarikoptic 7b662bd
TEMP(ish): add set -x and GIT_TRACE=1 to see what leads to that RPC c…
yarikoptic 8b72b07
Refactor the entire cloning of gentoo to avoid filter (migth be not s…
yarikoptic 6fc5e2a
[DATALAD RUNCMD] Replace fixed shebangs for python to use /usr/bin/en…
yarikoptic 5503f6b
Remove "module load" invocations from the code
yarikoptic 75fee4c
Add basic checking that external command succeeded
yarikoptic c7ef010
Move gentoo config bootstrapping inside the Dockerfile
yarikoptic a175c5a
Minimize bootstrapped config by removing comments
yarikoptic 076fa2c
Updated hashes to include AFNI nifti-clib fix from upstream
TheChymera 0e696ab
Merge pull request #1 from TheChymera/enh-container
yarikoptic c1f1824
Set AFNI_ATLAS_PATH to point to location of the templates now included
yarikoptic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
# Generated by Neurodocker and Reproenv. | ||
|
||
FROM docker.io/gentoo/portage:20240324 as portage | ||
FROM docker.io/gentoo/stage3:20240318 | ||
|
||
COPY --from=portage /var/db/repos/gentoo /var/db/repos/gentoo | ||
|
||
ARG gentoo_hash=2d25617a1d085316761b06c17a93ec972f172fc6 | ||
ARG science_hash=73916dd3680ffd92e5bd3d32b262e5d78c86a448 | ||
ARG FEATURES="-ipc-sandbox -network-sandbox -pid-sandbox" | ||
|
||
# Instead of | ||
# COPY gentoo-portage/ /etc/portage/ | ||
# produced by https://gist.github.com/yarikoptic/5da985d200fa1a2185a702ce9913d4d4 | ||
# with further HEAVY tune up to make it work | ||
# Lessons: | ||
# - needed to use echo -n so we could have new lines | ||
# - \n at the beginning since otherwise # lines are ignored as comments | ||
# NOTES/QUESTIONS: | ||
# - hardcoded --jobs and --load-average -- I wonder if some generic way | ||
RUN \ | ||
mkdir -p /etc/portage/; \ | ||
echo -e "\ | ||
\nCOMMON_FLAGS=\"-O2 -pipe -march=native\" \ | ||
\nMAKEOPTS=\"--jobs 8 --load-average 9\" \ | ||
\nCFLAGS=\"\${COMMON_FLAGS}\" \ | ||
\nCXXFLAGS=\"\${COMMON_FLAGS}\" \ | ||
\nFCFLAGS=\"\${COMMON_FLAGS}\" \ | ||
\nFFLAGS=\"\${COMMON_FLAGS}\" \ | ||
\nLC_MESSAGES=C \ | ||
\nUSE=\"\${USE} science\" \ | ||
\nACCEPT_LICENSE=\"*\" \ | ||
" > "/etc/portage/make.conf"; \ | ||
mkdir -p "/etc/portage/package.accept_keywords"; \ | ||
echo -e "*/* ~amd64" > "/etc/portage/package.accept_keywords/gen" ; \ | ||
mkdir -p "/etc/portage/package.mask"; \ | ||
touch "/etc/portage/package.mask/bugs"; \ | ||
mkdir -p "/etc/portage/repos.conf" ; \ | ||
echo -e "[gentoo] \ | ||
\nlocation = /var/db/repos/gentoo \ | ||
\nsync-type = git \ | ||
\nsync-uri = https://anongit.gentoo.org/git/repo/gentoo.git \ | ||
\nsync-git-verify-commit-signature = yes" > "/etc/portage/repos.conf/gentoo"; \ | ||
echo -e "[science] \ | ||
\nlocation = /var/db/repos/science \ | ||
\nsync-type = git \ | ||
\nsync-uri = https://anongit.gentoo.org/git/proj/sci.git \ | ||
\npriority = 7777" > "/etc/portage/repos.conf/science" | ||
|
||
RUN emerge -v --noreplace dev-vcs/git \ | ||
&& emerge -v1u portage \ | ||
&& mkdir /outputs \ | ||
&& rm /var/db/repos/gentoo -rf \ | ||
&& git config --global init.defaultBranch master \ | ||
&& \ | ||
set -x && export GIT_TRACE=1 && \ | ||
REPO_URL=$(grep "^sync-uri" /etc/portage/repos.conf/gentoo | sed -e "s/sync-uri *= *//g") && \ | ||
git clone --depth 1 ${REPO_URL} /var/db/repos/gentoo && \ | ||
cd /var/db/repos/gentoo && \ | ||
git fetch --depth 1 origin $gentoo_hash && \ | ||
git reset --hard $gentoo_hash && \ | ||
rm .git -rf && \ | ||
REPO_URL=$(grep "^sync-uri" /etc/portage/repos.conf/science | sed -e "s/sync-uri *= *//g") && \ | ||
git clone --depth 1 ${REPO_URL} /var/db/repos/science && \ | ||
cd /var/db/repos/science && \ | ||
git fetch --depth 1 origin $science_hash && \ | ||
git reset --hard $science_hash && \ | ||
rm .git -rf | ||
# Old Christian: Remove sync-uri to not accidentally re-sync if we work with the package management interactively | ||
# Christian from the future: Maybe we want the option to re-sync if we're debugging it interactively... | ||
#RUN sed -i /etc/portage/repos.conf/{gentoo,science} -e "s/sync-type *= *git/sync-type =/g" | ||
#RUN sed -i /etc/portage/repos.conf/{gentoo,science} -e "/sync-uri/d" | ||
#RUN sed -i /etc/portage/repos.conf/{gentoo,science} -e "/sync-git-verify-commit-signature/d" | ||
# Make sure all CPU flags supported by the hardware are whitelisted | ||
# This only affects packages with handwritten assembly language optimizations, e.g. ffmpeg. | ||
# Removing it is safe, software will just not take full advantage of processor capabilities. | ||
#RUN emerge cpuid2cpuflags | ||
#RUN echo "*/* $(cpuid2cpuflags)" > /etc/portage/package.use/00cpu-flags | ||
### Emerge cool stuff here | ||
### Autounmask-continue enables all features on dependencies which the top level packages require | ||
### By default this needs user confirmation which would interrupt the build. | ||
RUN emerge --autounmask-continue \ | ||
afni \ | ||
fsl \ | ||
&& rm -rf /var/tmp/portage/* | ||
COPY ["environment.yml", \ | ||
"/opt/environment.yml"] | ||
COPY ["src", \ | ||
"/opt/dsst-defacing-pipeline"] | ||
ENV CONDA_DIR="/opt/miniconda-latest" \ | ||
PATH="/opt/miniconda-latest/bin:$PATH" | ||
RUN \ | ||
# Install dependencies. | ||
export PATH="/opt/miniconda-latest/bin:$PATH" \ | ||
&& echo "Downloading Miniconda installer ..." \ | ||
&& conda_installer="/tmp/miniconda.sh" \ | ||
&& curl -fsSL -o "$conda_installer" https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \ | ||
&& bash "$conda_installer" -b -p /opt/miniconda-latest \ | ||
&& rm -f "$conda_installer" \ | ||
&& conda update -yq -nbase conda \ | ||
# Prefer packages in conda-forge | ||
&& conda config --system --prepend channels conda-forge \ | ||
# Packages in lower-priority channels not considered if a package with the same | ||
# name exists in a higher priority channel. Can dramatically speed up installations. | ||
# Conda recommends this as a default | ||
# https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html | ||
&& conda config --set channel_priority strict \ | ||
&& conda config --system --set auto_update_conda false \ | ||
&& conda config --system --set show_channel_urls true \ | ||
# Enable `conda activate` | ||
&& conda init bash \ | ||
&& conda env create --name dsstdeface --file /opt/environment.yml \ | ||
# Clean up | ||
&& sync && conda clean --all --yes && sync \ | ||
&& rm -rf ~/.cache/pip/* | ||
RUN test "$(getent passwd dsst)" \ | ||
|| useradd --no-user-group --create-home --shell /bin/bash dsst | ||
USER dsst | ||
ENTRYPOINT ["/opt/dsst-defacing-pipeline/run.py"] | ||
|
||
# Save specification to JSON. | ||
USER root | ||
RUN printf '{ \ | ||
"pkg_manager": "portage", \ | ||
"existing_users": [ \ | ||
"root" \ | ||
], \ | ||
"instructions": [ \ | ||
{ \ | ||
"name": "from_", \ | ||
"kwds": { \ | ||
"base_image": "docker.io/gentoo/portage:20240324 as portage" \ | ||
} \ | ||
}, \ | ||
{ \ | ||
"name": "from_", \ | ||
"kwds": { \ | ||
"base_image": "docker.io/gentoo/stage3:20240318" \ | ||
} \ | ||
}, \ | ||
{ \ | ||
"name": "run", \ | ||
"kwds": { \ | ||
"command": "COPY --from=portage /var/db/repos/gentoo /var/db/repos/gentoo\\nRUN emerge -v --noreplace dev-vcs/git\\nRUN emerge -v1u portage\\n# Pinned commits for the dependency tree state\\nARG gentoo_hash=2d25617a1d085316761b06c17a93ec972f172fc6\\nARG science_hash=73916dd3680ffd92e5bd3d32b262e5d78c86a448\\nARG FEATURES=\\"-ipc-sandbox -network-sandbox -pid-sandbox\\"\\n# This will be bound, and contents available outside of container\\nRUN mkdir /outputs\\nCOPY gentoo-portage/ /etc/portage/\\n# Moving gentoo repo from default rsync to git\\nRUN rm /var/db/repos/gentoo -rf\\n# Cloning manually to prevent vdb update, pinning state via git\\n# Allegedly it'"'"'s better to chain everything in one command, something with container layers \\ud83e\\udd14\\nRUN \\\\\\n REPO_URL=$\(grep \\"^sync-uri\\" /etc/portage/repos.conf/gentoo | sed -e \\"s/sync-uri *= *//g\\"\) && \\\\\\n mkdir -p /var/db/repos/gentoo && pushd /var/db/repos/gentoo && git init . && \\\\\\n git remote add origin ${REPO_URL} && \\\\\\n git fetch --filter=\\"blob:none\\" origin $gentoo_hash && \\\\\\n git reset --hard $gentoo_hash && rm .git -rf && popd && \\\\\\n REPO_URL=$\(grep \\"^sync-uri\\" /etc/portage/repos.conf/science | sed -e \\"s/sync-uri *= *//g\\"\) && \\\\\\n mkdir -p /var/db/repos/science && pushd /var/db/repos/science && git init . && \\\\\\n git remote add origin ${REPO_URL} && \\\\\\n git fetch --filter=\\"blob:none\\" origin $science_hash && \\\\\\n git reset --hard $science_hash && rm .git -rf && popd\\n# Old Christian: Remove sync-uri to not accidentally re-sync if we work with the package management interactively\\n# Christian from the future: Maybe we want the option to re-sync if we'"'"'re debugging it interactively...\\n#RUN sed -i /etc/portage/repos.conf/{gentoo,science} -e \\"s/sync-type *= *git/sync-type =/g\\"\\n#RUN sed -i /etc/portage/repos.conf/{gentoo,science} -e \\"/sync-uri/d\\"\\n#RUN sed -i /etc/portage/repos.conf/{gentoo,science} -e \\"/sync-git-verify-commit-signature/d\\"\\n# Make sure all CPU flags supported by the hardware are whitelisted\\n# This only affects packages with handwritten assembly language optimizations, e.g. ffmpeg.\\n# Removing it is safe, software will just not take full advantage of processor capabilities.\\n#RUN emerge cpuid2cpuflags\\n#RUN echo \\"*/* $\(cpuid2cpuflags\)\\" > /etc/portage/package.use/00cpu-flags\\n### Emerge cool stuff here\\n### Autounmask-continue enables all features on dependencies which the top level packages require\\n### By default this needs user confirmation which would interrupt the build." \ | ||
} \ | ||
}, \ | ||
{ \ | ||
"name": "install", \ | ||
"kwds": { \ | ||
"pkgs": [ \ | ||
"afni", \ | ||
"fsl" \ | ||
], \ | ||
"opts": null \ | ||
} \ | ||
}, \ | ||
{ \ | ||
"name": "run", \ | ||
"kwds": { \ | ||
"command": "emerge --autounmask-continue \\\\\\n afni \\\\\\n fsl \\\\\\n && rm -rf /var/tmp/portage/*" \ | ||
} \ | ||
}, \ | ||
{ \ | ||
"name": "copy", \ | ||
"kwds": { \ | ||
"source": [ \ | ||
"environment.yml", \ | ||
"/opt/environment.yml" \ | ||
], \ | ||
"destination": "/opt/environment.yml" \ | ||
} \ | ||
}, \ | ||
{ \ | ||
"name": "copy", \ | ||
"kwds": { \ | ||
"source": [ \ | ||
"src", \ | ||
"/opt/dsst-defacing-pipeline" \ | ||
], \ | ||
"destination": "/opt/dsst-defacing-pipeline" \ | ||
} \ | ||
}, \ | ||
{ \ | ||
"name": "env", \ | ||
"kwds": { \ | ||
"CONDA_DIR": "/opt/miniconda-latest", \ | ||
"PATH": "/opt/miniconda-latest/bin:$PATH" \ | ||
} \ | ||
}, \ | ||
{ \ | ||
"name": "run", \ | ||
"kwds": { \ | ||
"command": "\\n# Install dependencies.\\nexport PATH=\\"/opt/miniconda-latest/bin:$PATH\\"\\necho \\"Downloading Miniconda installer ...\\"\\nconda_installer=\\"/tmp/miniconda.sh\\"\\ncurl -fsSL -o \\"$conda_installer\\" https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh\\nbash \\"$conda_installer\\" -b -p /opt/miniconda-latest\\nrm -f \\"$conda_installer\\"\\nconda update -yq -nbase conda\\n# Prefer packages in conda-forge\\nconda config --system --prepend channels conda-forge\\n# Packages in lower-priority channels not considered if a package with the same\\n# name exists in a higher priority channel. Can dramatically speed up installations.\\n# Conda recommends this as a default\\n# https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html\\nconda config --set channel_priority strict\\nconda config --system --set auto_update_conda false\\nconda config --system --set show_channel_urls true\\n# Enable `conda activate`\\nconda init bash\\nconda env create --name dsstdeface --file /opt/environment.yml\\n# Clean up\\nsync && conda clean --all --yes && sync\\nrm -rf ~/.cache/pip/*" \ | ||
} \ | ||
}, \ | ||
{ \ | ||
"name": "user", \ | ||
"kwds": { \ | ||
"user": "dsst" \ | ||
} \ | ||
}, \ | ||
{ \ | ||
"name": "entrypoint", \ | ||
"kwds": { \ | ||
"args": [ \ | ||
"/opt/dsst-defacing-pipeline/run.py" \ | ||
] \ | ||
} \ | ||
} \ | ||
] \ | ||
}' > /.reproenv.json | ||
USER dsst | ||
# End saving to specification to JSON. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
generate() { | ||
# more details might come on https://github.com/ReproNim/neurodocker/issues/330 | ||
[ "$1" == singularity ] && add_entry=' "$@"' || add_entry='' | ||
#neurodocker generate "$1" \ | ||
#ndversion=0.9.5 | ||
#ndversion=master | ||
#docker run --rm repronim/neurodocker:$ndversion \ | ||
# ATM needs devel version of neurodocker for a fix to AFNI recipe | ||
#--base-image neurodebian:bookworm \ | ||
#--ndfreeze date=20240320 \ | ||
dest=/opt/dsst-defacing-pipeline | ||
neurodocker \ | ||
generate "$1" \ | ||
--pkg-manager portage \ | ||
--base-image "docker.io/gentoo/portage:20240324 as portage" \ | ||
--base-image "docker.io/gentoo/stage3:20240318" \ | ||
--gentoo gentoo_hash=2d25617a1d085316761b06c17a93ec972f172fc6 \ | ||
--install afni fsl \ | ||
--copy environment.yml /opt/environment.yml \ | ||
--copy src "$dest" \ | ||
--miniconda \ | ||
version=latest \ | ||
env_name=dsstdeface \ | ||
env_exists=false \ | ||
yaml_file=/opt/environment.yml \ | ||
--user=dsst \ | ||
--entrypoint "$dest/run.py" | ||
#--run "curl -sL https://deb.nodesource.com/setup_16.x | bash - " \ | ||
#--install nodejs npm \ | ||
#--run "npm install -g [email protected]" \ | ||
#--fsl version=6.0.7.1 \ | ||
} | ||
|
||
generate docker > Dockerfile | ||
# generate singularity > Singularity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/local/bin/python3 | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import subprocess | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/local/bin/python3 | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import subprocess | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
import json | ||
import re | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheChymera could you please provide new hashes needed here for the new/fixed up build and also add a patch for AFNI to reflect change like https://github.com/afni/afni/pull/650/files ? or could you just incorporate it to AFNI package so we could build/test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to, but after testing the fix doesn't seem to work. collecting more logs so I can report in the upstream issue exactly what's going on how it was built etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Report here → afni/afni#639 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR here (tested with this repo, for some reason the image takes a long time to build compared to the neurodocker test) → yarikoptic#1
Commot on the gentoo+neurodocker PR: ReproNim/neurodocker@758951b