Skip to content

Commit

Permalink
WIP: Fix dockerfile (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored Aug 27, 2024
1 parent a87949f commit 7e73399
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 206 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
actions:
patterns:
- "*"
53 changes: 0 additions & 53 deletions .github/workflows/ReleaseLatest.yml

This file was deleted.

70 changes: 0 additions & 70 deletions .github/workflows/ReleaseTags.yml

This file was deleted.

84 changes: 43 additions & 41 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,63 @@
name: Tests

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
cancel-in-progress: true
on: # yamllint disable-line rule:truthy
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
tags:
description: 'MNE-Python version (e.g. v0.23.0 or main)'
required: false
default: 'main'

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

- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Base

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

- name: Set env vars
run: |
set -eo pipefail
if [[ "${{ github.event.inputs.tags }}" != "" ]]; then
echo "MNE_VERSION=${{ github.event.inputs.tags }}" >> $GITHUB_ENV
echo "DOCKER_TAG=${{ github.event.inputs.tags }}" >> $GITHUB_ENV
else
echo "MNE_VERSION=main" >> $GITHUB_ENV
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
fi
echo "Got MNE_VERSION=${MNE_VERSION}"
echo "Got DOCKER_TAG=${DOCKER_TAG}"
- run: docker compose build base --build-arg mne_v="$MNE_VERSION"
- run: docker tag mnetools/mne-python ghcr.io/mne-tools/mne-python:${DOCKER_TAG}
- name: System info - base image
run: docker run mnetools/mne-python python -c "import mne; mne.sys_info()"

run: docker run mnetools/mne-python:${DOCKER_TAG} python -c "import mne; mne.sys_info()"
- name: Run base test
run: docker run -v `pwd`:/opt/app/examples mnetools/mne-python python /opt/app/examples/tests/base.py

# Jupyter

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

run: docker run -v `pwd`:/opt/app/examples mnetools/mne-python:${DOCKER_TAG} python /opt/app/examples/tests/base.py
- run: docker compose build jupyter
- run: docker tag mnetools/mne-python-jupyter ghcr.io/mne-tools/mne-python-jupyter:${DOCKER_TAG}
- name: System info - jupyter image
run: docker run mnetools/mne-python-jupyter ipython -c "import mne; mne.sys_info()"

run: docker run mnetools/mne-python-jupyter:${DOCKER_TAG} ipython -c "import mne; mne.sys_info()"
- name: Run jupyter test
run: docker run -v `pwd`:/opt/app/examples mnetools/mne-python-jupyter ipython /opt/app/examples/tests/base.py

# Plot

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

run: docker run -v `pwd`:/opt/app/examples mnetools/mne-python-jupyter:${DOCKER_TAG} ipython /opt/app/examples/tests/base.py
- run: docker compose build plot
- run: docker tag mnetools/mne-python-plot ghcr.io/mne-tools/mne-python-plot:${DOCKER_TAG}
- name: System info - plot image
run: docker run mnetools/mne-python-plot python -c "import mne; mne.sys_info()"

run: docker run mnetools/mne-python-plot:${DOCKER_TAG} python -c "import mne; mne.sys_info()"
- name: Run plotting test
run: docker run -v `pwd`:/opt/app/examples mnetools/mne-python-plot python /opt/app/examples/tests/plot.py
run: docker run -v `pwd`:/opt/app/examples mnetools/mne-python-plot:${DOCKER_TAG} python /opt/app/examples/tests/plot.py
- name: Push images to github
run: |
set -exo pipefail
docker push ghcr.io/mne-tools/mne-python:${DOCKER_TAG}
docker push ghcr.io/mne-tools/mne-python-jupyter:${DOCKER_TAG}
docker push ghcr.io/mne-tools/mne-python-plot:${DOCKER_TAG}
if: github.repository == 'mne-tools/mne-docker' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
39 changes: 26 additions & 13 deletions base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ubuntu:20.04
# TODO: Use micromamba instead of bare image at some point
FROM ubuntu:24.04

ARG mne_v=v0.23.0
ARG mne_v=v1.8.0

ENV DEBIAN_FRONTEND=noninteractive

Expand Down Expand Up @@ -36,29 +37,41 @@ RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh &
rm -f ./Miniconda3-latest-Linux-x86_64.sh && \
conda init
SHELL ["/bin/bash", "--login", "-c"]

RUN conda config --add channels conda-forge && \
conda config --remove channels defaults && \
conda config --set channel_priority strict && \
conda config --get channels
RUN conda install --yes \
-c conda-forge \
python==3.9 \
python==3.12 \
python-blosc \
cytoolz \
dask==2021.4.0 \
dask \
lz4 \
nomkl \
numpy==1.21.0 \
pandas==1.3.0 \
tini==0.18.0 \
numpy \
pandas \
tini \
pooch \
bokeh \
joblib \
nibabel \
h5py \
s3fs \
matplotlib-base \
scikit-learn \
numba \
nilearn \
dipy \
h5io \
mamba \
conda-libmamba-solver \
&& conda clean -tipy \
&& find /opt/conda/ -type f,l -name '*.a' -delete \
&& find /opt/conda/ -type f,l -name '*.pyc' -delete \
&& find /opt/conda/ -type f,l -name '*.js.map' -delete \
&& find /opt/conda/lib/python*/site-packages/bokeh/server/static -type f,l -name '*.js' -not -name '*.min.js' -delete \
&& rm -rf /opt/conda/pkgs

RUN pip install s3fs
RUN pip install bokeh
RUN pip install nibabel joblib h5py
RUN pip install pooch
RUN pip install https://github.com/mne-tools/mne-python/archive/${mne_v}.zip

ENTRYPOINT ["tini", "-g", "--", "/usr/bin/prepare.sh"]
2 changes: 1 addition & 1 deletion base/Dockerfile.jupyter
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM mnetools/mne-python

RUN pip install jupyterlab ipywidgets ipyvtklink
RUN conda install --yes jupyterlab ipywidgets ipympl

EXPOSE 8888

Expand Down
8 changes: 4 additions & 4 deletions base/Dockerfile.plot
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ ENV DEBIAN_FRONTEND=noninteractive
# install xvfb
USER root
RUN apt-get update && \
apt-get install -y xvfb qt5-default && \
apt-get install -y xvfb && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

USER $MNE_USER
WORKDIR $HOME_DIR

RUN pip install vtk pyvista pyvistaqt PyQt5 matplotlib
RUN conda install --yes vtk pyvista pyvistaqt trame PySide6 qtpy mne-qt-browser trame-vtk trame-vuetify

# 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\
MNE_3D_BACKEND=pyvistaqt \
MNE_3D_OPTION_ANTIALIAS=false \
START_XVFB=true

ENTRYPOINT ["tini", "-g", "--", "/usr/bin/prepare.sh"]
2 changes: 1 addition & 1 deletion base/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi

if [ "$EXTRA_CONDA_PACKAGES" ]; then
echo "EXTRA_CONDA_PACKAGES environment variable found. Installing."
/opt/conda/bin/conda install -y $EXTRA_CONDA_PACKAGES
/opt/conda/bin/conda install --yes $EXTRA_CONDA_PACKAGES
fi

if [ "$EXTRA_PIP_PACKAGES" ]; then
Expand Down
Loading

0 comments on commit 7e73399

Please sign in to comment.