Skip to content

Commit 25a26d6

Browse files
committed
enhancing readme; setting token using ENVs and updating some libs
1 parent 60f07c1 commit 25a26d6

6 files changed

+63
-41
lines changed

Dockerfile

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM tensorflow/tensorflow:2.0.0a0-py3-jupyter
1+
FROM tensorflow/tensorflow:2.1.0-py3-jupyter
22
# FROM flaviostutz/datascience-tools:2.0.0
33

44
RUN apt-get update && \
@@ -44,7 +44,7 @@ RUN pip install pydicom && \
4444
pip install scikit-image && \
4545
pip install opencv-python && \
4646
pip install ImageHash && \
47-
apt-get install libav-tools -y && \
47+
apt-get install ffmpeg -y && \
4848
apt-get install imagemagick -y && \
4949
pip install git+https://github.com/danoneata/selectivesearch.git
5050

@@ -70,19 +70,22 @@ RUN pip install Geohash && \
7070
pip install rasterio && \
7171
pip install rasterstats && \
7272
pip install folium && \
73-
pip install pyepsg && \
74-
apt-get install -y software-properties-common && \
73+
pip install pyepsg
74+
RUN apt-get install -y software-properties-common && \
7575
add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable && \
7676
apt update && \
77-
apt-get install libproj-dev libgeos-dev -y && \
78-
apt-get install -y gdal-bin python-gdal python3-gdal && \
77+
apt-get install -y gdal-bin && \
78+
apt-get install -y python-gdal python3-gdal && \
79+
apt-get install -y libproj-dev libgeos-dev && \
7980
pip install mgrspy && \
80-
pip install git+https://github.com/flaviostutz/sentinelloader && \
81-
apt-get install -y libspatialindex-dev && \
81+
pip install git+https://github.com/flaviostutz/sentinelloader
82+
RUN apt-get install -y libspatialindex-dev && \
8283
pip install rtree && \
8384
pip uninstall -y pyepsg && \
8485
pip install git+https://github.com/flaviostutz/pyepsg && \
85-
pip install cartopy
86+
pip uninstall -y enum34 && \
87+
pip install cython && \
88+
pip install git+https://github.com/snowman2/cartopy.git@5e624fe
8689

8790
#SPARK DRIVER
8891
# RUN apt-get install openjdk-8-jdk -y
@@ -107,4 +110,7 @@ RUN apt-get install supervisor -y
107110
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
108111
ADD /start-jupyter.sh /
109112

113+
ENV JUPYTER_TOKEN ''
114+
ENV SPARK_MASTER ''
115+
110116
CMD ["/usr/bin/supervisord"]

Dockerfile-gpu

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM tensorflow/tensorflow:2.0.0a0-gpu-py3-jupyter
1+
FROM tensorflow/tensorflow:2.1.0-gpu-py3-jupyter
22

33
RUN apt-get update && \
44
apt-get install git -y
@@ -68,19 +68,22 @@ RUN pip install Geohash && \
6868
pip install rasterio && \
6969
pip install rasterstats && \
7070
pip install folium && \
71-
pip install pyepsg && \
72-
apt-get install -y software-properties-common && \
71+
pip install pyepsg
72+
RUN apt-get install -y software-properties-common && \
7373
add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable && \
7474
apt update && \
75-
apt-get install libproj-dev libgeos-dev -y && \
76-
apt-get install -y gdal-bin python-gdal python3-gdal && \
75+
apt-get install -y gdal-bin && \
76+
apt-get install -y python-gdal python3-gdal && \
77+
apt-get install -y libproj-dev libgeos-dev && \
7778
pip install mgrspy && \
78-
pip install git+https://github.com/flaviostutz/sentinelloader && \
79-
apt-get install -y libspatialindex-dev && \
79+
pip install git+https://github.com/flaviostutz/sentinelloader
80+
RUN apt-get install -y libspatialindex-dev && \
8081
pip install rtree && \
8182
pip uninstall -y pyepsg && \
8283
pip install git+https://github.com/flaviostutz/pyepsg && \
83-
pip install cartopy
84+
pip uninstall -y enum34 && \
85+
pip install cython && \
86+
pip install git+https://github.com/snowman2/cartopy.git@5e624fe
8487

8588
#SPARK DRIVER
8689
#RUN apt-get install openjdk-8-jdk -y
@@ -104,5 +107,9 @@ RUN mkdir -p /notebooks/data/output
104107
RUN apt-get install supervisor -y
105108
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
106109
ADD /start-jupyter.sh /
110+
ADD /hashpass.py /
111+
112+
ENV JUPYTER_TOKEN ''
113+
ENV SPARK_MASTER ''
107114

108115
CMD ["/usr/bin/supervisord"]

README.md

+24-14
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ This container was created to support various experimentations on Datascience, m
1313
- Scoop, h5py, pandas, scikit, TFLearn, plotly
1414
- pyexcel-ods, pydicom, textblob, wavio, trueskill, cytoolz, ImageHash...
1515

16-
**Run container:**
16+
## Run container:
1717

1818
- CPU only:
1919

2020
* create docker-compose.yml
2121

2222
```
2323
version: "3"
24-
2524
services:
26-
2725
datascience-tools:
2826
image: flaviostutz/datascience-tools
2927
ports:
@@ -32,8 +30,7 @@ This container was created to support various experimentations on Datascience, m
3230
volumes:
3331
- /notebooks:/notebooks
3432
environment:
35-
- PASSWORD=flaviostutz
36-
- SPARK_MASTER=spark-master
33+
- JUPYTER_TOKEN=flaviostutz
3734
```
3835
* `docker-compose up`
3936

@@ -53,8 +50,12 @@ This container was created to support various experimentations on Datascience, m
5350
./boot.sh >> /var/log/boot-script`
5451
- Change "/root/datascience-tools" to where you cloned this repo
5552

53+
**Access:**
5654

57-
**Autorun script:**
55+
- http://[ip]:8888 for Jupyter
56+
- http://[ip]:6006 for TensorBoard
57+
58+
## Autorun script
5859

5960
- When this container starts, it runs:
6061
- Jupyter Notebook server on port 8888
@@ -70,15 +71,24 @@ This container was created to support various experimentations on Datascience, m
7071
- `#!/bin/bash
7172
python test.py`
7273

73-
**Access:**
74+
## Build instructions
75+
76+
- `docker build . -f Dockerfile`
77+
- `docker build . -f Dockerfile-gpu`
78+
79+
## Tips for development of your own Notebooks
80+
81+
- A good practice is to store your notebook scripts in a git repository
82+
- Ex.: http://github.com/flaviostutz/puzzler
83+
84+
- Run datascience-tools container and map the volume "/notebooks", inside the container, to the path you cloned your git repository in your computer
85+
86+
- You can edit/save/run the scripts from the web interface (http://localhost:8888) or directly with other tools on your computer. You can commit and push your code to the destination repository directly (no copy from/to container is needed because the volume is mapped)
7487

75-
- http://[ip]:8888 for Jupyter
76-
- http://[ip]:6006 for TensorBoard
88+
- For running in production, create a new container with "FROM flaviostutz/datascience-tools" and add your script files to "/notebooks" so when you run the container it will have your custom scripts embedded into it. No "volume" mapping is needed for this container.
7789

78-
**Build container:**
90+
## ENVs variables
7991

80-
- `docker-compose build cpu`
81-
OR
82-
- `docker build . -f Dockerfile`
83-
- `docker build . -f Dockerfile-gpu`
92+
- JUPYTER_TOKEN - token needed for the users to open Jupyter. defaults to '', so that no token or password will asked to the user
8493

94+
- SPARK_MASTER - Spark master address. Used if you want to send jobs to an external Spark cluster and still control the whole job from Jupyter Notebook itself.

docker-compose-gpu.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
version: "3"
1+
version: "3.5"
22

33
services:
44

55
datascience-tools-gpu:
66
build:
77
context: .
88
dockerfile: Dockerfile-gpu
9-
image: flaviostutz/datascience-tools:2.8.0-gpu
9+
image: flaviostutz/datascience-tools:2.9.0-gpu
1010
ports:
1111
- 8888:8888
1212
- 6006:6006
13-
volumes:
14-
- /notebooks:/notebooks
13+
# volumes:
14+
# - /notebooks:/notebooks
1515
environment:
16-
- PASSWORD=flaviostutz
16+
- JUPYTER_PASSWORD=flaviostutz

docker-compose.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
version: "3"
1+
version: "3.5"
22

33
services:
44

55
datascience-tools:
66
build:
77
context: .
88
dockerfile: Dockerfile
9-
image: flaviostutz/datascience-tools:2.8.0
9+
image: flaviostutz/datascience-tools:2.9.0
1010
ports:
1111
- 8888:8888
1212
- 6006:6006
1313
# volumes:
1414
# - /notebooks:/notebooks
1515
environment:
16-
- PASSWORD=flaviostutz
17-
- SPARK_MASTER=spark-master
16+
- JUPYTER_TOKEN=flaviostutz

start-jupyter.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ echo "Starting Jupyter..."
66
# export PATH=$SPARK_HOME/bin:$PATH
77
# export PYSPARK_SUBMIT_ARGS="--master $SPARK_MASTER"
88

9-
jupyter notebook "$@" --ip 0.0.0.0 --no-browser --allow-root --NotebookApp.token='' --NotebookApp.password='' --NotebookApp.notebook_dir='/notebooks'
9+
jupyter notebook "$@" --ip 0.0.0.0 --no-browser --allow-root --NotebookApp.allow_password_change=False --NotebookApp.token="$JUPYTER_TOKEN" --NotebookApp.password='' --NotebookApp.notebook_dir='/notebooks'
1010

0 commit comments

Comments
 (0)