Skip to content

Commit 709537f

Browse files
authored
Merge pull request #87 from darribas/mono_restructure
Mono restructure
2 parents 6c8ff55 + a3e33f3 commit 709537f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+277
-52
lines changed

Makefile

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
export GDS_VERSION=10.0
2+
# make command [image=image_name]
23
#DOCKERRUN = docker run --rm --user root -e GRANT_SUDO=yes -e NB_UID=1002 -e NB_GID=100 -v `pwd`:/home/jovyan/test
34
DOCKERRUN = docker run -v `pwd`:/home/jovyan/test
45
test: test_py test_r
56
test_py:
6-
$(DOCKERRUN) darribas/gds_py:${GDS_VERSION} start.sh jupyter nbconvert --to html --execute /home/jovyan/test/gds_py/check_py_stack.ipynb
7+
$(DOCKERRUN) $(image) start.sh /opt/conda/envs/gds/bin/jupyter nbconvert --to html --execute /home/jovyan/test/env/py/check_py_stack.ipynb
78
test_r:
8-
$(DOCKERRUN) darribas/gds:${GDS_VERSION} start.sh jupyter nbconvert --to html --execute /home/jovyan/test/gds/check_r_stack.ipynb
9+
$(DOCKERRUN) $(image) start.sh /opt/conda/envs/gds/bin/jupyter nbconvert --to html --execute /home/jovyan/test/env/r/check_r_stack.ipynb
910
write_stacks: write_py_stack write_r_stack
1011
write_py_stack:
11-
$(DOCKERRUN) darribas/gds_py:${GDS_VERSION} start.sh bash -c "conda list -n gds > /home/jovyan/test/gds_py/stack_py.txt"
12-
$(DOCKERRUN) darribas/gds_py:${GDS_VERSION} start.sh sed -i '1iGDS version: ${GDS_VERSION}' /home/jovyan/test/gds_py/stack_py.txt
13-
$(DOCKERRUN) darribas/gds_py:${GDS_VERSION} start.sh python -c "import subprocess, pandas; fo=open('/home/jovyan/test/gds_py/stack_py.md', 'w'); fo.write(pandas.read_json(subprocess.check_output(['conda', 'list', '-n', 'gds', '--json']).decode())[['name', 'version', 'build_string', 'channel']].to_markdown());fo.close()"
14-
$(DOCKERRUN) darribas/gds_py:${GDS_VERSION} start.sh sed -i "1s/^/\n/" /home/jovyan/test/gds_py/stack_py.md
12+
$(DOCKERRUN) $(image) start.sh bash -c "conda list -n gds > /home/jovyan/test/env/py/stack_py.txt"
13+
$(DOCKERRUN) $(image) start.sh sed -i '1iGDS image: $(image)' /home/jovyan/test/env/py/stack_py.txt
14+
$(DOCKERRUN) $(image) start.sh /opt/conda/envs/gds/bin/python -c "import subprocess, pandas; fo=open('/home/jovyan/test/env/py/stack_py.md', 'w'); fo.write(pandas.read_json(subprocess.check_output(['conda', 'list', '-n', 'gds', '--json']).decode())[['name', 'version', 'build_string', 'channel']].to_markdown());fo.close()"
15+
$(DOCKERRUN) $(image) start.sh sed -i "1s/^/\n/" /home/jovyan/test/env/py/stack_py.md
1516
write_r_stack:
16-
$(DOCKERRUN) darribas/gds:${GDS_VERSION} start.sh sh -c 'Rscript -e "ip <- as.data.frame(installed.packages()[,c(1,3:4)]); print(ip)" > /home/jovyan/test/gds/stack_r.txt'
17-
$(DOCKERRUN) darribas/gds:${GDS_VERSION} start.sh sed -i '1iGDS version: ${GDS_VERSION}' /home/jovyan/test/gds/stack_r.txt
18-
$(DOCKERRUN) darribas/gds:${GDS_VERSION} start.sh Rscript -e "library(knitr); ip <- as.data.frame(installed.packages()[,c(1,3:4)]); fc <- file('/home/jovyan/test/gds/stack_r.md'); writeLines(kable(ip, format = 'markdown'), fc); close(fc);"
19-
$(DOCKERRUN) darribas/gds:${GDS_VERSION} start.sh sed -i "1s/^/\n/" /home/jovyan/test/gds/stack_r.md
17+
$(DOCKERRUN) $(image) start.sh sh -c 'Rscript -e "ip <- as.data.frame(installed.packages()[,c(1,3:4)]); print(ip)" > /home/jovyan/test/env/r/stack_r.txt'
18+
$(DOCKERRUN) $(image) start.sh sed -i '1iGDS image: $(image)' /home/jovyan/test/env/r/stack_r.txt
19+
$(DOCKERRUN) $(image) start.sh Rscript -e "library(knitr); ip <- as.data.frame(installed.packages()[,c(1,3:4)]); fc <- file('/home/jovyan/test/env/r/stack_r.md'); writeLines(kable(ip, format = 'markdown'), fc); close(fc);"
20+
$(DOCKERRUN) $(image) start.sh sed -i "1s/^/\n/" /home/jovyan/test/env/r/stack_r.md
2021
write_py_explicit:
21-
$(DOCKERRUN) darribas/gds_py:${GDS_VERSION} start.sh sh -c "conda list -n gds --explicit > /home/jovyan/test/gds_py/stack_py_explicit.txt"
22+
$(DOCKERRUN) $(image) start.sh sh -c "conda list -n gds --explicit > /home/jovyan/test/env/py/stack_py_explicit.txt"
2223
website_build:
2324
cd website && \
2425
rm -rf _includes && \

env/Dockerfile

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
FROM quay.io/jupyter/minimal-notebook
2+
3+
LABEL maintainer="Dani Arribas-Bel <D.Arribas-Bel@liverpool.ac.uk>"
4+
5+
# Set version
6+
ENV GDS_ENV_VERSION "11.0alpha"
7+
8+
# https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/Dockerfile
9+
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
10+
11+
ADD ./*/*.sh $HOME/scripts/
12+
USER root
13+
RUN chmod +x $HOME/scripts/*.sh
14+
USER $NB_UID
15+
16+
##############
17+
### Python ###
18+
##############
19+
20+
#--- Jupyter Dev ---#
21+
RUN $HOME/scripts/install_jupyter_dev.sh
22+
23+
#--- Python ---#
24+
25+
ADD ./py/gds_py.yml /home/${NB_USER}/
26+
RUN $HOME/scripts/install_py_stack.sh
27+
ENV PATH="/opt/conda/envs/gds/bin/:${PATH}"
28+
29+
#--- Clean up ---#
30+
31+
USER root
32+
33+
# Clean cache up
34+
RUN jupyter lab clean -y \
35+
&& conda clean --yes --all --force-pkgs-dirs \
36+
&& npm cache clean --force \
37+
&& rm -rf $CONDA_DIR/share/jupyter/lab/staging \
38+
&& rm -rf "/home/${NB_USER}/.node-gyp" \
39+
&& rm -rf /home/$NB_USER/.cache/yarn \
40+
&& fix-permissions "${CONDA_DIR}" \
41+
&& fix-permissions "/home/${NB_USER}"
42+
# Build mpl font cache
43+
# https://github.com/jupyter/docker-stacks/blob/c3d5df67c8b158b0aded401a647ea97ada1dd085/scipy-notebook/Dockerfile#L59
44+
USER $NB_UID
45+
ENV XDG_CACHE_HOME="/home/${NB_USER}/.cache/"
46+
RUN source activate gds \
47+
&& MPLBACKEND=Agg python -c "import matplotlib.pyplot"
48+
49+
#########
50+
### R ###
51+
#########
52+
53+
USER root
54+
55+
# Remove Conda from path to not interfere with R install
56+
RUN echo ${PATH}
57+
ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
58+
RUN echo ${PATH}
59+
60+
# install R
61+
RUN $HOME/scripts/install_R.sh
62+
63+
# Install Tidyverse + Geospatial
64+
RUN $HOME/scripts/install_R_stack.sh
65+
66+
# install R GDS stack
67+
RUN $HOME/scripts/install_R_gds.sh
68+
69+
# re-attach conda to path
70+
ENV PATH="/opt/conda/envs/gds/bin/:/opt/conda/condabin:/opt/conda/envs/gds/bin:/opt/conda/bin:${PATH}"
71+
72+
#--- R/Python ---#
73+
74+
RUN $HOME/scripts/setup_py-r.sh
75+
76+
#--- Quarto ---#
77+
RUN $HOME/scripts/install_quarto.sh
78+
79+
###########
80+
### Dev ###
81+
###########
82+
83+
#--- jekyll ---#
84+
RUN $HOME/scripts/install_jekyll.sh
85+
86+
#--- tippecanoe ---#
87+
RUN $HOME/scripts/install_tippecanoe.sh
88+
89+
#--- htop ---#
90+
RUN apt-get update \
91+
&& apt-get install -y --no-install-recommends htop
92+
93+
#--- Decktape ---#
94+
RUN $HOME/scripts/install_decktape.sh
95+
96+
#--- LaTeX tools ---#
97+
ADD ./dev/texBuild.py $HOME/
98+
ADD ./dev/install_texbuild.py $HOME/
99+
RUN $HOME/scripts/install_latex_tools.sh
100+
101+
#--- Vim ---#
102+
ADD ./dev/vimrc $HOME/.vimrc
103+
RUN $HOME/scripts/install_vim.sh
104+
105+
#--- GPQ ---#
106+
RUN $HOME/scripts/install_gpq.sh
107+
108+
#--- Clean up ---#
109+
RUN fix-permissions $HOME \
110+
&& fix-permissions $CONDA_DIR
111+
112+
USER $NB_UID
113+
114+
RUN find /opt/conda/ -follow -type f -name '*.a' -delete \
115+
&& find /opt/conda/ -follow -type f -name '*.pyc' -delete \
116+
&& find /opt/conda/ -follow -type f -name '*.js.map' -delete \
117+
&& find /opt/conda/envs/gds//lib/python*/site-packages/bokeh/server/static \
118+
-follow -type f -name '*.js' ! -name '*.min.js' -delete \
119+
&& pip cache purge \
120+
&& rm -rf $HOME/.cache/pip
121+
122+
USER root
123+
RUN cd $NB_HOME \
124+
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds \
125+
&& rm -rf $GEM_HOME/cache \
126+
&& rm -rf /usr/local/bundle/cache \
127+
&& apt-get autoclean \
128+
&& apt-get autoremove \
129+
&& apt-get clean \
130+
&& rm -rf /var/lib/apt/lists/* \
131+
&& rm -rf $HOME/scripts
132+
133+
USER $NB_UID
File renamed without changes.
File renamed without changes.
File renamed without changes.

gds_dev/install_decktape.sh renamed to env/dev/install_decktape.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ apt-get update -qq \
6363
libcups2 \
6464
libxss-dev \
6565
libxrandr-dev \
66+
&& rm -rf /var/lib/apt/lists/* \
6667
&& apt-get autoclean \
6768
&& apt-get autoremove \
6869
&& apt-get clean
File renamed without changes.

env/dev/install_jekyll.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
apt-get update \
4+
&& apt-get install -y --no-install-recommends \
5+
ruby-full \
6+
build-essential \
7+
zlib1g-dev
8+
# https://github.com/sass-contrib/sass-embedded-host-ruby/issues/130#issuecomment-1588245011
9+
gem install sass-embedded
10+
gem install sass --force sass-embedded
11+
gem install jekyll bundler github-pages jekyll-scholar just-the-docs
12+
13+
rm -rf /var/lib/gems/3.0.0/cache/*
14+
rm -rf /var/lib/apt/lists/* \
15+
&& apt-get autoclean \
16+
&& apt-get autoremove \
17+
&& apt-get clean
18+

gds_dev/install_jupyter_dev.sh renamed to env/dev/install_jupyter_dev.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ pip install dask-labextension bash_kernel jupyterlab_vim \
1818
sed -i "s/c.KernelSpecManager.whitelist = {'gds', 'ir'}/c.KernelSpecManager.whitelist = {'gds', 'ir', 'bash'}/g" \
1919
/home/${NB_USER}/.jupyter/jupyter_lab_config.py
2020

21+
#--- Pypeteer ---#
22+
pyppeteer-install
2123

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

env/dev/install_vim.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
#################
4+
### Vim setup ###
5+
#################
6+
7+
apt-get update \
8+
&& apt-get install -y --no-install-recommends vim \
9+
&& curl -fLo $HOME/.vim/autoload/plug.vim --create-dirs \
10+
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim \
11+
&& vim +PlugInstall +qall \
12+
&& rm -rf /var/lib/apt/lists/* \
13+
&& apt-get autoclean \
14+
&& apt-get autoremove \
15+
&& apt-get clean
16+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

gds_py/gds_py.yml renamed to env/py/gds_py.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ dependencies:
2929
- ipympl
3030
- ipywidgets
3131
- jupyterlab>=4.0
32-
- jupyter_bokeh
3332
- jupyter-book
3433
- jupytext
3534
- legendgram
@@ -46,8 +45,6 @@ dependencies:
4645
- pandana
4746
- pip
4847
- pip:
49-
- jupyterlab-geojson
50-
- jupyterlab_myst
5148
- matplotlib-scalebar
5249
- polars
5350
# - pygeoda
File renamed without changes.
File renamed without changes.

env/py/install_jupyter_dev.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
#--- [Run under $NB_USER] ---#
4+
5+
#--- Text editor / default Vim ---#
6+
# https://github.com/jupyterlab/jupyterlab/issues/14599
7+
mkdir -p /home/$NB_USER/.jupyter/lab/user-settings/\@jupyterlab/fileeditor-extension/ \
8+
&& echo '{"editorConfig": {"codeFolding": true, "highlightActiveLine": true, "highlightTrailingWhitespace": true}}' \
9+
>> /home/$NB_USER/.jupyter/lab/user-settings/\@jupyterlab/fileeditor-extension/plugin.jupyterlab-settings
10+
11+
#--- JupyterLab extensions & Bash kernel ---#
12+
13+
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" \
14+
&& pip install \
15+
bash_kernel \
16+
jupyterlab-geojson \
17+
jupyterlab_myst \
18+
jupyterlab-quarto \
19+
jupyterlab_vim \
20+
jupyterlab_widgets \
21+
jupytext
22+
# Bash kernel
23+
python -m bash_kernel.install
24+
# Required for dask extension
25+
mamba install python-graphviz
26+
# Clean
27+
pip cache purge \
28+
&& conda clean --all --yes --force-pkgs-dirs \
29+
&& jupyter lab clean -y \
30+
&& npm cache clean --force
31+

env/py/install_py_stack.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
#--- [Run under $NB_USER] ---#
4+
5+
# Install GDS conda environment
6+
mamba env create -f gds_py.yml \
7+
&& source activate gds \
8+
&& python -m ipykernel install --user --name gds --display-name "GDS-$GDS_ENV_VERSION" \
9+
&& conda deactivate \
10+
&& rm ./gds_py.yml \
11+
&& conda clean --yes --all --force-pkgs-dirs \
12+
&& find /opt/conda/ -follow -type f -name '*.a' -delete \
13+
&& find /opt/conda/ -follow -type f -name '*.pyc' -delete \
14+
&& find /opt/conda/ -follow -type f -name '*.js.map' -delete \
15+
&& find /opt/conda/envs/gds//lib/python*/site-packages/bokeh/server/static \
16+
-follow -type f -name '*.js' ! -name '*.min.js' -delete \
17+
&& pip cache purge \
18+
&& rm -rf $HOME/.cache/pip
19+
20+
# Pypeteer
21+
pyppeteer-install
22+
23+
# Make GDS default
24+
# https://github.com/jupyter/notebook/issues/3674#issuecomment-397212982
25+
jupyter lab --generate-config \
26+
&& echo "c.MultiKernelManager.default_kernel_name='gds'" >> \
27+
/home/${NB_USER}/.jupyter/jupyter_lab_config.py \
28+
&& echo "conda activate gds" >> /home/${NB_USER}/.bashrc \
29+
&& echo "c.KernelSpecManager.ensure_native_kernel = False" >> \
30+
/home/${NB_USER}/.jupyter/jupyter_lab_config.py \
31+
&& echo "c.KernelSpecManager.whitelist = {'gds', 'bash'}" >> \
32+
/home/${NB_USER}/.jupyter/jupyter_lab_config.py
33+
jupyter kernelspec remove -y python3
34+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

gds/install_R.sh renamed to env/r/install_R.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ apt-get update -qq \
1414
&& apt-get update -qq \
1515
&& apt-get install -y --no-install-recommends \
1616
ca-certificates \
17+
libcurl4-openssl-dev \
1718
less \
1819
libopenblas-base \
1920
locales \
@@ -56,6 +57,8 @@ apt-get update \
5657
&& ln -s /usr/lib/R/site-library/littler/examples/testInstalled.r /usr/local/bin/testInstalled.r \
5758
&& ln -s /usr/lib/R/site-library/littler/examples/update.r /usr/local/bin/update.r \
5859
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds \
59-
&& rm -rf /var/lib/apt/lists/*
60-
60+
&& rm -rf /var/lib/apt/lists/* \
61+
&& apt-get autoclean \
62+
&& apt-get autoremove \
63+
&& apt-get clean
6164

gds/install_R_gds.sh renamed to env/r/install_R_gds.sh

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@ apt-get update -qq \
2626
&& apt-get clean \
2727
&& rm -rf /var/lib/apt/lists/*
2828

29-
#--- R ---#
30-
# https://github.com/rocker-org/rocker-versioned/blob/master/r-ver/Dockerfile
31-
# Look at: http://sites.psu.edu/theubunturblog/installing-r-in-ubuntu/
32-
33-
echo "deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/" >> /etc/apt/sources.list \
34-
&& sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \
35-
&& apt-get update \
36-
&& apt-get install -y \
37-
r-base \
38-
r-base-dev \
39-
&& apt-get autoclean \
40-
&& apt-get autoremove \
41-
&& apt-get clean \
42-
&& rm -rf /var/lib/apt/lists/*
43-
4429
#--- R libs ---#
4530
# SAN requirements (on top of Rocker Geospatial)
4631
# https://github.com/GDSL-UL/san/blob/master/01-overview.Rmd

gds/install_R_stack.sh renamed to env/r/install_R_stack.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ apt-get update -qq \
3232
R -e "install.packages(c( \
3333
'tidyverse', \
3434
'devtools', \
35+
'curl', \
3536
'rmarkdown', \
3637
'BiocManager', \
3738
'vroom', \
@@ -68,6 +69,7 @@ add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable \
6869
libhdf4-alt-dev \
6970
libhdf5-dev \
7071
libjq-dev \
72+
liblwgeom-dev \
7173
libpq-dev \
7274
libproj-dev \
7375
libprotobuf-dev \

gds/setup_py-r.sh renamed to env/r/setup_py-r.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Set up links between Python/R (IRkernel, rpy2) and R/Python (reticulate)
2+
13
ln -s /opt/conda/envs/gds/bin/jupyter /usr/local/bin
24
R -e "install.packages(c( \
35
'IRkernel', 'reticulate' \
@@ -8,8 +10,8 @@ LD_LIBRARY_PATH /usr/local/lib/R/lib/:${LD_LIBRARY_PATH}
810
fix-permissions $HOME
911
fix-permissions $CONDA_DIR
1012

11-
sed -i "s/c.KernelSpecManager.whitelist = {'gds'}/c.KernelSpecManager.whitelist = {'gds', 'ir'}/g" \
12-
me/${NB_USER}/.jupyter/jupyter_lab_config.py
13+
sed -i "s/c.KernelSpecManager.whitelist = {'gds', 'bash'}/c.KernelSpecManager.whitelist = {'gds', 'ir', 'bash'}/g" \
14+
/home/${NB_USER}/.jupyter/jupyter_lab_config.py
1315

1416
pip install -U --no-deps \
1517
rpy2 \
@@ -18,7 +20,8 @@ pip install -U --no-deps \
1820
pytz_deprecation_shim \
1921
jinja2 \
2022
'cffi>=1.10.0' \
21-
tzlocal
23+
tzlocal \
24+
&& pip cache purge
2225

2326
rm -rf /home/$NB_USER/.cache/pip
2427
rm -rf /tmp/downloaded_packages/ /tmp/*.rds
File renamed without changes.
File renamed without changes.

gds_code/Dockerfile renamed to frontend_code/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM darribas/gds_dev:10.0
1+
FROM gds:11.0alpha
22

33
USER root
44

0 commit comments

Comments
 (0)