-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
322 lines (269 loc) · 11.8 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# ARG BASE_CONTAINER=jupyter/base-notebook
# FROM $BASE_CONTAINER:notebook-6.3.0
# # Set jupyter default memory usage limit to 6GB (in bytes)
# ARG mem_limit=6442450944
# # Set jupyter default cpu usage limit to 6 cores
# ARG cpu_limit=6
# # Set name of the default conda environment
# ARG conda_env=python38
# # Set the python version of the environment
# ARG py_ver=3.8
# WORKDIR $HOME
# USER root
# RUN echo "c.ResourceUseDisplay.track_cpu_percent = True" >> /etc/jupyter/jupyter_notebook_config.py && \
# echo "c.ResourceUseDisplay.cpu_limit = ${cpu_limit}" >> /etc/jupyter/jupyter_notebook_config.py
# COPY --chown=${NB_UID}:${NB_GID} requirements.txt ./
# COPY --chown=${NB_UID}:${NB_GID} environment.yml ./
# #Update python version in the environment file
# RUN sed -i "s/\$py_ver/$py_ver/g" environment.yml && \
# cat environment.yml
# RUN apt-get update -y && \
# # Install Proj4 and geo, which are depencies required by cartopy
# apt-get install -y --no-install-recommends \
# libproj-dev \
# proj-data \
# proj-bin \
# libgeos-dev \
# libgdal-dev \
# software-properties-common=* && \
# add-apt-repository ppa:deadsnakes/ppa && \
# apt-get clean && \
# rm -rf /var/lib/apt/lists/*
# # Switch back to jovyan to avoid accidental container runs as root
# USER $NB_UID
# ENV SITE_PACKAGES=$CONDA_DIR/envs/$conda_env/lib/python3.8/site-packages \
# SNAP_HOME=$CONDA_DIR/envs/$conda_env/snap
# RUN conda env create -p $CONDA_DIR/envs/$conda_env -f environment.yml && \
# # Install snappy package
# cd /opt/conda/envs/$conda_env/bin/ && \
# ./python $SNAP_HOME/.snap/snap-python/snappy/setup.py install && \
# # Rename package to snappy_esa to avoid conflicts with google's snappy package
# mv $SITE_PACKAGES/snappy $SITE_PACKAGES/snappy_esa && \
# mv $SITE_PACKAGES/snappy_esa/snappy.ini $SITE_PACKAGES/snappy_esa/snappy_esa.ini && \
# # Install python packages from the requirements file
# ./pip install --no-cache-dir -r $HOME/requirements.txt && \
# # create Python 3.x environment and link it to jupyter
# ./python -m ipykernel install --user --name=${conda_env} && \
# $SNAP_HOME/bin/snap --nosplash --nogui --modules --install org.esa.snap.idepix.core && \
# $SNAP_HOME/bin/snap --nosplash --nogui --modules --install org.esa.snap.idepix.olci && \
# # Fix permissions
# fix-permissions $CONDA_DIR && \
# fix-permissions /home/$NB_USER && \
# conda clean --all -f -y
# # Enable jupyterlab
# ENV JUPYTER_ENABLE_LAB=TRUE \
# # Set default environment
# CONDA_DEFAULT_ENV=${conda_env} \
# # Set memory usage limit
# MEM_LIMIT=${mem_limit} \
# GPT_BIN=$SNAP_HOME/bin/gpt
# ARG BASE_CONTAINER=jupyter/tensorflow-notebook:bbf0ada0a935
# FROM $BASE_CONTAINER
# # Set jupyter default memory usage limit to 6GB (in bytes)
# ARG mem_limit=6442450944
# # Set jupyter default cpu usage limit to 6 cores
# ARG cpu_limit=6
# # Set name of the default conda environment
# ARG conda_env=python38
# # Set the python version of the environment
# ARG py_ver=3.8
# USER root
# RUN echo "c.ResourceUseDisplay.track_cpu_percent = True" >> /etc/jupyter/jupyter_notebook_config.py && \
# echo "c.ResourceUseDisplay.cpu_limit = ${cpu_limit}" >> /etc/jupyter/jupyter_notebook_config.py
# COPY --chown=${NB_UID}:${NB_GID} requirements.txt ./
# RUN apt-get update -y && \
# # Install Proj4 and geo, which are depencies required by cartopy
# apt-get install -y libproj-dev proj-data proj-bin && \
# apt-get install -y libgeos-dev && \
# apt-get install -y libgdal-dev && \
# apt-get install -y --no-install-recommends \
# software-properties-common=* && \
# add-apt-repository ppa:deadsnakes/ppa
# # Switch back to jovyan to avoid accidental container runs as root
# USER $NB_UID
# ENV SITE_PACKAGES=$CONDA_DIR/envs/$conda_env/lib/python3.8/site-packages \
# SNAP_HOME=$CONDA_DIR/envs/$conda_env/snap
# RUN conda config --append channels terradue && \
# conda config --append channels defaults && \
# conda list -e > conda_requirements.txt && \
# echo $' \n\
# ipython=7.23.0 \n\
# ipykernel=5.5.3 \n\
# java-1.7.0-openjdk-cos6-x86_64=1.7.0.131 \n\
# jpy=0.9.0 \n\
# snap=8.0.0=py38_2 \n\
# jupyter-resource-usage=0.6.0' >> conda_requirements.txt && \
# conda create --yes -p $CONDA_DIR/envs/$conda_env python=$py_ver --file conda_requirements.txt && \
# # Install snappy package
# cd /opt/conda/envs/$conda_env/bin/ && \
# ./python $SNAP_HOME/.snap/snap-python/snappy/setup.py install && \
# # Rename package to snappy_esa to avoid conflicts with google's snappy package
# mv $SITE_PACKAGES/snappy $SITE_PACKAGES/snappy_esa && \
# mv $SITE_PACKAGES/snappy_esa/snappy.ini $SITE_PACKAGES/snappy_esa/snappy_esa.ini && \
# # Install python packages from the requirements file
# ./pip install --no-cache-dir -r $HOME/requirements.txt && \
# # create Python 3.x environment and link it to jupyter
# ./python -m ipykernel install --user --name=${conda_env} && \
# $SNAP_HOME/bin/snap --nosplash --nogui --modules --install org.esa.snap.idepix.core && \
# $SNAP_HOME/bin/snap --nosplash --nogui --modules --install org.esa.snap.idepix.olci && \
# # $SNAP_HOME/bin/snap --nosplash --nogui --modules --list --refresh && \
# fix-permissions $CONDA_DIR && \
# fix-permissions /home/$NB_USER && \
# conda clean --all -f -y
# # Enable jupyterlab
# ENV JUPYTER_ENABLE_LAB=TRUE \
# # Set default environment
# CONDA_DEFAULT_ENV=${conda_env} \
# # Set memory usage limit
# MEM_LIMIT=${mem_limit} \
# GPT_BIN=$SNAP_HOME/bin/gpt
# ARG BASE_CONTAINER=jupyter/scipy-notebook
# FROM $BASE_CONTAINER:cf6258237ff9
# # Set jupyter default memory usage limit to 6GB (in bytes)
# ARG mem_limit=6442450944
# # Set jupyter default cpu usage limit to 6 cores
# ARG cpu_limit=6
# # Set the python version of the environment
# ARG py_ver=3.7
# WORKDIR $HOME
# FROM jupyter/base-notebook:notebook-6.3.0 as utils
# FROM jcrist/alpine-conda:4.6.8
# USER root
# # create user with a home directory
# ARG NB_USER="jovyan"
# ARG NB_UID="1000"
# ARG NB_GID="100"
# ARG py_ver=3.7
# ENV HOME=/home/${NB_USER} \
# CONDA_DIR=/opt/conda \
# NB_USER=$NB_USER \
# NB_UID=$NB_UID \
# NB_GID=$NB_GID
# # RUN adduser --disabled-password \
# # --gecos "Default user" \
# # --uid ${NB_UID} \
# # -s /bin/bash \
# # ${NB_USER}
# WORKDIR ${HOME}
# # RUN echo "c.ResourceUseDisplay.track_cpu_percent = True" >> /etc/jupyter/jupyter_notebook_config.py && \
# # echo "c.ResourceUseDisplay.cpu_limit = ${cpu_limit}" >> /etc/jupyter/jupyter_notebook_config.py
# COPY --from=utils /usr/local/bin/fix-permissions /usr/local/bin/fix-permissions
# # snap requires bash to be installed
# RUN apk add --no-cache bash tini \
# && chmod a+rx /usr/local/bin/fix-permissions \
# && adduser --disabled-password \
# --gecos "Default user" \
# --uid ${NB_UID} \
# -s /bin/bash \
# ${NB_USER} \
# && chown -R $NB_USER:$NB_GID $CONDA_DIR \
# && sed -i "s/chmod +6000/chmod 6000/g" /usr/local/bin/fix-permissions \
# && fix-permissions $HOME \
# && fix-permissions $CONDA_DIR
# COPY --chown=${NB_UID}:${NB_GID} requirements.txt ./
# COPY --chown=${NB_UID}:${NB_GID} environment.yml ./
# SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# USER ${NB_USER}
# #Update python version in the environment file
# RUN sed -i "s/\$py_ver/$py_ver/g" environment.yml \
# && cat environment.yml
# ENV SHELL=/bin/bash \
# PATH=$CONDA_DIR/bin:$PATH
# # RUN apt-get update -y && \
# # # Install Proj4 and geo, which are depencies required by cartopy
# # apt-get install -y --no-install-recommends \
# # libproj-dev \
# # proj-data \
# # proj-bin \
# # libgeos-dev \
# # libgdal-dev \
# # software-properties-common=* && \
# # add-apt-repository ppa:deadsnakes/ppa && \
# # apt-get clean && \
# # rm -rf /var/lib/apt/lists/*
# # Switch back to jovyan to avoid accidental container runs as root
# # USER ${USER}
# # ENV SITE_PACKAGES=$CONDA_DIR/lib/python3.8/site-packages \
# # SNAP_HOME=$CONDA_DIR/snap
# RUN conda env update -f environment.yml
# # Install snappy package
# #cd /opt/conda/bin/ && \
# #./python $SNAP_HOME/.snap/snap-python/snappy/setup.py install && \
# # Rename package to snappy_esa to avoid conflicts with google's snappy package
# #mv $SITE_PACKAGES/snappy $SITE_PACKAGES/snappy_esa && \
# #mv $SITE_PACKAGES/snappy_esa/snappy.ini $SITE_PACKAGES/snappy_esa/snappy_esa.ini && \
# # # Install python packages from the requirements file
# # ./pip install --no-cache-dir -r $HOME/requirements.txt && \
# # # create Python 3.x environment and link it to jupyter
# # ./python -m ipykernel install --user --name=${conda_env} && \
# # $SNAP_HOME/bin/snap --nosplash --nogui --modules --install org.esa.snap.idepix.core && \
# # $SNAP_HOME/bin/snap --nosplash --nogui --modules --install org.esa.snap.idepix.olci && \
# # # Fix permissions
# # && fix-permissions $CONDA_DIR \
# # && fix-permissions /home/$NB_USER \
# # && /opt/conda/bin/conda clean --all -f -y
# # Enable jupyterlab
# ENV JUPYTER_ENABLE_LAB=TRUE \
# # Set default environment
# CONDA_DEFAULT_ENV=${conda_env} \
# # Set memory usage limit
# MEM_LIMIT=${mem_limit} \
# GPT_BIN=$SNAP_HOME/bin/gpt
# EXPOSE 8888
# # Configure container startup
# ENTRYPOINT ["tini", "-g", "--"]
# CMD ["start-notebook.sh"]
# # Copy local files as late as possible to avoid cache busting
# COPY --from=utils /usr/local/bin/start.sh /usr/local/bin/start-notebook.sh /usr/local/bin/start-singleuser.sh /usr/local/bin/
FROM jupyter/base-notebook:notebook-6.3.0
ARG py_ver=3.7
WORKDIR ${HOME}
USER root
# RUN echo "c.ResourceUseDisplay.track_cpu_percent = True" >> /etc/jupyter/jupyter_notebook_config.py && \
# echo "c.ResourceUseDisplay.cpu_limit = ${cpu_limit}" >> /etc/jupyter/jupyter_notebook_config.py
COPY --chown=${NB_UID}:${NB_GID} requirements.txt ./
COPY --chown=${NB_UID}:${NB_GID} environment.yml ./
USER ${NB_USER}
#Update python version in the environment file
RUN sed -i "s/\$py_ver/$py_ver/g" environment.yml \
&& cat environment.yml
# RUN apt-get update -y && \
# # Install Proj4 and geo, which are depencies required by cartopy
# apt-get install -y --no-install-recommends \
# libproj-dev \
# proj-data \
# proj-bin \
# libgeos-dev \
# libgdal-dev \
# software-properties-common=* && \
# add-apt-repository ppa:deadsnakes/ppa && \
# apt-get clean && \
# rm -rf /var/lib/apt/lists/*
# Switch back to jovyan to avoid accidental container runs as root
# USER ${USER}
# ENV SITE_PACKAGES=$CONDA_DIR/lib/python3.8/site-packages \
# SNAP_HOME=$CONDA_DIR/snap
RUN conda env update -f environment.yml
# Install snappy package
#cd /opt/conda/bin/ && \
#./python $SNAP_HOME/.snap/snap-python/snappy/setup.py install && \
# Rename package to snappy_esa to avoid conflicts with google's snappy package
#mv $SITE_PACKAGES/snappy $SITE_PACKAGES/snappy_esa && \
#mv $SITE_PACKAGES/snappy_esa/snappy.ini $SITE_PACKAGES/snappy_esa/snappy_esa.ini && \
# # Install python packages from the requirements file
# ./pip install --no-cache-dir -r $HOME/requirements.txt && \
# # create Python 3.x environment and link it to jupyter
# ./python -m ipykernel install --user --name=${conda_env} && \
# $SNAP_HOME/bin/snap --nosplash --nogui --modules --install org.esa.snap.idepix.core && \
# $SNAP_HOME/bin/snap --nosplash --nogui --modules --install org.esa.snap.idepix.olci && \
# # Fix permissions
# && fix-permissions $CONDA_DIR \
# && fix-permissions /home/$NB_USER \
# && /opt/conda/bin/conda clean --all -f -y
# Enable jupyterlab
ENV JUPYTER_ENABLE_LAB=TRUE \
# Set default environment
CONDA_DEFAULT_ENV=${conda_env} \
# Set memory usage limit
MEM_LIMIT=${mem_limit} \
GPT_BIN=$SNAP_HOME/bin/gpt