-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
756d6c1
commit 3154d8a
Showing
8 changed files
with
244 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu16.04 | ||
|
||
#################################### | ||
# Apt libraries | ||
#################################### | ||
RUN apt-get update && apt-get install -y --no-install-recommends\ | ||
build-essential \ | ||
apt-utils \ | ||
cmake \ | ||
git \ | ||
less \ | ||
zsh \ | ||
curl \ | ||
vim \ | ||
graphviz \ | ||
libjpeg-dev \ | ||
libpng-dev \ | ||
gfortran \ | ||
zlib1g-dev \ | ||
automake \ | ||
autoconf \ | ||
git \ | ||
libtool \ | ||
subversion \ | ||
libatlas3-base \ | ||
ffmpeg \ | ||
python-pip \ | ||
python-dev \ | ||
wget \ | ||
libncurses5-dev \ | ||
libncursesw5-dev \ | ||
unzip \ | ||
sox \ | ||
locales &&\ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /home | ||
ENV HOME /home | ||
|
||
################################### | ||
# Anaconda + python deps | ||
################################### | ||
# https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh | ||
WORKDIR /home | ||
RUN curl -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ | ||
chmod +x ~/miniconda.sh && \ | ||
~/miniconda.sh -b -p /home/miniconda3 && \ | ||
rm ~/miniconda.sh | ||
|
||
# RUN /home/miniconda3/bin/conda install -c anaconda tensorflow-gpu | ||
RUN /home/miniconda3/bin/conda install -y pytorch==0.4.1 torchvision -c pytorch | ||
RUN /home/miniconda3/bin/pip install \ | ||
h5py \ | ||
matplotlib \ | ||
colorama \ | ||
tqdm \ | ||
scipy \ | ||
natsort \ | ||
pandas \ | ||
astropy \ | ||
ipdb \ | ||
scikit-learn \ | ||
pytest \ | ||
unidecode &&\ | ||
/home/miniconda3/bin/pip install sphinx sphinx-autobuild sphinxcontrib-napoleon sphinx_rtd_theme tabulate | ||
|
||
# Extra python packages | ||
RUN /home/miniconda3/bin/pip install seaborn pytest-sugar pytest-cov | ||
|
||
|
||
ENV PATH=$PATH:/u/home/.local/bin | ||
|
||
#################################### | ||
# Set up locale to avoid zsh errors | ||
#################################### | ||
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ | ||
&& locale-gen --purge --lang en_US \ | ||
&& locale-gen | ||
|
||
################################################ | ||
# Set up the environment variables | ||
# Used in installing following libs as well | ||
################################################ | ||
|
||
ENV TMP_PATH=/u/home/dump \ | ||
LD_LIBRARY_PATH="/usr/local/lib:/home/miniconda3/lib:$LD_LIBRARY_PATH" \ | ||
PATH=/home/miniconda3/bin:$PATH \ | ||
LANG=en_US.utf8 \ | ||
USER=researcher \ | ||
USER_ID=2018 \ | ||
USER_GID=2018 | ||
|
||
####################################### | ||
# Adding a user which will be mapped to | ||
# real user running the docker | ||
####################################### | ||
|
||
RUN mkdir -p /u/home && \ | ||
groupadd --gid "${USER_GID}" "$USER" && \ | ||
useradd \ | ||
--uid ${USER_ID} \ | ||
--gid ${USER_GID} \ | ||
--home-dir /u/home \ | ||
--shell /usr/bin/zsh \ | ||
${USER} | ||
|
||
#################################### | ||
# Set up oh my zsh | ||
#################################### | ||
WORKDIR /u/home | ||
COPY zshrc /u/home/.zshrc | ||
RUN git clone https://github.com/robbyrussell/oh-my-zsh.git /u/home/.oh-my-zsh &&\ | ||
sed -i 's/❯/Docker❯/g' /u/home/.oh-my-zsh/themes/refined.zsh-theme | ||
# Path to your oh-my-zsh installation. | ||
ENV ZSH=/u/home/.oh-my-zsh \ | ||
PATH_TO_COPY=${PATH} | ||
|
||
COPY entry_script.sh / | ||
RUN chmod u+x /entry_script.sh | ||
ENV HOME=/u/home | ||
|
||
ENTRYPOINT ["/bin/bash", "/entry_script.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
|
||
if [ -z "${USER}" ]; then | ||
echo "We need USER to be set!"; exit 100 | ||
fi | ||
|
||
# if both not set we do not need to do anything | ||
if [ -z "${HOST_USER_ID}" -a -z "${HOST_USER_GID}" ]; then | ||
echo "Nothing to do here." ; exit 0 | ||
fi | ||
|
||
# reset user_?id to either new id or if empty old (still one of above | ||
# might not be set) | ||
USER_ID=${HOST_USER_ID:=$USER_ID} | ||
USER_GID=${HOST_USER_GID:=$USER_GID} | ||
|
||
LINE=$(grep -F "${USER}" /etc/passwd) | ||
# replace all ':' with a space and create array | ||
array=( ${LINE//:/ } ) | ||
|
||
# home is 5th element | ||
USER_HOME=/u/home | ||
|
||
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*:[0-9]*/${USER}:\1:${USER_ID}:${USER_GID}/" /etc/passwd | ||
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group | ||
|
||
chown $HOST_USER_ID:$HOST_USER_GID $USER_HOME | ||
chown $HOST_USER_ID:$HOST_USER_GID /u/home/.zshrc | ||
chown $HOST_USER_ID:$HOST_USER_GID /u/home/.oh-my-zsh | ||
|
||
_term() { | ||
echo "Caught SIGTERM signal!" | ||
kill -TERM "$child" 2>/dev/null | ||
} | ||
|
||
trap _term SIGTERM | ||
# PATH is reset on user switch but we need to preserve | ||
|
||
|
||
su -p "${USER}" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters