Skip to content

Commit

Permalink
Merge pull request #7 from bloyl/viz
Browse files Browse the repository at this point in the history
add 2d/3d plotting support to base Dockerfile
  • Loading branch information
rob-luke authored Jul 11, 2021
2 parents 3936ec1 + 958fc3d commit 85953bf
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 14 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

# Controls when the action will run.
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
Expand All @@ -10,12 +10,12 @@ on:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2
with:
fetch-depth: 0
Expand All @@ -28,5 +28,8 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build docker image
- name: Build docker images
run: docker-compose build

- name: System info
run: docker run mnetools/mne-python python -c "import mne; mne.sys_info()"
43 changes: 37 additions & 6 deletions base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
FROM continuumio/miniconda3:4.8.2
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

ARG MNE_USER="mne_user"
ARG HOME_DIR="/home/${MNE_USER}"
ENV MNE_USER=${MNE_USER}
ENV HOME_DIR=${HOME_DIR}

ARG CONDA_DIR="/opt/conda/"

# install xvfb
RUN apt-get update && \
apt-get install -y wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# setup entry point
COPY prepare.sh /usr/bin/prepare.sh
RUN chmod a+x /usr/bin/prepare.sh

RUN chmod 777 /opt

# setup mne user
RUN useradd -ms /bin/bash -d ${HOME_DIR} ${MNE_USER}
USER $MNE_USER
WORKDIR $HOME_DIR

# setup conda
ENV PATH="${CONDA_DIR}/bin:${PATH}"
ARG PATH="${CONDA_DIR}/bin:${PATH}"
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
sh ./Miniconda3-latest-Linux-x86_64.sh -b -p ${CONDA_DIR} && \
rm -f ./Miniconda3-latest-Linux-x86_64.sh && \
conda init
SHELL ["/bin/bash", "--login", "-c"]

RUN conda install --yes \
-c conda-forge \
Expand All @@ -19,11 +54,7 @@ RUN conda install --yes \
&& rm -rf /opt/conda/pkgs

RUN pip install s3fs
RUN pip install mne
RUN pip install bokeh

COPY prepare.sh /usr/bin/prepare.sh

RUN mkdir /opt/app
RUN pip install nibabel joblib h5py mne

ENTRYPOINT ["tini", "-g", "--", "/usr/bin/prepare.sh"]
25 changes: 25 additions & 0 deletions base/Dockerfile.plot
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM mnetools/mne-python

ENV DEBIAN_FRONTEND=noninteractive

# install xvfb
USER root
RUN apt-get update && \
apt-get install -y xvfb qt5-default && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

USER $MNE_USER
WORKDIR $HOME_DIR

RUN pip install vtk pyvista pyvistaqt PyQt5 matplotlib nibabel joblib h5py mne

# setup environment for mne
# MNE_3D_OPTION_ANTIALIAS is needed to avoid blank screenshots.
# PYVISTA_OFF_SCREEN=true is *NOT* needed
ENV \
MNE_3D_BACKEND=pyvista \
MNE_3D_OPTION_ANTIALIAS=false\
START_XVFB=true

ENTRYPOINT ["tini", "-g", "--", "/usr/bin/prepare.sh"]
8 changes: 8 additions & 0 deletions base/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,13 @@ if [ "$EXTRA_PIP_PACKAGES" ]; then
/opt/conda/bin/pip install $EXTRA_PIP_PACKAGES
fi

if [ "$START_XVFB" ]; then
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid \
--make-pidfile --background --exec /usr/bin/Xvfb -- :99 \
-screen 0 1400x900x24 -ac +extension GLX +render -noreset
sleep 3
export DISPLAY=:99
fi

# Run extra commands
exec "$@"
22 changes: 18 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
version: "3.1"

services:
scheduler:
base:
build:
context: ./base
dockerfile: Dockerfile
image: mnetools/mne-python

scheduler:
depends_on:
- base
image: mnetools/mne-python
hostname: mne-dask-scheduler
ports:
- "8786:8786"
- "8787:8787"
command: ["dask-scheduler"]

worker:
build:
context: ./base
dockerfile: Dockerfile
depends_on:
- base
image: mnetools/mne-python
hostname: mne-dask-worker
command: ["dask-worker", "tcp://scheduler:8786"]

worker_viz:
depends_on:
- base
build:
context: ./base
dockerfile: Dockerfile.plot
image: mnetools/mne-python-plot
hostname: mne-dask-worker-plot
command: ["dask-worker", "tcp://scheduler:8786"]

0 comments on commit 85953bf

Please sign in to comment.