-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile-analyses
More file actions
97 lines (87 loc) · 3.92 KB
/
Copy pathDockerfile-analyses
File metadata and controls
97 lines (87 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# builds an image for running the notebooks to reproduce analyses and figures
# TODO: might need to do some sort of check to make sure submodules are initialized
FROM debian:bookworm-slim
LABEL maintainer="Paxton Fitzpatrick <Paxton.C.Fitzpatrick.GR@Dartmouth.edu>"
ARG DEBIAN_FRONTEND=noninteractive \
notebook_ip=0.0.0.0 \
notebook_port=8888 \
notebook_dir="/mnt/code/notebooks" \
develop=0
ENV LANG="C.UTF-8" \
LC_ALL="C.UTF-8" \
CONDA_PREFIX="/opt/conda" \
MAMBA_NO_BANNER=1 \
PIP_ROOT_USER_ACTION=ignore \
NOTEBOOK_IP="$notebook_ip" \
NOTEBOOK_PORT="$notebook_port" \
NOTEBOOK_DIR="$notebook_dir"
ENV MAMBA_ROOT_PREFIX="$CONDA_PREFIX" \
PATH="${CONDA_PREFIX}/bin:${PATH}"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN --mount=type=bind,source=.,target=/mnt,rw \
sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc && \
# install basic system packages
apt-get update --fix-missing && \
apt-get install -y --no-install-recommends eatmydata && \
eatmydata apt-get install -y --no-install-recommends \
bzip2 \
ca-certificates \
curl \
git \
rsync \
vim-tiny \
# packages required to build brainiak from source
# (no pre-built dists available on conda-forge/PyPI for aarch64)
build-essential \
libgomp1 \
libmpich-dev \
mpich && \
# symlink "vim.tiny" to just "vim" for simplicity
ln -s /usr/bin/vim.tiny /usr/bin/vim && \
# install conda & mamba (faster C++ reimplementation) via miniforge
curl --progress-bar \
-L "https://github.com/conda-forge/miniforge/releases/download/25.3.1-0/Miniforge3-25.3.1-0-Linux-$(uname -m).sh" \
-o "$HOME/miniforge.sh" && \
/bin/bash "$HOME/miniforge.sh" -bp $CONDA_PREFIX && \
# configure conda for long-term stability/reproducibility
conda config --set auto_update_conda false && \
conda config --set notify_outdated_conda false && \
conda config --set channel_priority strict && \
# reconstruct analysis environment from conda-lock file (multi-platform)
mamba install -yn base -f /mnt/docker/conda-lock.yml && \
# install & enable GUI menu for configuring Jupyter notebook extensions
jupyter contrib nbextension install --sys-prefix --overwrite && \
jupyter nbclassic-extension install --sys-prefix --py jupyter_nbextensions_configurator --overwrite && \
jupyter nbclassic-extension enable --sys-prefix --py jupyter_nbextensions_configurator && \
jupyter nbclassic-serverextension enable --sys-prefix --py jupyter_nbextensions_configurator && \
# copy in Jupyter server & extensions config files from build context
mkdir -p "$HOME/.jupyter/serverconfig" && \
cp /mnt/docker/jupyter_notebook_config.py "$HOME/.jupyter/jupyter_notebook_config.py" && \
cp /mnt/docker/notebook.json "$HOME/.jupyter/serverconfig/notebook.json" && \
echo -e '{\n "nbext_hide_incompat": false\n}' > "$HOME/.jupyter/serverconfig/common.json" && \
# install helpers package for analyses
if [[ $develop -eq 1 ]]; then editable_flag="-e"; else editable_flag=""; fi && \
pip install --disable-pip-version-check --no-cache-dir $editable_flag /mnt/code/analysis-helpers && \
# cleanup to reduce image size
apt-get clean && \
apt-get purge -y --auto-remove \
eatmydata \
bzip2 \
ca-certificates \
curl \
git \
build-essential \
libgomp1 \
libmpich-dev \
mpich && \
rm -rf /var/lib/apt/lists/* && \
rm "$HOME/miniforge.sh" && \
mamba clean -afy && \
find ${CONDA_PREFIX} -follow -type f -name '*.a' -delete && \
find ${CONDA_PREFIX} -follow -type f -name '*.pyc' -delete && \
find ${CONDA_PREFIX}/ -follow -type f -name '*.js.map' -delete && \
rm -rf "$HOME/.cache/pip" && \
rm -f $HOME/nltk_data/*/*.zip
WORKDIR "/mnt"
ENTRYPOINT ["tini", "-g", "--"]
CMD ["jupyter", "nbclassic"]