Skip to content

Instantly share code, notes, and snippets.

@heathdrobertson
Last active November 13, 2019 21:59
Show Gist options
  • Save heathdrobertson/28fb3f8f4f30261186670192e1d878cb to your computer and use it in GitHub Desktop.
Save heathdrobertson/28fb3f8f4f30261186670192e1d878cb to your computer and use it in GitHub Desktop.
iHaskell Jupyter Lab Docker Image Build
```Dockerfile
FROM fpco/stack-build:lts-14.7
# Install all necessary Ubuntu packages
RUN apt-get update && apt-get install -y python3-pip libgmp-dev libmagic-dev libtinfo-dev libzmq3-dev libcairo2-dev libpango1.0-dev libblas-dev liblapack-dev gcc g++ nodejs && \
rm -rf /var/lib/apt/lists/*
# Install Jupyter notebook
RUN pip3 install -U jupyterlab
ARG NB_USER=defaultuser
ARG NB_UID=1000
ENV LANG en_US.UTF-8
ENV HOME /home/${NB_USER}
RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}
# Set up a working directory for IHaskell
RUN mkdir ${HOME}/ihaskell
WORKDIR ${HOME}/ihaskell
USER root
RUN chown -R ${NB_UID} ${HOME}
USER ${NB_UID}
# Set up stack
COPY stack.yaml stack.yaml
RUN stack config set system-ghc --global true
# Install dependencies for IHaskell
COPY ihaskell.cabal ihaskell.cabal
COPY ipython-kernel ipython-kernel
COPY ghc-parser ghc-parser
COPY ihaskell-display ihaskell-display
USER root
RUN chown -R ${NB_UID} ${HOME}
USER ${NB_UID}
RUN stack build --only-snapshot
# Install IHaskell itself. Don't just COPY . so that
# changes in e.g. README.md don't trigger rebuild.
COPY src ${HOME}/ihaskell/src
COPY html ${HOME}/ihaskell/html
COPY main ${HOME}/ihaskell/main
COPY LICENSE ${HOME}/ihaskell/LICENSE
USER root
RUN chown -R ${NB_UID} ${HOME}
USER ${NB_UID}
RUN stack build && stack install
# Run the notebook
ENV PATH $(stack path --local-install-root)/bin:$(stack path --snapshot-install-root)/bin:$(stack path --compiler-bin):/home/${NB_USER}/.local/bin:${PATH}
RUN ihaskell install --stack
USER root
COPY jupyter_lab_extensions.sh ./jupyter_lab_extensions.sh
RUN bash ./jupyter_lab_extensions.sh
RUN jupyter notebook --generate-config
RUN chown -R ${NB_UID} ${HOME}
USER ${NB_UID}
WORKDIR ${HOME}
CMD ["jupyter", "lab", "--allow-root", "--ip", "0.0.0.0"]
```
#!/bin/bash
# File create by Heath Robertson CodeHappens@ToiletHill
echo "Startup Commands Executing -Heath"
declare -a lst=("jupyterlab_vim" "@jupyterlab/toc" "@ijmbarr/jupyterlab_spellchecker")
for i in ${lst[*]}
do
jupyter labextension install ${i}
jupyter labextension enable ${i}
echo ${i}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment