-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
84 lines (70 loc) · 2.81 KB
/
Dockerfile
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
# syntax=docker/dockerfile:1
FROM --platform=${TARGETPLATFORM} jupyter/julia-notebook:julia-1.9.2
ARG TARGETPLATFORM
LABEL org.opencontainers.image.title="Algorithms of the Mind"
LABEL org.opencontainers.image.authors="John Muchovej (@jmuchovej), Ilker Yildirim (@iyildirim)"
LABEL org.opencontainers.image.url="https://github.com/cnclgithub/algorithms-of-the-mind/README.md"
LABEL org.opencontainers.image.source="https://github.com/cnclgithub/algorithms-of-the-mind/Dockerfile"
USER root
RUN apt-get update --yes && \
apt-get install --yes --no-install-recommends \
neovim \
tmux \
jq \
&& rm -rf /var/lib/apt/cache/*
RUN groupadd -g ${NB_UID} ${NB_USER} && \
usermod -g ${NB_USER} -aG users ${NB_USER} && \
echo ${NB_USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${NB_USER} && \
chmod 0440 /etc/sudoers.d/${NB_USER}
RUN conda install -n base conda-libmamba-solver && \
conda config --set solver libmamba
ADD --chown=${NB_USER}:${NB_USER} . /algorithms-of-the-mind
WORKDIR /algorithms-of-the-mind
RUN conda env create -f /algorithms-of-the-mind/environment.yml --yes; \
conda env update -n base -f /algorithms-of-the-mind/environment.yml
ADD .devcontainer/root/ /
ENV JUPYTER_DATA_DIR="${CONDA_DIR}/share/jupyter"
ENV CONDA_JL_HOME="${CONDA_DIR}/envs/algorithms-of-the-mind"
ENV EDITOR="neovim"
ENV CONDA_DEFAULT_ENV="algorithms-of-the-mind"
ENV JULIA_PROJECT="/algorithms-of-the-mind"
ENV NOTEBOOK_ARGS="--config /opt/conda/etc/jupyter/config.py"
EXPOSE 2686
RUN julia <<EOF
import Pkg;
Pkg.activate("/algorithms-of-the-mind")
Pkg.instantiate()
EOF
RUN rm -rf ${JUPYTER_DATA_DIR}/kernels/* ; \
pkgs=$(conda list -n algorithms-of-the-mind --json); \
_python="$(echo "${pkgs}" | jq -r '.[] | select(.name == "python")')"; \
pythonV="$(echo "${_python}" | jq -r ".version" | tr -d '[:space:]')"; \
conda run -n algorithms-of-the-mind \
python -m ipykernel install \
--prefix "${CONDA_DIR}" \
--name atom-py \
--display-name "Algorithms of the Mind (Python) ${pythonV}"; \
juliaV="$(julia --version | grep -Eo "([0-9]{1,}\.)+[0-9]{1,}")"; \
julia <<EOF
import IJulia;
IJulia.installkernel(
"Algorithms of the Mind (Julia)";
specname="atom-jl",
env=Dict(
"JULIA_PROJECT" => "${JULIA_PROJECT}",
"CONDA_JL_HOME" => "${CONDA_JL_HOME}",
"JULIA_NUM_THREADS" => "auto",
)
)
EOF
EXPOSE 2686
RUN chown -R ${NB_UID}:${NB_UID} /algorithms-of-the-mind; \
chmod -R 2775 /algorithms-of-the-mind; \
fix-permissions /algorithms-of-the-mind; \
chown -R ${NB_UID}:${NB_UID} ${CONDA_DIR}; \
chmod -R 2775 ${CONDA_DIR}; \
fix-permissions ${CONDA_DIR}; \
chown -R ${NB_UID}:${NB_UID} ${JULIA_PKGDIR}; \
chmod -R 2775 ${JULIA_PKGDIR}; \
fix-permissions ${JULIA_PKGDIR};
USER ${NB_USER}