Skip to content

Commit 56cb1bb

Browse files
authored
Add and fix cluster dev environment (#99)
Add dev env build
1 parent cb24090 commit 56cb1bb

File tree

3 files changed

+150
-13
lines changed

3 files changed

+150
-13
lines changed

.github/dockerfiles/env/Dockerfile

Lines changed: 130 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,141 @@
1-
FROM ubuntu:latest
1+
FROM python:3.9-bullseye as python_builder
22

3-
SHELL ["/bin/bash", "-xec"]
3+
WORKDIR /app
4+
5+
RUN set -ex; \
6+
git clone https://github.com/dirkcgrunwald/jupyter_codeserver_proxy-.git; \
7+
cd jupyter_codeserver_proxy-; \
8+
make build-package
9+
10+
FROM ubuntu:22.04 as conda_builder
11+
12+
RUN set -ex; \
13+
export DEBIAN_FRONTEND=noninteractive; \
14+
apt-get update -y; \
15+
apt-get install -y curl xz-utils pixz
16+
17+
ENV USER=jovyan
18+
ENV HOME=/home/${USER}
19+
ENV SHELL=/bin/bash
20+
21+
ARG CONDA_PREFIX=${HOME}/.conda
22+
ARG CONDA=${CONDA_PREFIX}/bin/conda
23+
24+
RUN adduser \
25+
--disabled-password \
26+
--gecos "Default user" \
27+
--uid 1000 \
28+
--home ${HOME} \
29+
--force-badname \
30+
${USER}
31+
32+
USER ${USER}
33+
34+
WORKDIR ${HOME}
35+
36+
# install miniforge to CONDA_PREFIX
37+
RUN set -ex; \
38+
curl -sSL -o /tmp/miniforge.sh https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh; \
39+
/bin/bash /tmp/miniforge.sh -b -p ${CONDA_PREFIX}; \
40+
rm -f /tmp/miniforge.sh
41+
42+
RUN echo "conda prefix after initial installation: $(du --human-readable --summarize ${CONDA_PREFIX})" > /dev/stderr
43+
44+
# install mamba solver
45+
RUN ${CONDA} install -n base conda-libmamba-solver
46+
47+
RUN echo "conda prefix after installing conda-libmamba-solver: $(du --human-readable --summarize ${CONDA_PREFIX})" > /dev/stderr
48+
49+
# set libmamba as the default resolver
50+
# https://conda.github.io/conda-libmamba-solver/getting-started/
51+
RUN ${CONDA} config --set solver libmamba
52+
53+
# update to conda-forge
54+
RUN ${CONDA} update -n base -c conda-forge conda
55+
56+
RUN echo "conda prefix after updating to conda-forge: $(du --human-readable --summarize ${CONDA_PREFIX})" > /dev/stderr
57+
58+
COPY --chown=${USER}:${USER} requirements.txt /tmp/requirements.txt
59+
COPY --from=python_builder --chown=${USER}:${USER} /app/jupyter_codeserver_proxy-/dist/*.whl /opt/jupyter_codeserver_proxy/dist/
60+
61+
# install nb_conda_kernels for discovering kernels (https://towardsdatascience.com/get-your-conda-environment-to-show-in-jupyter-notebooks-the-easy-way-17010b76e874)
62+
# install all dependencies
63+
# disable JupyterLab announcement pop-up (https://jupyterlab.readthedocs.io/en/stable/user/announcements.html)
64+
RUN set -e; \
65+
. ${CONDA_PREFIX}/etc/profile.d/conda.sh; \
66+
conda activate base; \
67+
conda install nb_conda_kernels nodejs; \
68+
pip install --no-cache-dir -r /tmp/requirements.txt /opt/jupyter_codeserver_proxy/dist/*.whl; \
69+
jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
70+
71+
RUN echo "conda prefix after installing jupyterhub: $(du --human-readable --summarize ${CONDA_PREFIX})" > /dev/stderr
72+
73+
# create new conda environment python-3.9
74+
# install infractl, lit
75+
RUN set -e; \
76+
. ${CONDA_PREFIX}/etc/profile.d/conda.sh; \
77+
conda create --name python-3.9 python=3.9 ipykernel s3cmd dvc; \
78+
conda activate python-3.9; \
79+
pip --no-cache-dir install infractl lit
80+
81+
RUN echo "conda prefix after installing infractl: $(du --human-readable --summarize ${CONDA_PREFIX})" > /dev/stderr
82+
83+
RUN ${CONDA} clean --all --force-pkgs-dirs --yes
84+
85+
RUN echo "conda prefix after cleaning: $(du --human-readable --summarize ${CONDA_PREFIX})" > /dev/stderr
86+
87+
# archive conda prefix
88+
RUN tar c -I"pixz -9" -f conda.tar.xz .conda
89+
90+
RUN echo "conda archive: $(du --human-readable conda.tar*)" > /dev/stderr
91+
92+
FROM ubuntu:22.04
93+
94+
ENV USER=jovyan
95+
ENV HOME=/home/${USER}
96+
ENV SHELL=/bin/bash
497

598
RUN set -ex; \
699
export DEBIAN_FRONTEND=noninteractive; \
7100
apt-get update -y; \
8-
apt-get install -y --no-install-recommends --fix-missing \
9-
curl \
10-
bash-completion \
11-
python3-pip \
12-
cmake gcc g++ ninja-build git clang-format; \
101+
apt-get install -y software-properties-common curl; \
102+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg > /usr/share/keyrings/githubcli-archive-keyring.gpg; \
13103
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list; \
14-
curl -sSL https://cli.github.com/packages/githubcli-archive-keyring.gpg > /usr/share/keyrings/githubcli-archive-keyring.gpg; \
15104
apt-get update -y; \
16-
apt-get install -y --no-install-recommends --fix-missing gh; \
105+
apt-get install -y --no-install-recommends \
106+
ca-certificates \
107+
curl \
108+
gh jq \
109+
git \
110+
bash-completion \
111+
cmake gcc g++ ninja-build git clang-format \
112+
sudo \
113+
pixz \
114+
; \
17115
rm -rf /var/lib/apt/lists/*
18116

19-
RUN pip install lit
117+
RUN set -ex; \
118+
adduser \
119+
--disabled-password \
120+
--gecos "Default user" \
121+
--uid 1000 \
122+
--home ${HOME} \
123+
--force-badname \
124+
${USER}; \
125+
usermod -aG sudo ${USER}; \
126+
echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers
127+
128+
COPY --from=conda_builder ${HOME}/conda.tar.xz /template/
129+
130+
COPY entrypoint.sh /template/
131+
132+
USER ${USER}
133+
134+
WORKDIR ${HOME}
135+
136+
RUN curl -fsSL https://code-server.dev/install.sh | sh && rm -rf "${HOME}/.cache"
137+
138+
EXPOSE 8888
20139

21-
RUN useradd -m dev
140+
ENTRYPOINT ["/bin/bash", "/template/entrypoint.sh"]
22141

23-
USER dev
24-
WORKDIR /home/dev

.github/dockerfiles/env/build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
REGISTRY=localhost:5000
4+
TAG=graph-compiler-env:0.0.11
5+
6+
set -e
7+
8+
kubectl -n docker-registry port-forward svc/docker-registry 5000:5000 &
9+
10+
cd $(dirname "$0")
11+
docker build --progress=plain . --tag $REGISTRY/$TAG
12+
docker push $REGISTRY/$TAG
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# See also
2+
# https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/main/images/singleuser-sample/requirements.in
3+
# https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/main/images/singleuser-sample/requirements.txt
4+
jupyterhub==4.0.2
5+
jupyterlab
6+
nbclassic
7+
nbgitpuller
8+
jupyter-server-proxy

0 commit comments

Comments
 (0)