From 45ad25a9bb82cbec09aab55a2a656fc103e7c431 Mon Sep 17 00:00:00 2001 From: Andrew Gibiansky Date: Sun, 31 Jan 2016 19:03:56 -0800 Subject: [PATCH] Added and tested Dockerfile and instructions on how to use it --- .dockerignore | 30 ++++++++++++++++++++++++++++++ Dockerfile | 43 +++++++++++++++++++++++++++++++++++++++++++ README.md | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..224488dd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +*.hi +Untitled*.ipynb +main/Main +.stack-work +notebooks/Test.ipynb +notebooks/Untitled.ipynb +notebooks/Untitled0.ipynb +*.dyn_o +*.dyn_hi +*.o +dist +IHaskell/GHC +env +.shelly +.ihaskell_capture +.ipynb_checkpoints +Hspec +todo +profile/profile.tar +.cabal-sandbox +cabal.sandbox.config +.tmp1 +.tmp2 +.tmp3 +.stack-work +src/Hspec +notebooks +dist +**/dist +**/.stack-work diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..938d9817 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu:14.04 + +# Install all necessary Ubuntu packages +RUN apt-get update && apt-get install -y python-dev python-setuptools libmagic-dev libtinfo-dev libzmq3-dev libcairo2-dev libpango1.0-dev libblas-dev liblapack-dev gcc g++ + +# Install Jupyter notebook +RUN easy_install -U pip && pip install -U jupyter + +# Install stack from the FPComplete repositories. +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 575159689BEFB442 && \ + echo 'deb http://download.fpcomplete.com/ubuntu trusty main' > /etc/apt/sources.list.d/fpco.list && \ + apt-get update && \ + apt-get install -y stack + +# Set up a working directory for IHaskell +RUN mkdir /ihaskell +WORKDIR /ihaskell + +# Set up stack +COPY stack.yaml stack.yaml +RUN stack setup + +# Install dependencies for IHaskell +COPY ihaskell.cabal ihaskell.cabal +COPY ipython-kernel ipython-kernel +COPY ghc-parser ghc-parser +COPY ihaskell-display ihaskell-display +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 /ihaskell/src +COPY html /ihaskell/html +COPY main /ihaskell/main +COPY LICENSE /ihaskell/LICENSE +RUN stack build && stack install + +# Run the notebook +RUN mkdir /notebooks +ENV PATH /ihaskell/.stack-work/install/x86_64-linux/nightly-2015-08-15/7.10.2/bin:/root/.stack/snapshots/x86_64-linux/nightly-2015-08-15/7.10.2/bin:/root/.stack/programs/x86_64-linux/ghc-7.10.2/bin:/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +RUN ihaskell install +ENTRYPOINT stack exec -- jupyter notebook --NotebookApp.port=8888 '--NotebookApp.ip=*' --NotebookApp.notebook_dir=/notebooks +EXPOSE 8888 diff --git a/README.md b/README.md index d5d65eff..d14fb45a 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,44 @@ Arch Linux has a package for IHaskell: https://aur.archlinux.org/packages/ihaske Here is a blog post with step-by-step instructions for Ubuntu 14.04 (but should also work on other versions): https://remusao.github.io/install-ihaskell-on-ubuntu-1404-with-stack.html +### Docker Installation + +The easiest way to use IHaskell is to install it inside a Docker container, which will come with the entire necessary stack, including Jupyter notebook. To install Docker, follow the [OS-specific instructions for your OS](https://docs.docker.com/engine/installation/). + +To get the Docker image, pull it from the Docker Hub: +```bash +docker pull gibiansky/ihaskell:latest +``` + +You can then run IHaskell with: +```bash +docker run -it --volume $(pwd):/notebooks --publish 8888:8888 gibiansky/ihaskell:latest +``` + +If you wish to expose the Jupyter notebook on a port other than 8888, use the options `--publish 8888:$PORT` for any `PORT`. + +If you'd like to build the image yourself, there is a provided `Dockerfile`, which you can build using: + +```bash +# Build it in the repository directory +cd IHaskell/ + +# Building the image from scratch may take quite a while! (an hour or more) +docker build -t ihaskell:latest . + +# Run the image without the gibiansky/ prefix +PORT=8888 +docker run -it --volume $(pwd):/notebooks --publish 8888:$PORT ihaskell:latest +``` + +Open `localhost:$PORT` (`localhost:8888`) in your web browser to use IHaskell. If you are running on Mac OS X, then you will likely need to account for `docker-machine` and use the local IP of the machine instead of `localhost`. + ### Install Using Installation Scripts #### Ubuntu: +**If you are a user, and not a developer, it is recommended you use the `docker` instructions above instead of the Ubuntu installation script.** + If you are using a modern version of Ubuntu, clone the repository and then run the `ubuntu-install.sh` script: ```bash git clone http://www.github.com/gibiansky/IHaskell