Skip to content

Instantly share code, notes, and snippets.

@psychemedia
Last active February 12, 2019 01:07
Show Gist options
  • Select an option

  • Save psychemedia/d67e7de29a2d012183681778662ef4b6 to your computer and use it in GitHub Desktop.

Select an option

Save psychemedia/d67e7de29a2d012183681778662ef4b6 to your computer and use it in GitHub Desktop.
Adding OpenRefine to a Jupyter notebook container for proxying
REFINEVERSION=3.1
JUPYTER_TOKEN=letmein

OpenRefine in a Jupyter notebook container

Can we add an OpenRefine app to a Jupyer notebook container and then proxy it using the Jupyter server proxy?

In a Digital Ocean one-click Docker droplet (min 3GB serve should be okay too), use the User data provided in this gist to create a Docker container based on an official Docker container that also contains a specified version of OpenRefine (v3.1 by default).

Use the JUPYTER_TOKEN variable to define a token to let you in to the server. The best way of using this is as a one time password that allows you to define your own notebook password (see the bottom of the notebook login screen on start-up).

After 2-3 minutes (time to download and install the notebook container, update apt, download and install Java and OpenRefine), you should see the notebook login screen.

OpenRefine can be started from the notebook homepage New menu (you may need to refresh the browser if you see an error page when launching OpenRefine for the first time).

Don't forget to destroy your DIgital Ocean droplet when you've finished with it, unless you're happy to keep paying the rental...

version: '3.5'
services:
jupyter:
container_name: refine_jupyter_notebook_container
#image: jupyter/minimal-notebook
build:
context: .
args:
- REFINEVERSION=$REFINEVERSION
environment:
JUPYTER_TOKEN: "$JUPYTER_TOKEN"
ports:
- "80:8888"
networks:
- jupyternet
volumes:
- ./jupyter_notebook_config.py:/home/jovyan/.jupyter/jupyter_notebook_config.py
restart: unless-stopped
networks:
jupyternet:
driver: bridge
volumes:
jupyter:
FROM jupyter/minimal-notebook
RUN pip install --no-cache git+https://github.com/jupyterhub/jupyter-server-proxy
USER root
RUN apt-get update && apt-get install -y openjdk-8-jre && apt-get clean
USER $NB_USER
ARG REFINEVERSION=3.1
ENV REFINEVERSION=$REFINEVERSION
RUN wget -q -O openrefine-$REFINEVERSION.tar.gz https://github.com/OpenRefine/OpenRefine/releases/download/$REFINEVERSION/openrefine-linux-$REFINEVERSION.tar.gz
RUN mkdir -p $HOME/.openrefine
RUN tar xzf openrefine-$REFINEVERSION.tar.gz -C $HOME/.openrefine
RUN rm openrefine-$REFINEVERSION.tar.gz
RUN mkdir -p $HOME/openrefine
# Traitlet configuration file for jupyter-notebook.
import os
REFINEVERSION = os.getenv('REFINEVERSION','3.1')
c.ServerProxy.servers = {
'openrefine': {
'command': ['/home/jovyan/.openrefine/openrefine-{REFINEVERSION}/refine'.format(REFINEVERSION=REFINEVERSION), '-p', '{port}','-d','/home/jovyan/openrefine'],
'port': 3333,
'timeout': 120,
'launcher_entry': {
'title': 'OpenRefine'
},
},
}
#!/bin/bash
#Optionally:
export JUPYTER_TOKEN=myOwnPA5%w0rD
#Optionally:
#export REFINEVERSION=2.8
GIST=d67e7de29a2d012183681778662ef4b6
git clone https://gist.github.com/$GIST.git
cd $GIST
docker-compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment