-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile_app
More file actions
211 lines (168 loc) · 7.48 KB
/
Copy pathDockerfile_app
File metadata and controls
211 lines (168 loc) · 7.48 KB
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
ARG VERSION=2022.2.1
FROM adlsregistrysbx.azurecr.io/pokeball/base:${VERSION} as production
ARG VERSION
RUN echo $VERSION > image_version
ENV VERSION_SECOND=2021.7.1 \
HDF5_VERSION=hdf5-1_12_2 \
CDF_DIR=cdf38_1-dist
ENV PATH="/opt/hdf5_ifort/bin:/opt/intel/oneapi/mpi/${VERSION_SECOND}/libfabric/bin:/opt/intel/oneapi/mpi/${VERSION_SECOND}/bin:/opt/intel/oneapi/mkl/${VERSION}/bin/intel64:/opt/intel/oneapi/intelpython/latest/bin:/opt/intel/oneapi/intelpython/latest/condabin:/opt/intel/oneapi/dev-utilities/${VERSION_SECOND}/bin:/opt/intel/oneapi/debugger/${VERSION_SECOND}/gdb/intel64/bin:/opt/intel/oneapi/compiler/${VERSION}/linux/bin/intel64:/opt/intel/oneapi/compiler/${VERSION}/linux/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ENV HDF5_DIR="/opt/hdf5_ifort/" \
HDF5_LIBRARIES="/opt/hdf5_ifort/lib" \
HDF5_INCLUDE_DIRS="/opt/hdf5_ifort/include" \
LD_LIBRARY_PATH="/opt/hdf5_ifort:${LD_LIBRARY_PATH}"
ENV CONDA_DEFAULT_ENV='intelpython-python3.9' \
CONDA_EXE='/opt/intel/oneapi/intelpython/latest/bin/conda' \
CONDA_PREFIX='/opt/intel/oneapi/intelpython/latest' \
CONDA_PROMPT_MODIFIER='(intelpython-3.9) ' \
CONDA_PYTHON_EXE='/opt/intel/oneapi/intelpython/latest/bin/python' \
CONDA_SHLVL='1'
WORKDIR /app
ENV APPHOME=/app
ENV F9X=/opt/hdf5_ifort/bin/h5fc \
FC=/opt/hdf5_ifort/bin/h5fc \
CC=/opt/hdf5_ifort/bin/h5cc \
CXX=/opt/hdf5_ifort/bin/h5c++
COPY python3.9requirements.txt .
RUN apt -y update && apt install -y gfortran libncurses5-dev libncursesw5-dev imagemagick &&\
pip install -r python3.9requirements.txt
ENV PYTHONPATH="${APPHOME}"
COPY cdf .
RUN tar xvzf cdf.tar.gz && rm cdf.tar.gz && cd ${CDF_DIR} &&\
make OS=linux ENV=gnu FORTRAN=yes all &&\
make install &&\
cd ${APPHOME}
ENV CDF_LEAPSECONDSTABLE="/cdf/${CDF_DIR}/CDFLeapSeconds.txt" \
CDF_HELP="/app/${CDF_DIR}/lib/cdf/help" \
CDF_INC="/app/${CDF_DIR}/include" \
CDF_LIB="/app/${CDF_DIR}/lib" \
CDF_BASE="/app/${CDF_DIR}" \
CDF_BIN="/app/${CDF_DIR}/bin" \
CDF_JAVA="/app/${CDF_DIR}/cdfjava"
# Copy in all dirs that contain your source code
COPY source_app /app/source_app
ENV PATH="${APPHOME}/scripts/preproc:${PATH}" \
PATH="${APPHOME}/scripts/datamodel:${PATH}" \
PATH="${APPHOME}/scripts/postproc:${PATH}" \
PATH="${APPHOME}/scripts/OHelio:${PATH}" \
PATH="${APPHOME}/scripts/quicklook:${PATH}" \
PATH="${APPHOME}/scripts/legacy:${PATH}"
# Now comes the Jupyter part
WORKDIR /
ARG OWNER=jupyter
ARG NB_USER="jovyan"
ARG NB_UID="1000"
ARG NB_GID="100"
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
USER root
# Install all OS dependencies for notebook server that starts but lacks all
# features (e.g., download as all possible file formats)
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update --yes && \
apt-get install --yes --no-install-recommends \
# - bzip2 is necessary to extract the micromamba executable.
bzip2 \
ca-certificates \
fonts-liberation \
locales vim emacs \
# - pandoc is used to convert notebooks to html files
# it's not present in arm64 ubuntu image, so we install it here
# pandoc \
# - run-one - a wrapper script that runs no more
# than one unique instance of some command with a unique set of arguments,
# we use `run-one-constantly` to support `RESTARTABLE` option
run-one \
# sudo \
# - tini is installed as a helpful container entrypoint that reaps zombie
# processes and such of the actual executable we want to start, see
# https://github.com/krallin/tini#why-tini for details.
tini \
wget \
# the next three are dependencies for the vtk package that is otherwise not installed correct
ffmpeg \
libsm6 \
libxext6 \
&& \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen
# Configure environment
ENV CONDA_DIR=/opt/intel/oneapi/intelpython/latest/ \
SHELL=/bin/bash \
NB_USER="${NB_USER}" \
NB_UID=${NB_UID} \
NB_GID=${NB_GID} \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8
ENV PATH="${CONDA_DIR}/bin:${PATH}" \
HOME="/home/${NB_USER}"
# Copy a script that we will use to correct permissions after running certain commands
COPY fix-permissions /usr/local/bin/fix-permissions
RUN chmod a+rx /usr/local/bin/fix-permissions
# Enable prompt color in the skeleton .bashrc before creating the default NB_USER
# hadolint ignore=SC2016
RUN sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc && \
# Add call to conda init script see https://stackoverflow.com/a/58081608/4413446
echo 'eval "$(command conda shell.bash hook 2> /dev/null)"' >> /etc/skel/.bashrc
# Create NB_USER with name jovyan user with UID=1000 and in the 'users' group
# and make sure these dirs are writable by the `users` group.
RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su && \
useradd -l -m -s /bin/bash -N -u "${NB_UID}" "${NB_USER}" && \
mkdir -p "${CONDA_DIR}" && \
chown "${NB_USER}:${NB_GID}" "${CONDA_DIR}" && \
chmod g+w /etc/passwd && \
fix-permissions "${HOME}"
USER root
# Pin python version here, or set it to "default"
#ARG PYTHON_VERSION=3.9
# Setup work directory for backward-compatibility
RUN mkdir "/home/${NB_USER}/work" && \
fix-permissions "/home/${NB_USER}"
RUN conda install python="${PYTHON_VERSION}" \
notebook \
jupyterlab \
jupyterhub \
vtk \
ipywidgets \
plotly \
scikit-image \
&& \
jupyter notebook --generate-config && \
conda clean -a -y && \
jupyter lab clean && \
pip install chart_studio && \
rm -rf "/home/${NB_USER}/.cache/yarn" && \
fix-permissions "/home/${NB_USER}"
ENV PYTHONPATH="${PYTHONPATH}:.local/lib/python3.9/site-packages/"
EXPOSE 8888
# Configure container startup
ENTRYPOINT ["tini", "-g", "--"]
CMD ["start-notebook.sh"]
# Copy local files as late as possible to avoid cache busting
COPY start.sh start-notebook.sh start-singleuser.sh /usr/local/bin/
#RUN chmod +x /usr/local/bin/start*.sh
# Currently need to have both jupyter_notebook_config and jupyter_server_config to support classic and lab
COPY jupyter_server_config.py /etc/jupyter/
# Fix permissions on /etc/jupyter as root
USER root
RUN pip install jupyterlab_h5web[full]
# Legacy for Jupyter Notebook Server, see: [#1205](https://github.com/jupyter/docker-stacks/issues/1205)
RUN sed -re "s/c.ServerApp/c.NotebookApp/g" \
/etc/jupyter/jupyter_server_config.py > /etc/jupyter/jupyter_notebook_config.py && \
fix-permissions /etc/jupyter/ &&\
fix-permissions /usr/local/bin
# HEALTHCHECK documentation: https://docs.docker.com/engine/reference/builder/#healthcheck
# This healtcheck works well for `lab`, `notebook`, `nbclassic`, `server` and `retro` jupyter commands
# https://github.com/jupyter/docker-stacks/issues/915#issuecomment-1068528799
HEALTHCHECK --interval=15s --timeout=3s --start-period=5s --retries=3 \
CMD wget -O- --no-verbose --tries=1 --no-check-certificate \
http${GEN_CERT:+s}://localhost:8888${JUPYTERHUB_SERVICE_PREFIX:-/}api || exit 1
# Run the fix-permissions for home as there are still some problems
RUN fix-permissions /home/$NB_USER
ENV NOTEBOOK_ARGS="--FileCheckpoints.checkpoint_dir=/home/$NB_USER"
# Switch back to jovyan to avoid accidental container runs as root
USER ${NB_UID}
RUN echo "ulimit -s unlimited" >> /home/jovyan/.bashrc
WORKDIR "${HOME}"