-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile-cuda112
96 lines (76 loc) · 3.28 KB
/
Dockerfile-cuda112
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
ARG CUDA="11.2.2"
ARG CUDNN="8"
FROM nvidia/cuda:${CUDA}-cudnn${CUDNN}-devel-ubuntu20.04
# use tinghua resource to speed up
COPY sources.list /etc/apt/
RUN rm /etc/apt/sources.list.d/cuda.list
# copy installer files
COPY oh-my-zsh_install.sh /tmp/
COPY pyenv_install.sh /tmp/
# skip select geographic area
ENV DEBIAN_FRONTEND=noninteractive
# install packages
RUN apt-get update \
&& apt-get install -y sudo git zsh curl tmux wget build-essential libbz2-dev \
libssl-dev libreadline-dev libsqlite3-dev tk-dev \
libpng-dev libfreetype6-dev libffi-dev liblzma-dev \
openssh-server locales busybox software-properties-common
# create user
ARG USERNAME=ubuntu
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN echo $USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# set language
RUN export LANGUAGE=en_US.UTF-8 && \
export LANG=en_US.UTF-8 && \
export LC_ALL=en_US.UTF-8 && \
sudo locale-gen en_US.UTF-8
# set time
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
# set user
USER ubuntu
WORKDIR /home/ubuntu
RUN sudo chown -R ubuntu:ubuntu /tmp
# download config files from git
RUN cd /tmp && git clone https://github.com/wyg1997/Linux-configs.git
# tmux and tmux-resurrect
RUN cp /tmp/Linux-configs/.tmux.conf ~
RUN cp /tmp/Linux-configs/.tmux.conf.local ~
RUN mkdir -p ~/.config && git clone https://github.com/tmux-plugins/tmux-resurrect ~/.config/tmux-resurrect
# install and set oh-my-zsh
RUN cd ~ && /tmp/oh-my-zsh_install.sh \
&& git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k \
&& cp /tmp/Linux-configs/.p10k.zsh ~
# zsh-autosuggestions
RUN git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# zsh-syntax-highlighting
RUN git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# set shell to zsh
RUN cp /tmp/Linux-configs/.zshrc ~
RUN sudo usermod -s /bin/zsh ubuntu
# install pyenv and python3.8.5
RUN /tmp/pyenv_install.sh \
&& echo "\nexport PYENV_ROOT=\$HOME/.pyenv\nPATH=\"\$PYENV_ROOT/shims:\$PYENV_ROOT/bin:\$PATH\"\neval \"\$(pyenv init -)\"\neval \"\$(pyenv virtualenv-init -)\"" >> ~/.zshrc \
&& v=3.8.5;wget https://npmmirror.com/mirrors/python/$v/Python-$v.tar.xz -P ~/.pyenv/cache/ \
&& CONFIGURE_OPTS=--enable-shared ~/.pyenv/bin/pyenv install $v && ~/.pyenv/bin/pyenv global $v
# pip resources
RUN mkdir ~/.pip && cp /tmp/Linux-configs/pip.conf ~/.pip
# TODO: install neovimplus
# sshd
RUN sudo mkdir -p /var/run/sshd
# SSH login fix. Otherwise user is kicked off after login
RUN sudo sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" | sudo tee -a /etc/profile
CMD ["/usr/sbin/sshd", "-D"]
# remove temp files
RUN sudo rm -rf /tmp/* \
&& sudo apt-get clean \
&& sudo rm -rf /var/lib/apt/lists/*
# open port
EXPOSE 22 8888 8887 8886