Skip to content

Commit 239b807

Browse files
authored
Merge pull request #288 from jdye64/287
Initial streamz docker image to lower barrier for users accessing str…
2 parents 4e71119 + 2bf3fae commit 239b807

6 files changed

Lines changed: 104 additions & 0 deletions

File tree

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Common IDE configuration directories and files that should be ignored
2+
*.vscode
3+
*.idea
4+
5+
# Previous build output that should not be included
6+
build
7+
directories
8+
9+
# Ignore the Dockerfile itself
10+
Dockerfile
11+
12+
# Ignore CI related files are we don't need those in the container
13+
.codecov.yml
14+
.coveragerc
15+
.gitignore
16+
.travis.yml

Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM python:3.7.5-slim
2+
USER root
3+
SHELL ["/bin/bash", "--login", "-c"]
4+
5+
ENV DEBIAN_FRONTEND noninteractive
6+
ENV SCALA_VERSION 2.11
7+
ENV KAFKA_VERSION 2.3.0
8+
ENV KAFKA_HOME /opt/kafka_"$SCALA_VERSION"-"$KAFKA_VERSION"
9+
10+
# Install conda
11+
ADD https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh /miniconda.sh
12+
RUN sh /miniconda.sh -b -p /conda && /conda/bin/conda update -n base conda
13+
RUN echo "PATH=${PATH}:/conda/bin" >> ~/.bashrc
14+
15+
# Add Streamz source code to the build context
16+
ADD . /streamz/.
17+
18+
# Create the conda environment
19+
RUN conda env create --name streamz-dev -f /streamz/conda/environments/streamz_dev.yml
20+
RUN conda init bash
21+
22+
# Ensures subsequent RUN commands do not need the "conda activate streamz_dev" command
23+
RUN echo "conda activate streamz_dev" >> ~/.bashrc
24+
25+
# Build streamz from source
26+
RUN cd /streamz && \
27+
python setup.py install
28+
29+
# Install optional dependencies in the conda environment
30+
RUN conda install -c conda-forge jupyterlab \
31+
numpy \
32+
pandas \
33+
wget \
34+
vim
35+
36+
# Install Kafka
37+
RUN wget -q http://www.gtlib.gatech.edu/pub/apache/kafka/2.3.0/kafka_2.11-2.3.0.tgz -O /tmp/kafka_"$SCALA_VERSION"-"$KAFKA_VERSION".tgz && \
38+
tar xfz /tmp/kafka_"$SCALA_VERSION"-"$KAFKA_VERSION".tgz -C /opt && \
39+
rm /tmp/kafka_"$SCALA_VERSION"-"$KAFKA_VERSION".tgz
40+
41+
# Zookeeper & Kafa ports
42+
EXPOSE 2181
43+
EXPOSE 9092
44+
45+
CMD ["/streamz/docker/scripts/entry.sh"]

docker/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker build -t streamz:0.5.2 .

docker/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker run -p 8888:8888 streamz:0.5.2

docker/scripts/entry.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# Activate the streamz-dev anaconda environment by default
4+
source activate streamz-dev
5+
6+
# Start Zookeeper
7+
$KAFKA_HOME/bin/zookeeper-server-start.sh -daemon $KAFKA_HOME/config/zookeeper.properties
8+
9+
# Configure Kafka
10+
sed -i '/#listeners=PLAINTEXT:\/\/:9092/c\listeners=PLAINTEXT:\/\/localhost:9092' $KAFKA_HOME/config/server.properties
11+
sed -i '/#advertised.listeners=PLAINTEXT:\/\/your.host.name:9092/c\advertised.listeners=PLAINTEXT:\/\/localhost:9092' $KAFKA_HOME/config/server.properties
12+
13+
# Start Kafka
14+
$KAFKA_HOME/bin/kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties
15+
16+
# Start up a jupyter notebook
17+
cd /streamz/examples && jupyter-lab --allow-root --ip=0.0.0.0 --no-browser --NotebookApp.token=''

docs/source/index.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,26 @@ To install either use:
7474
- pip: ``pip install streamz``
7575
- dev: ``git clone https://github.com/python-streamz/streamz`` followed by ``pip install -e streamz/``
7676

77+
Quickstart
78+
----------
79+
80+
The streamz project offers a Docker image for the convenience of quickly trying out streamz and its features.
81+
The purpose of the Dockerfile at this time is not to be used in a production
82+
environment but rather for experimentation, learning, or new feature development.
83+
84+
Its most common use would be to interact with the streamz example jupyter notebooks. Lets walk through the steps needed for this.
85+
86+
- Build the Docker container
87+
.. code-block:: bash
88+
$ docker/build.sh
89+
- Run the Docker container
90+
.. code-block:: bash
91+
$ docker/run.sh
92+
- Interact with Jupyter Lab on the container in your browser at `JUPYTER_LAB`_.
93+
.. JUPYTER_LAB: http://localhost:8888/
94+
95+
96+
7797
Related Work
7898
------------
7999

0 commit comments

Comments
 (0)