forked from darribas/gds_env
-
Notifications
You must be signed in to change notification settings - Fork 1
/
DockerfileSmall
102 lines (87 loc) · 4.01 KB
/
DockerfileSmall
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
98
99
100
101
102
# How to pull and run this image
# > docker pull jreades/gsa_sm:1.0
# > docker run --rm -ti -p 8888:8888 -v ${PWD}:/home/jovyan/work jreades/gsa_sm:1.0
#
# How to build
# > docker build -t jreades/gsa_sm:1.0 -f DockerfileSmall --compress .
# How to push an updated image
# > docker tag jreades/gsa_sm:1.0 jreades/gsa_sm:2019
# > docker tag jreades/gsa_sm:1.0 jreades/gsa_sm:latest
# > docker login docker.io
# > docker push jreades/gsa_sm:1.0 jreades/gsa_sm:latest
#
#--- Build from Jupyter-provided Minimal Install ---#
# https://github.com/jupyter/docker-stacks/blob/master/docs/using/selecting.md
# 2 Sept 2019
FROM jupyter/minimal-notebook:1386e2046833
LABEL maintainer="[email protected]"
ENV base_nm gsa_sm
ENV release_nm ${base_nm}2019
ENV kernel_nm 'GSA2019Small'
RUN echo "Building $kernel_nm"
# https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/Dockerfile
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
#--- Python ---#
# Get conda updated and set up before installing
# any packages
RUN conda update -n base conda --yes \
&& conda config --add channels conda-forge \
&& conda config --set channel_priority strict
# Now install the packages then tidy up
COPY ${base_nm}.yml /tmp/
RUN conda-env create -f /tmp/${base_nm}.yml \
&& conda clean --all --yes --force-pkgs-dirs \
&& find /opt/conda/ -follow -type f -name '*.a' -delete \
&& find /opt/conda/ -follow -type f -name '*.pyc' -delete \
&& find /opt/conda/ -follow -type f -name '*.js.map' -delete \
&& conda list
# Set paths for conda and PROJ
ENV PATH /opt/conda/envs/${release_nm}/bin:$PATH
ENV PROJ_LIB /opt/conda/envs/gsa2019/share/proj/
# And configure the bash shell params
COPY init.sh /tmp/
RUN cat /tmp/init.sh > ~/.bashrc
RUN echo "export PROJ_LIB=/opt/conda/envs/${release_nm}/share/proj/" >> ~/.bashrc
# Install jupyterlab extensions, but don't build
# (saves some time over install and building each)
RUN jupyter lab clean \
# These should work, but can be commented out for speed during dev
&& jupyter labextension install --no-build @jupyter-widgets/jupyterlab-manager \
&& jupyter labextension install --no-build jupyter-matplotlib \
&& jupyter labextension install --no-build @jupyterlab/mathjax3-extension \
&& jupyter labextension install --no-build plotlywidget \
&& jupyter labextension install --no-build @jupyterlab/plotly-extension \
&& jupyter labextension install --no-build @jupyterlab/geojson-extension \
&& jupyter labextension install --no-build @krassowski/jupyterlab_go_to_definition \
&& jupyter labextension install --no-build @ryantam626/jupyterlab_code_formatter \
&& jupyter labextension install --no-build @bokeh/jupyter_bokeh \
&& jupyter labextension install --no-build @pyviz/jupyterlab_pyviz
# Build the jupyterlab extensions
RUN jupyter lab build \
&& jupyter labextension enable jupyterlab-manager \
&& jupyter labextension enable jupyter-matplotlib \
&& jupyter labextension enable mathjax3-extension \
&& jupyter labextension enable plotlywidget \
&& jupyter labextension enable plotly-extension \
&& jupyter labextension enable geojson-extension \
&& jupyter labextension enable jupyterlab_go_to_definition \
&& jupyter labextension enable jupyterlab_code_formatter \
&& jupyter labextension enable jupyter_bokeh \
&& jupyter labextension enable jupyterlab_pyviz
#--- JupyterLab config ---#
RUN echo "c.NotebookApp.default_url = '/lab'" \
>> /home/$NB_USER/.jupyter/jupyter_notebook_config.py
# Clean up
RUN npm cache clean --force \
&& rm -rf $CONDA_DIR/share/jupyter/lab/staging\
&& rm -rf /home/$NB_USER/.cache/yarn
#--- Set up Kernelspec so name visible in chooser ---#
USER root
SHELL ["/bin/bash", "-c"]
RUN . /opt/conda/etc/profile.d/conda.sh \
&& conda activate ${release_nm} \
&& python -m ipykernel install --name ${release_nm} --display-name ${kernel_nm} \
&& ln -s /opt/conda/bin/jupyter /usr/local/bin
# Switch back to user to avoid accidental container runs as root
USER $NB_UID
RUN echo "Build complete."