diff --git a/Dockerfile b/Dockerfile index ea1c1fb0..b85f6372 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,10 @@ # Dockerfile for an image with the currently checked out version of zipline installed. To build: # # docker build -t quantopian/zipline . -# +# # To run the container: # -# docker run -v=/path/to/your/notebooks:/projects -p 8888:8888/tcp --name zipline -it quantopian/zipline +# docker run -v /path/to/your/notebooks:/projects -v ~/.zipline:/root/.zipline -p 8888:8888/tcp --name zipline -it quantopian/zipline # # To access Jupyter when running docker locally (you may need to add NAT rules): # @@ -13,27 +13,19 @@ # # default password is jupyter. to provide another, see: # http://jupyter-notebook.readthedocs.org/en/latest/public_server.html#preparing-a-hashed-password -# +# # once generated, you can pass the new value via `docker run --env` the first time # you start the container. -# +# # You can also run an algo using the docker exec command. For example: # -# docker exec -it zipline run_algo.py -f /projects/my_algo.py --start 2015-1-1 --end 2016-1-1 \ -# --symbols XOP -o /projects/result.pickle +# docker exec -it zipline zipline run -f /projects/my_algo.py --start 2015-1-1 --end 2016-1-1 /projects/result.pickle # -# For developers who want to access source inside the zipline container, try running this from -# within the root of the zipline source tree: -# -# docker run -v=/path/to/your/notebooks:/projects -v=`pwd`:/zipline -p 443:8888/tcp \ -# --name zipline -it quantopian/zipline -# - FROM python:2.7 # # set up environment -# +# ENV PROJECT_DIR=/projects \ NOTEBOOK_PORT=8888 \ SSL_CERT_PEM=/root/.jupyter/jupyter.pem \ @@ -41,19 +33,19 @@ ENV PROJECT_DIR=/projects \ PW_HASH="u'sha1:31cb67870a35:1a2321318481f00b0efdf3d1f71af523d3ffc505'" \ CONFIG_PATH=/root/.jupyter/jupyter_notebook_config.py -# +# # install TA-Lib and other prerequisites -# +# RUN mkdir ${PROJECT_DIR} \ && apt-get -y update \ && apt-get -y install libfreetype6-dev libpng-dev libopenblas-dev liblapack-dev gfortran \ - && curl -L http://downloads.sourceforge.net/project/ta-lib/ta-lib/0.4.0/ta-lib-0.4.0-src.tar.gz | tar xvz + && curl -L http://downloads.sourceforge.net/project/ta-lib/ta-lib/0.4.0/ta-lib-0.4.0-src.tar.gz | tar xvz # # build and install zipline from source. install TA-Lib after to ensure # numpy is available. -# +# WORKDIR /ta-lib @@ -73,10 +65,10 @@ RUN pip install numpy==1.9.2 \ ADD ./etc/docker_cmd.sh / -# +# # make port available. /zipline is made a volume # for developer testing. -# +# EXPOSE ${NOTEBOOK_PORT} # @@ -85,14 +77,7 @@ EXPOSE ${NOTEBOOK_PORT} ADD . /zipline WORKDIR /zipline -RUN python setup.py install - -# -# clean up the build artifacts and recreate the folder for -# developer mount -# - -RUN rm -rf /zipline && mkdir /zipline +RUN pip install -e . # # start the jupyter server diff --git a/etc/docker_cmd.sh b/etc/docker_cmd.sh index 801b10be..8dd87a45 100755 --- a/etc/docker_cmd.sh +++ b/etc/docker_cmd.sh @@ -1,8 +1,8 @@ #!/bin/bash -# +# # generate configuration, cert, and password if this is the first run -# +# if [ ! -f /var/tmp/zipline_init ] ; then jupyter notebook --generate-config if [ ! -f ${SSL_CERT_PEM} ] ; then @@ -12,7 +12,7 @@ if [ ! -f /var/tmp/zipline_init ] ; then fi echo "c.NotebookApp.password = ${PW_HASH}" >> ${CONFIG_PATH} touch /var/tmp/zipline_init -fi +fi jupyter notebook -y --no-browser --notebook-dir=${PROJECT_DIR} \ --certfile=${SSL_CERT_PEM} --keyfile=${SSL_CERT_KEY} --ip='*' \