Skip to content

Instantly share code, notes, and snippets.

@chiehpower
Last active July 29, 2022 06:48
Show Gist options
  • Save chiehpower/1ca5e9d46e0545dc8f6944f86a557d47 to your computer and use it in GitHub Desktop.
Save chiehpower/1ca5e9d46e0545dc8f6944f86a557d47 to your computer and use it in GitHub Desktop.
Set up ZSH and packages
#!/bin/bash
apt-get update && apt-get install -y zsh autojump fonts-powerline
sudo chsh -s /bin/zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true
## Resolved: Could not resolve host: github.com
git config --global --unset http.proxy
git config --global --unset https.proxy
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/themes/powerlevel10k
# Install zsh-nvm
# git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm
sed -i -e 's/# DISABLE_UNTRACKED_FILES_DIRTY="true"/DISABLE_UNTRACKED_FILES_DIRTY="true"/1' ~/.zshrc
sed -i 's/plugins=(git)/plugins=(git autojump zsh-autosuggestions)/1' ~/.zshrc
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="powerlevel10k\/powerlevel10k" # ZSH_THEME="robbyrussell"/g' ~/.zshrc
sed -i '$a\POWERLEVEL9K_MODE="awesome-patched"' ~/.zshrc
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
echo "source ~/.oh-my-zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
# You can use this to set the style
# p10k configure # n n n n 1 2 3 1 2 1 n 1 y
@chiehpower
Copy link
Author

The usage in your side is below:

Step

git clone https://gist.github.com/1ca5e9d46e0545dc8f6944f86a557d47.git install_zsh
cd install_zsh
chmod +x setup_zsh_script.sh 
./setup_zsh_script.sh

You can type p10k configure to set the p10k style.

@chiehpower
Copy link
Author

# ## 2103 Version
FROM nvcr.io/nvidia/tensorrt:21.03-py3

RUN sed -i -e 's/archive.ubuntu.com/free.nchc.org.tw/' /etc/apt/sources.list

# CUDA 21.04 > 11.3

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
    ca-certificates wget sudo protobuf-compiler \
    libprotobuf-dev python3-pip curl vim zip fonts-powerline \
    libsm6 libxext6 libxrender-dev python3-tk openssh-server zsh git-core nano && \ 
    rm -rf /var/lib/apt/lists/*

# RUN mkdir /var/run/sshd
RUN echo 'root:SolomonRoot' | chpasswd
RUN sed -i 's/#PermitRootLogin/PermitRootLogin/' /etc/ssh/sshd_config
RUN sed -i 's/#PasswordAuthentication/PasswordAuthentication/' /etc/ssh/sshd_config
  
EXPOSE 22

## Got from here: https://gist.github.com/MichalZalecki/4a87880bbe7a3a5428b5aebebaa5cd97#gistcomment-2833222
# create a non-root user
ARG USER_NAME="solomon"
ARG USER_PASSWORD="solomon"

ENV USER_NAME $USER_NAME
ENV USER_PASSWORD $USER_PASSWORD

RUN echo $USER_NAME
RUN echo $USER_PASSWORD

RUN adduser --quiet --disabled-password --shell /bin/zsh --home /home/$USER_NAME --gecos "User" $USER_NAME \
# update the password
  && echo "${USER_NAME}:${USER_PASSWORD}" | chpasswd && usermod -aG sudo $USER_NAME   
  
## Original 2021/08/05
# ARG USER_ID=1000
# RUN useradd -m --no-log-init --system  --uid ${USER_ID} solomon -g sudo
# RUN echo 'solomon:solomon' | sudo /usr/sbin/chpasswd

RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# USER solomon

ENTRYPOINT sudo service ssh restart && /usr/local/bin/nvidia_entrypoint.sh

WORKDIR /home/solomon

## 08/09 Python parts
### upgrade pip
RUN sudo python3 -m pip install --upgrade pip
### opencv
RUN sudo python3 -m pip install opencv-python==4.1.2.30 opencv-python-headless==4.1.2.30 
### pytorch
RUN sudo pip3 install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
### detectron2
RUN sudo python3 -m pip install detectron2 -f \
  https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.9/index.html
### Relevant python libraries
RUN sudo python3 -m pip install scipy==1.7.1 scikit-image==0.18.2 shapely==1.7.1
### Brilian
RUN sudo python3 -m pip install onnx==1.9.0 onnxruntime-gpu==1.8.1 mmdet onnx-simplifier==0.2.21 faiss-cpu

## 08/24 Python parts
RUN sudo python3 -m pip install pandas seaborn torchsummary dvc "dvc[ssh]"

## 09/13 Python parts
RUN sudo python3 -m pip install timm==0.4.12 prettytable==2.2.0 wandb==0.12.1

### Install zsh 
# the user we're applying this too (otherwise it most likely install for root)
USER $USER_NAME
# terminal colors with xterm
ENV TERM xterm
# set the zsh theme 
ENV ZSH_THEME bunnyruni
# run the installation script  
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true

RUN sudo apt-get update && sudo apt-get install htop autojump \
&& sudo curl https://raw.githubusercontent.com/jopcode/oh-my-zsh-bunnyruni-theme/master/bunnyruni.zsh-theme -L -o ~/.oh-my-zsh/themes/bunnyruni.zsh-theme \
&& sudo git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions \
&& sudo git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting \
&& sudo git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions \
&& sudo git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search \
&& sudo sed -i 's/plugins=(git)/plugins=(git autojump zsh-autosuggestions zsh-completions zsh-syntax-highlighting zsh-history-substring-search)/1' ~/.zshrc \ 
&& sudo sed -i -e 's/# DISABLE_UNTRACKED_FILES_DIRTY="true"/DISABLE_UNTRACKED_FILES_DIRTY="true"/1' ~/.zshrc 
# && sudo sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="bunnyruni"/g' ~/.zshrc 

### Amend the welcome info
RUN sudo sed -i '/Support:        https:\/\/ubuntu.com\/advantage\\n/a\printf " * SOLOMON Forum:               http:\/\/10.1.2.166\/\\n\"' /etc/update-motd.d/10-help-text \
&& sudo sed -i '/Support:        https:\/\/ubuntu.com\/advantage\\n/a\printf " * SOLOMON Redmine:             http:\/\/10.1.3.87\/redmine\/\\n\"' /etc/update-motd.d/10-help-text \
&& sudo sed -i 's/Documentation:  https:\/\/help.ubuntu.com\\n/SOLOMON Gitlab for AI-Team:  http:\/\/10.1.2.110:5567\/artificial-intelligence-team\\n/g' /etc/update-motd.d/10-help-text \ 
&& sudo sed -i 's/Management:     https:\/\/landscape.canonical.com\\n/SOLOMON Gitea  for AI-Team:  http:\/\/10.1.30.16:3000\/AI-Team\\n/g' /etc/update-motd.d/10-help-text \
&& sudo sed -i 's/Support:        https:\/\/ubuntu.com\/advantage\\n/Internal Cloud Drive:        http:\/\/10.1.2.166:8888\/\\n/g' /etc/update-motd.d/10-help-text \ 
&& sudo sed -i 's/echo "This system has/\#echo "This system has/g' /etc/update-motd.d/60-unminimize \ 
&& sudo sed -i 's/echo "not required on a/\#echo "not required on a/g' /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo "__        _______ _     ____ ___  __  __ _____   _____ ___  "' /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo "\\\\ \\\\      \/ \/ ____| |   \/ ___\/ _ \\\\|  \\\\\/  | ____| |_   _\/ _ \\\\ "' /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo " \\\\ \\\\ \/\\\\ \/ \/|  _| | |  | |  | | | | |\\\\\/| |  _|     | || | | |"'  /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo "  \\\\ V  V \/ | |___| |__| |__| |_| | |  | | |___    | || |_| |"'  /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo "   \\\\_\/\\\\_\/  |_____|_____\\\\____\\\\___\/|_|  |_|_____|   |_| \\\\___\/ "'  /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo "                                                            "' /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo "       _    ___    ____  _____ ______     _______ ____  "' /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo "      \/ \\\\  |_ _|  \/ ___|| ____|  _ \\\\ \\\\   \/ \/ ____|  _ \\\\ "' /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo "     \/ _ \\\\  | |   \\\\___ \\\\|  _| | |_) \\\\ \\\\ \/ \/|  _| | |_) |"' /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo "    \/ ___ \\\\ | |    ___) | |___|  _ < \\\\ V \/ | |___|  _ < "' /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo "   \/_\/   \\\\_\\\\___|  |____\/|_____|_| \\\\_\\\\ \\\\_\/  |_____|_| \\\\_\\\\"' /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo "                                                     "' /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo ""' /etc/update-motd.d/60-unminimize \
&& sudo sed -i '$i echo ""' /etc/update-motd.d/60-unminimize \
&& sudo rm /etc/legal  

### Change the permission of Public folder
RUN mkdir /home/solomon/public && sudo chown -R solomon:solomon /home/solomon/*

### Change the .so file of detectron2 to site-package
COPY assets/_C.cpython-38-x86_64-linux-gnu.so /usr/local/lib/python3.8/dist-packages/detectron2/

### Add the alias commands in zshrc
RUN sudo sed -i '$i alias e="exit"' /home/solomon/.zshrc \
&& sudo sed -i '$i alias cdd="j"' /home/solomon/.zshrc \
&& sudo sed -i '$i alias n="nvidia-smi"' /home/solomon/.zshrc \
&& sudo sed -i '$i alias gs="git status"' /home/solomon/.zshrc \
&& sudo sed -i '$i alias ga="git add"' /home/solomon/.zshrc \
&& sudo sed -i '$i alias gp="git pull"' /home/solomon/.zshrc \
&& sudo sed -i '$i alias dvc="python3 -m dvc"' /home/solomon/.zshrc \
&& sudo sed -i '$i alias trtexec="/usr/src/tensorrt/bin/trtexec"' /home/solomon/.zshrc \
&& sudo sed -i '$i export PATH="$PATH:/usr/src/tensorrt/bin"' /home/solomon/.zshrc 

RUN sudo apt-get install -y powerline tmux

RUN echo "set -g terminal-overrides 'xterm*:smcup@:rmcup@'" > /home/solomon/.tmux.conf \
&& sudo sed -i '$i set -g mouse on' /home/solomon/.tmux.conf

## 11/05
### upgrade pip
RUN sudo python3 -m pip install numba
RUN sudo apt install -y unrar unzip

# start zsh
CMD [ "zsh" ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment