Skip to content

Commit

Permalink
add nobrainer dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
hvgazula committed Feb 15, 2024
1 parent 2a62bd6 commit 7573741
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 9 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
name: Docker Image CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
name: docker-image
on: workflow_dispatch

jobs:

Expand All @@ -26,7 +21,7 @@ jobs:
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Build the Docker image
run: docker build -t hvgazula/pialnn ./docker
run: docker build -t hvgazula/nobrainer ./nobrainer-docker/cpu.Dockerfile

# Cleanup steps to free up disk space

Expand All @@ -35,4 +30,4 @@ jobs:
# if: github.event.pull_request.merged == true
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push hvgazula/pialnn
docker push hvgazula/nobrainer:cpu
33 changes: 33 additions & 0 deletions nobrainer-docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Nobrainer in a container

The Dockerfiles in this directory can be used to create Docker images to use _Nobrainer_ on CPU or GPU.

## Build images

```bash
cd /code/nobrainer # Top-level nobrainer directory
docker build -t neuronets/nobrainer:master-cpu -f docker/cpu.Dockerfile .
docker build -t neuronets/nobrainer:master-gpu -f docker/gpu.Dockerfile .
```

# Convert Docker images to Singularity containers

Using Singularity version 3.x, Docker images can be converted to Singularity containers using the `singularity` command-line tool.

## Pulling from DockerHub

In most cases (e.g., working on a HPC cluster), the _Nobrainer_ singularity container can be created with:

```bash
singularity pull docker://neuronets/nobrainer:master-gpu
```

## Building from local Docker cache

If you built a _Nobrainer_ Docker images locally and would like to convert it to a Singularity container, you can do so with:

```bash
sudo singularity pull docker-daemon://neuronets/nobrainer:master-gpu
```

Please note the use of `sudo` here. This is necessary for interacting with the Docker daemon.
23 changes: 23 additions & 0 deletions nobrainer-docker/cpu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM tensorflow/tensorflow:2.14.0-jupyter
RUN curl -sSL http://neuro.debian.net/lists/focal.us-nh.full | tee /etc/apt/sources.list.d/neurodebian.sources.list \
&& export GNUPGHOME="$(mktemp -d)" \
&& echo "disable-ipv6" >> ${GNUPGHOME}/dirmngr.conf \
&& (apt-key adv --homedir $GNUPGHOME --recv-keys --keyserver hkp://pgpkeys.eu 0xA5D32F012649A5A9 \
|| { curl -sSL http://neuro.debian.net/_static/neuro.debian.net.asc | apt-key add -; } ) \
&& apt-get update \
&& apt-get install -y git-annex-standalone git \
&& rm -rf /tmp/*
COPY [".", "/opt/nobrainer"]
RUN cd /opt/nobrainer \
&& sed -i 's/tensorflow >=/tensorflow-cpu >=/g' setup.cfg
RUN python3 -m pip install --no-cache-dir /opt/nobrainer datalad datalad-osf
RUN git config --global user.email "neuronets@example.com" \
&& git config --global user.name "Neuronets maintainers"
RUN datalad clone https://github.com/neuronets/trained-models /models \
&& cd /models && git-annex enableremote osf-storage \
&& datalad get -s osf-storage .
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8
WORKDIR "/work"
LABEL maintainer="Satrajit Ghosh <satrajit.ghosh@gmail.com>"
ENTRYPOINT ["nobrainer"]
22 changes: 22 additions & 0 deletions nobrainer-docker/gpu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM tensorflow/tensorflow:2.14.0-gpu-jupyter
RUN curl -sSL http://neuro.debian.net/lists/focal.us-nh.full | tee /etc/apt/sources.list.d/neurodebian.sources.list \
&& export GNUPGHOME="$(mktemp -d)" \
&& echo "disable-ipv6" >> ${GNUPGHOME}/dirmngr.conf \
&& (apt-key adv --homedir $GNUPGHOME --recv-keys --keyserver hkp://pgpkeys.eu 0xA5D32F012649A5A9 \
|| { curl -sSL http://neuro.debian.net/_static/neuro.debian.net.asc | apt-key add -; } ) \
&& apt-get update \
&& apt-get install -y git-annex-standalone git \
&& rm -rf /tmp/*
COPY [".", "/opt/nobrainer"]
RUN cd /opt/nobrainer
RUN python3 -m pip install --no-cache-dir /opt/nobrainer datalad datalad-osf
RUN git config --global user.email "neuronets@example.com" \
&& git config --global user.name "Neuronets maintainers"
RUN datalad clone https://github.com/neuronets/trained-models /models \
&& cd /models && git-annex enableremote osf-storage \
&& datalad get -s osf-storage .
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8
WORKDIR "/work"
LABEL maintainer="Satrajit Ghosh <satrajit.ghosh@gmail.com>"
ENTRYPOINT ["nobrainer"]

0 comments on commit 7573741

Please sign in to comment.