forked from brainlife/ezbids
-
Notifications
You must be signed in to change notification settings - Fork 3
Single docker file + Apptainer Support #60
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bb7048f
single dockerfile behaves
bendhouseart b53b7c0
update readme with instructions
bendhouseart d5f0cc1
Added apptainer CI
bendhouseart fa19f3e
added ci to build and test single image
bendhouseart af661f1
updated actions added cleanup for apptainer
bendhouseart 7fa18b5
nm rm
bendhouseart 441f778
not daemon -d is detach
bendhouseart f55cd85
fix typi
bendhouseart ad0cf5d
apptainer and docker misunderstandings
bendhouseart 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,247 @@ | ||
| # EverythingDockerfile - Multistage build combining all services | ||
| # This combines mongodb, api, handler, ui, and telemetry into a single container | ||
|
|
||
| # Stage 1: MongoDB base | ||
| FROM mongo:4.4.15 AS mongodb-stage | ||
| RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Stage 2: Neuroimaging tools and handler dependencies | ||
| FROM neurodebian:nd20.04-non-free AS neuroimaging-stage | ||
| SHELL ["/bin/bash", "-c"] | ||
| ENV DEBIAN_FRONTEND noninteractive | ||
|
|
||
| RUN apt update && \ | ||
| apt-get update && apt-get upgrade -y | ||
|
|
||
| RUN apt update && apt install -y parallel python3 python3-pip tree curl unzip git jq python libgl-dev python-numpy bc | ||
|
|
||
| RUN pip3 install numpy==1.23.0 nibabel==4.0.0 pandas matplotlib pyyaml==5.4.1 pydicom==2.3.1 natsort pydeface && \ | ||
| pip3 install quickshear mne mne-bids pypet2bids==1.4.1 | ||
|
|
||
| RUN apt-get install -y build-essential pkg-config cmake git pigz rename zstd libopenjp2-7 libgdcm-tools wget libopenblas-dev && \ | ||
| apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y | ||
|
|
||
| RUN touch /.pet2bidsconfig && chown 1001:1001 /.pet2bidsconfig | ||
| RUN echo "DEFAULT_METADATA_JSON=/usr/local/lib/python3.8/dist-packages/pypet2bids/template_json.json" > /.pet2bidsconfig | ||
|
|
||
| RUN mkdir -p /usr/local/fsl && \ | ||
| git clone https://github.com/dlevitas/FSL_binaries /usr/local/fsl && \ | ||
| rm -rf /usr/local/fsl/README.md && \ | ||
| mkdir -p /usr/local/fsl/data/standard && \ | ||
| mv /usr/local/fsl/bin/MNI152_T1_2mm_brain.nii.gz /usr/local/fsl/data/standard | ||
|
|
||
| ENV FSLDIR=/usr/local/fsl | ||
| ENV PATH=$PATH:$FSLDIR/bin | ||
| ENV FSLOUTPUTTYPE=NIFTI_GZ | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install -y ca-certificates curl gnupg \ | ||
| && mkdir -p /etc/apt/keyrings \ | ||
| && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg | ||
|
|
||
| ARG NODE_MAJOR=20 | ||
| RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install nodejs -y | ||
|
|
||
| RUN cd /tmp && curl -fLO https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_lnx.zip \ | ||
| && unzip /tmp/dcm2niix_lnx.zip \ | ||
| && mv dcm2niix /usr/local/bin | ||
|
|
||
| RUN mkdir -p /app | ||
|
|
||
| # Get bids-specification from github | ||
| RUN cd /app && git clone https://github.com/bids-standard/bids-specification && \ | ||
| cd bids-specification && git checkout 3537e9edbc81545614d3ee605c398361099b6977 | ||
|
|
||
| #install ROBEX | ||
| ADD https://www.nitrc.org/frs/download.php/5994/ROBEXv12.linux64.tar.gz//?i_agree=1&download_now=1 / | ||
| RUN tar -xzf /ROBEXv12.linux64.tar.gz | ||
| ENV PATH /ROBEX:$PATH | ||
|
|
||
| ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules | ||
| ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH | ||
|
|
||
| #install bids-validator | ||
| RUN npm install -g [email protected] | ||
| RUN npm install -g [email protected] | ||
| RUN git clone https://github.com/bids-standard/bids-validator | ||
|
|
||
| # Stage 3: Node.js base for API and UI | ||
| FROM node:20 AS nodejs-stage | ||
| RUN npm install -g [email protected] pm2 typescript tsc-watch | ||
|
|
||
| # Stage 4: Telemetry dependencies | ||
| FROM neurodebian:nd20.04-non-free AS telemetry-stage | ||
| SHELL ["/bin/bash", "-c"] | ||
| ENV DEBIAN_FRONTEND noninteractive | ||
|
|
||
| RUN apt update && \ | ||
| apt-get update && apt-get upgrade -y | ||
|
|
||
| RUN apt install -y parallel python3 python3-pip tree curl unzip git jq python libgl-dev python-numpy | ||
| RUN pip3 install --upgrade pip | ||
| RUN pip3 install conversiontelemetry | ||
|
|
||
| # Stage 5: Final combined stage | ||
| FROM neurodebian:nd20.04-non-free AS everything | ||
| SHELL ["/bin/bash", "-c"] | ||
| ENV DEBIAN_FRONTEND noninteractive | ||
|
|
||
| # Install system dependencies | ||
| RUN apt update && \ | ||
| apt-get update && apt-get upgrade -y && \ | ||
| apt install -y parallel python3 python3-pip tree curl unzip git jq python libgl-dev python-numpy bc \ | ||
| build-essential pkg-config cmake git pigz rename zstd libopenjp2-7 libgdcm-tools wget libopenblas-dev \ | ||
| ca-certificates gnupg supervisor && \ | ||
| apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y | ||
|
|
||
| # Install Node.js 20 | ||
| RUN mkdir -p /etc/apt/keyrings \ | ||
| && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg | ||
|
|
||
| ARG NODE_MAJOR=20 | ||
| RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list | ||
|
|
||
| RUN apt-get update && apt-get install nodejs -y | ||
|
|
||
| # Install Python packages | ||
| RUN pip3 install numpy==1.23.0 nibabel==4.0.0 pandas matplotlib pyyaml==5.4.1 pydicom==2.3.1 natsort pydeface && \ | ||
| pip3 install quickshear mne mne-bids pypet2bids==1.4.1 conversiontelemetry | ||
|
|
||
| # Install MongoDB | ||
| RUN wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add - && \ | ||
| echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list && \ | ||
| apt-get update && \ | ||
| apt-get install -y mongodb-org=4.4.15 mongodb-org-server=4.4.15 mongodb-org-shell=4.4.15 mongodb-org-mongos=4.4.15 mongodb-org-tools=4.4.15 | ||
|
|
||
| # Install neuroimaging tools | ||
| RUN touch /.pet2bidsconfig && chown 1001:1001 /.pet2bidsconfig | ||
| RUN echo "DEFAULT_METADATA_JSON=/usr/local/lib/python3.8/dist-packages/pypet2bids/template_json.json" > /.pet2bidsconfig | ||
|
|
||
| RUN mkdir -p /usr/local/fsl && \ | ||
| git clone https://github.com/dlevitas/FSL_binaries /usr/local/fsl && \ | ||
| rm -rf /usr/local/fsl/README.md && \ | ||
| mkdir -p /usr/local/fsl/data/standard && \ | ||
| mv /usr/local/fsl/bin/MNI152_T1_2mm_brain.nii.gz /usr/local/fsl/data/standard | ||
|
|
||
| ENV FSLDIR=/usr/local/fsl | ||
| ENV PATH=$PATH:$FSLDIR/bin | ||
| ENV FSLOUTPUTTYPE=NIFTI_GZ | ||
|
|
||
| # Install dcm2niix | ||
| RUN cd /tmp && curl -fLO https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_lnx.zip \ | ||
| && unzip /tmp/dcm2niix_lnx.zip \ | ||
| && mv dcm2niix /usr/local/bin | ||
|
|
||
| # Install ROBEX | ||
| ADD https://www.nitrc.org/frs/download.php/5994/ROBEXv12.linux64.tar.gz//?i_agree=1&download_now=1 / | ||
| RUN tar -xzf /ROBEXv12.linux64.tar.gz | ||
| ENV PATH /ROBEX:$PATH | ||
|
|
||
| # Install Node.js global packages | ||
| RUN npm install -g [email protected] pm2 typescript tsc-watch [email protected] | ||
|
|
||
| # Get bids-specification from github | ||
| RUN mkdir -p /app && \ | ||
| cd /app && git clone https://github.com/bids-standard/bids-specification && \ | ||
| cd bids-specification && git checkout 3537e9edbc81545614d3ee605c398361099b6977 | ||
|
|
||
| # Clone bids-validator | ||
| RUN git clone https://github.com/bids-standard/bids-validator /app/bids-validator | ||
|
|
||
| # Copy application code | ||
| COPY . /app | ||
|
|
||
| # Generate keys for API | ||
| WORKDIR /app | ||
| RUN ./generate_keys.sh | ||
|
|
||
| # Install API dependencies and build | ||
| WORKDIR /app/api | ||
| RUN cp /app/package.json /app/api/ && npm install && npx tsc | ||
|
|
||
| # Install handler dependencies and build | ||
| WORKDIR /app/handler | ||
| RUN npm install && npx tsc | ||
|
|
||
| # Install UI dependencies | ||
| WORKDIR /app/ui | ||
| RUN npm install | ||
|
|
||
| # Copy UI entrypoint | ||
| COPY ui/entrypoint.sh /entrypoint-ui.sh | ||
| RUN chmod +x /entrypoint-ui.sh | ||
|
|
||
| # Copy telemetry environment | ||
| COPY telemetry/telemetry.env /root/.telemetry.env | ||
|
|
||
| # Create supervisor configuration | ||
| RUN mkdir -p /etc/supervisor/conf.d | ||
| COPY <<EOF /etc/supervisor/conf.d/ezbids.conf | ||
| [supervisord] | ||
| nodaemon=true | ||
| user=root | ||
|
|
||
| [program:mongodb] | ||
| command=mongod --bind_ip_all --port 27017 | ||
| autostart=true | ||
| autorestart=true | ||
| stderr_logfile=/var/log/mongodb.err.log | ||
| stdout_logfile=/var/log/mongodb.out.log | ||
|
|
||
| [program:api] | ||
| command=/app/api/dev.sh | ||
| directory=/app/api | ||
| autostart=true | ||
| autorestart=true | ||
| environment=MONGO_CONNECTION_STRING="mongodb://localhost:27017/ezbids",BRAINLIFE_AUTHENTICATION="false" | ||
| stderr_logfile=/var/log/api.err.log | ||
| stdout_logfile=/var/log/api.out.log | ||
| depends_on=mongodb | ||
|
|
||
| [program:handler] | ||
| command=pm2 start handler.js --attach --watch --ignore-watch "ui **/node_modules **__pycache__**" | ||
| directory=/app/handler | ||
| autostart=true | ||
| autorestart=true | ||
| environment=MONGO_CONNECTION_STRING="mongodb://localhost:27017/ezbids",PRESORT="false" | ||
| stderr_logfile=/var/log/handler.err.log | ||
| stdout_logfile=/var/log/handler.out.log | ||
| depends_on=api | ||
|
|
||
| [program:ui] | ||
| command=/entrypoint-ui.sh | ||
| directory=/app/ui | ||
| autostart=true | ||
| autorestart=true | ||
| environment=VITE_APIHOST="http://localhost:8082",VITE_BRAINLIFE_AUTHENTICATION="false" | ||
| stderr_logfile=/var/log/ui.err.log | ||
| stdout_logfile=/var/log/ui.out.log | ||
| depends_on=api | ||
|
|
||
| [program:telemetry] | ||
| command=start-telemetry | ||
| autostart=false | ||
| autorestart=true | ||
| stderr_logfile=/var/log/telemetry.err.log | ||
| stdout_logfile=/var/log/telemetry.out.log | ||
| depends_on=mongodb | ||
| EOF | ||
|
|
||
| # Create necessary directories | ||
| RUN mkdir -p /data/db /var/log /tmp/ezbids-workdir | ||
|
|
||
| # Expose ports | ||
| EXPOSE 27017 8082 3000 8000 | ||
|
|
||
| # Health check | ||
| HEALTHCHECK --interval=10s --timeout=10s --retries=5 --start-period=30s \ | ||
| CMD curl -f http://localhost:8082/health || exit 1 | ||
|
|
||
| # Start all services with supervisor | ||
| CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/ezbids.conf"] | ||
|
|
||
|
|
||
| # run with docker run -p 27017:27017 -p 8082:8082 -p 3000:3000 -p 8000:8000 -v /tmp/ezbids-workdir:/tmp ezbids-everything |
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
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.
(base) martinnorgaard@pop-os:
/Downloads/ezbids_docker$ docker images/Downloads/ezbids_docker$ apptainer build ezbids-everything.sif ezbids-everythingREPOSITORY TAG IMAGE ID CREATED SIZE
ezbids-everything latest b8241a21e941 2 minutes ago 4.5GB
ezbids_docker-ui latest ac35e4d581c0 6 minutes ago 1.45GB
ezbids_docker-handler latest 005809e9181c 6 minutes ago 3.86GB
ezbids_docker-api latest bd7929c82a34 13 minutes ago 1.79GB
ghcr.io/nipreps/petprep main aad9b02f71e9 4 weeks ago 24.3GB
(base) martinnorgaard@pop-os:
FATAL: Unable to build from ezbids-everything: unable to open file ezbids-everything: open ezbids-everything: no such file or directory
(base) martinnorgaard@pop-os:~/Downloads/ezbids_docker$ apptainer build ezbids-everything.sif docker-daemon://ezbids-everything:latest
INFO: Starting build...
FATAL: While performing build: conveyor failed to get: while converting reference: loading image from docker engine: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
So think we should add the choice of saving the image to a tar, and then build the sif from that. E.g.
docker save ezbids-everything:latest -o ezbids-everything.tar
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.
Does that work? I didn't get a chance to try it today (I'm not at all opposed).