-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile-proxy-SSL
155 lines (129 loc) · 5.64 KB
/
Dockerfile-proxy-SSL
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
FROM nvcr.io/nvidia/pytorch:22.12-py3
#FROM pytorch/pytorch:1.13.1-cuda11.6-cudnn8-runtime
MAINTAINER OpenKBS <[email protected]>
ENV DEBIAN_FRONTEND noninteractive
##############################################
#### ---- Installation Directories ---- ####
##############################################
ENV INSTALL_DIR=${INSTALL_DIR:-/usr}
ENV SCRIPT_DIR=${SCRIPT_DIR:-$INSTALL_DIR/scripts}
############################################
##### ---- System: certificates : ---- #####
##### ---- Corporate Proxy : ---- #####
############################################
COPY ./scripts ${SCRIPT_DIR}
COPY certificates /certificates
RUN cat /root/.config/pip/pip.conf
RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates
RUN ${SCRIPT_DIR}/setup_system_certificates.sh
RUN ${SCRIPT_DIR}/setup_system_proxy.sh
#RUN ${SCRIPT_DIR}/CERT-trust-apt-install.sh
#RUN ${SCRIPT_DIR}/CERT-trust-git-install.sh
RUN ${SCRIPT_DIR}/CERT-trust-pip-install.sh
ENV PIP_TRUST=" --trusted-host pypi.org --trusted-host files.pythonhosted.org --trusted-host pypi.ngc.nvidia.com --trusted-host developer.download.nvidia.com "
RUN python3 -m pip install ${PIP_TRUST} --upgrade pip
###################################
#### ---- Install dependencies ----
###################################
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
build-essential \
curl \
graphviz \
pkg-config \
python3 \
python3-dev \
python3-pip \
python3-setuptools \
software-properties-common \
pkg-config \
unzip \
sudo \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
###################################
#### ---- user: developer ---- ####
###################################
ENV USER_ID=${USER_ID:-1000}
ENV GROUP_ID=${GROUP_ID:-1000}
ENV USER=${USER:-developer}
ENV HOME=/home/${USER}
## -- setup NodeJS user profile
RUN groupadd ${USER} && useradd ${USER} -m -d ${HOME} -s /bin/bash -g ${USER} && \
## -- Ubuntu -- \
usermod -aG sudo ${USER} && \
## -- Centos -- \
#usermod -aG wheel ${USER} && \
echo "${USER} ALL=NOPASSWD:ALL" | tee -a /etc/sudoers && \
echo "USER =======> ${USER}" && ls -al ${HOME}
###################################
#### ---- PIP modules: ---- ####
###################################
#### ---- pip3 Package installation ---- ####
USER ${USER}
WORKDIR ${HOME}
COPY --chown=${USER}:${USER} requirements.txt ./
ENV PATH="$HOME/.local/bin:$PATH"
ENV SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True
RUN python3 -m pip --no-cache-dir install ${PIP_TRUST} --upgrade pip && \
python3 -m pip --no-cache-dir install ${PIP_TRUST} --upgrade setuptools tensorflow && \
SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True python3 -m pip --no-cache-dir install ${PIP_TRUST} -r requirements.txt
##################################
#### ---- Jupyter ---- ####
##################################
#RUN sudo python3 -m ipykernel.kernelspec
#RUN sudo apt install -y dirmngr gnupg apt-transport-https ca-certificates software-properties-common && \
#RUN sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/' && \
# ----------------------------------------------------------------------------
# Timezone: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# ref: https://dev.to/grigorkh/fix-tzdata-hangs-during-docker-image-build-4o9m
# ----------------------------------------------------------------------------
ENV TZ=${TZ:-Etc/UTC}
#ENV TZ=Etc/UTC
RUN sudo apt update && \
sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ | sudo tee -a /etc/timezone && \
sudo apt install -y --no-install-recommends python3-ipykernel
##################################
#### ---- Set up Jupyter ---- ####
##################################
# Set up our notebook config.
ENV JUPYTER_CONF_DIR=$HOME/.jupyter
COPY --chown=${USER}:${USER} ./scripts/jupyter_notebook_config.py ${JUPYTER_CONF_DIR}/
COPY --chown=${USER}:${USER} ./scripts/jupyter_server_config.py ${JUPYTER_CONF_DIR}/
COPY --chown=${USER}:${USER} ./sample-notebooks $HOME/sample-notebooks
# Jupyter has issues with being run directly:
# https://github.com/ipython/ipython/issues/7062
# We just add a little wrapper script.
ADD --chown=${USER}:${USER} ./scripts $HOME/scripts
COPY --chown=${USER}:${USER} ./docker-entrypoint.sh /docker-entrypoint.sh
COPY --chown=${USER}:${USER} ./scripts/run-jupyter.sh /run-jupyter.sh
COPY --chown=${USER}:${USER} ./scripts/run-jupyter-server.sh /run-jupyter-server.sh
RUN sudo chmod +x $HOME/scripts/*.sh /run-jupyter*.sh
# Expose Ports for TensorBoard (6006), Ipython (8888)
EXPOSE 6006
EXPOSE 8888
VOLUME $HOME/notebooks
########################################
#### ---- Set up NVIDIA-Docker ---- ####
########################################
## ref: https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(Native-GPU-Support)#usage
ENV TOKENIZERS_PARALLELISM=false
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,video,utility
############################################
#### ---- CA-Certifcates variable: ---- ####
############################################
ENV REQUESTS_CA_BUNDLE=${REQUESTS_CA_BUNDLE:-/etc/ssl/certs/ca-certificates.crt}
#########################################
##### ---- Docker Entrypoint : ---- #####
#########################################
ENTRYPOINT ["/docker-entrypoint.sh"]
##################################
#### ---- start user env ---- ####
##################################
USER ${USER}
WORKDIR "$HOME"
#CMD ["/run-jupyter.sh", "notebooks", "--allow-root", "--port=8888", "--ip=0.0.0.0", "--no-browser"]
CMD ["/run-jupyter.sh", "--allow-root"]
#CMD ["/run-jupyter-server.sh", "--allow-root"]