diff --git a/docker/Dockerfile b/docker/Dockerfile index 5c61c49eb..07d57e5c6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -38,7 +38,7 @@ RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \ tzdata \ software-properties-common netcat-openbsd kmod unzip openssh-server \ curl wget lsof zsh ccache tmux htop git-lfs tree \ - build-essential cmake \ + build-essential cmake perl \ libopenmpi-dev libnuma1 libnuma-dev numactl \ libibverbs-dev libibverbs1 libibumad3 \ librdmacm1 libnl-3-200 libnl-route-3-200 libnl-route-3-dev libnl-3-dev \ @@ -286,171 +286,35 @@ RUN CMAKE_VERSION=3.31.1 \ && cp -r "${CMAKE_INSTALLER}/share/"* /usr/local/share/ \ && rm -rf "${CMAKE_INSTALLER}" "${CMAKE_INSTALLER}.tar.gz" -# Install Rust toolchain for sgl-router -ENV PATH="/root/.cargo/bin:${PATH}" +# Build and install sgl-router (Rust toolchain removed after build to save space) RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ - && rustc --version && cargo --version - -# Build and install sgl-router -RUN python3 -m pip install --no-cache-dir setuptools-rust \ + && export PATH="/root/.cargo/bin:${PATH}" \ + && rustc --version && cargo --version \ + && python3 -m pip install --no-cache-dir maturin \ && cd /sgl-workspace/sglang/sgl-router \ - && cargo build --release \ - && python3 -m pip install --no-cache-dir . \ - && rm -rf /root/.cache + && ulimit -n 65536 && maturin build --release --features vendored-openssl --out dist \ + && python3 -m pip install --no-cache-dir --force-reinstall dist/*.whl \ + && rm -rf /root/.cache /root/.cargo /root/.rustup target dist ~/.cargo # Add yank script -COPY --chown=root:root <<-"EOF" /usr/local/bin/yank -#!/bin/bash -put() { - esc=$1 - test -n "$TMUX" -o -z "${TERM##screen*}" && esc="\033Ptmux;\033$esc\033\\" - printf "$esc" -} -put "\033]52;c;!\a" -buf=$( cat "$@" ) -len=$( printf %s "$buf" | wc -c ) max=74994 -test $len -gt $max && echo "$0: input is $(( len - max )) bytes too long" >&2 -put "\033]52;c;$( printf %s "$buf" | head -c $max | base64 | tr -d '\r\n' )\a" -test -n "$TMUX" && tmux set-buffer "$buf" ||: -EOF - -RUN chmod +x /usr/local/bin/yank +COPY --chown=root:root --chmod=755 docker/configs/yank /usr/local/bin/yank # Install oh-my-zsh and plugins RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended \ && git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions \ && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting -# Configure Vim -COPY --chown=root:root <<-"EOF" /root/.vimrc -function! Yank(text) abort - let escape = system('yank', a:text) - if v:shell_error - echoerr escape - else - call writefile([escape], '/dev/tty', 'b') - endif -endfunction - -noremap y y:call Yank(@0) - -" automatically run yank(1) whenever yanking in Vim -function! CopyYank() abort - call Yank(join(v:event.regcontents, "\n")) -endfunction - -autocmd TextYankPost * call CopyYank() - -" Basic settings -set number -syntax on -set mouse=a -filetype indent on - -" Indentation -set autoindent nosmartindent -set smarttab -set expandtab -set shiftwidth=4 -set softtabstop=4 - -" Visual guides -set colorcolumn=120 -highlight ColorColumn ctermbg=5 - -" Status line -set laststatus=2 -set statusline=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P - -" Backspace behavior -set backspace=2 - -" Encoding -set encoding=utf-8 -set fileencoding=utf-8 -EOF - -# Configure tmux -COPY --chown=root:root <<-"EOF" /root/.tmux.conf -# Pane border styling -set -g pane-border-style fg='#742727',bg=black -set -g pane-active-border-style fg=red,bg=black - -# Status bar styling -set -g status-style bg='#0C8A92',fg=black - -# Change prefix key to backtick -set-option -g prefix ` -unbind C-b -bind-key ` send-prefix - -# Split panes using - and = with current path -unbind '"' -bind - splitw -v -c '#{pane_current_path}' -unbind '%' -bind = splitw -h -c '#{pane_current_path}' - -# Vi mode settings -bind-key -T copy-mode-vi Y send-keys -X copy-pipe 'yank > #{pane_tty}' -set-window-option -g mode-keys vi - -# Other settings -set-option -g escape-time 0 -set-option -g base-index 1 -set-window-option -g mouse on -set -g history-limit 100000 -EOF +# Configure Vim and tmux +COPY docker/configs/.vimrc /root/.vimrc +COPY docker/configs/.tmux.conf /root/.tmux.conf # Configure Git -RUN git config --global core.editor "vim" \ - && git config --global core.whitespace "fix,-indent-with-non-tab,trailing-space,cr-at-eol" \ - && git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX" \ - && git config --global color.ui true \ - && git config --global color."diff-highlight".oldNormal "red bold" \ - && git config --global color."diff-highlight".oldHighlight "red bold 52" \ - && git config --global color."diff-highlight".newNormal "green bold" \ - && git config --global color."diff-highlight".newHighlight "green bold 22" \ - && git config --global color.diff.meta "11" \ - && git config --global color.diff.frag "magenta bold" \ - && git config --global color.diff.commit "yellow bold" \ - && git config --global color.diff.old "red bold" \ - && git config --global color.diff.new "green bold" \ - && git config --global color.diff.whitespace "red reverse" \ - && git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%C(auto)%d%Creset' --abbrev-commit --" \ - && git config --global http.sslVerify false \ - && git config --global pull.rebase true +COPY docker/configs/.gitconfig /tmp/.gitconfig +RUN cat /tmp/.gitconfig >> /root/.gitconfig && rm /tmp/.gitconfig # Configure zsh -COPY --chown=root:root <<-"EOF" /root/.zshrc -export ZSH="/root/.oh-my-zsh" - -# Theme -ZSH_THEME="robbyrussell" - -# Plugins -plugins=( - git - z - zsh-autosuggestions - zsh-syntax-highlighting -) - -source $ZSH/oh-my-zsh.sh - -# Aliases -alias ll='ls -alF' -alias la='ls -A' -alias l='ls -CF' -alias vi='vim' - -# Enhanced history -HISTSIZE=10000 -SAVEHIST=10000 -setopt HIST_IGNORE_ALL_DUPS -setopt HIST_FIND_NO_DUPS -setopt INC_APPEND_HISTORY -EOF +COPY docker/configs/.zshrc /root/.zshrc RUN set -euxo ; \ curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin diff --git a/docker/configs/.gitconfig b/docker/configs/.gitconfig new file mode 100644 index 000000000..8150e40d8 --- /dev/null +++ b/docker/configs/.gitconfig @@ -0,0 +1,30 @@ +[core] + editor = vim + whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol + pager = diff-so-fancy | less --tabs=4 -RFX + +[color] + ui = true + +[color "diff-highlight"] + oldNormal = red bold + oldHighlight = red bold 52 + newNormal = green bold + newHighlight = green bold 22 + +[color "diff"] + meta = 11 + frag = magenta bold + commit = yellow bold + old = red bold + new = green bold + whitespace = red reverse + +[alias] + lg = log --color --graph --pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%C(auto)%d%Creset' --abbrev-commit -- + +[http] + sslVerify = false + +[pull] + rebase = true diff --git a/docker/configs/.tmux.conf b/docker/configs/.tmux.conf new file mode 100644 index 000000000..89f20064e --- /dev/null +++ b/docker/configs/.tmux.conf @@ -0,0 +1,27 @@ +# Pane border styling +set -g pane-border-style fg='#742727',bg=black +set -g pane-active-border-style fg=red,bg=black + +# Status bar styling +set -g status-style bg='#0C8A92',fg=black + +# Change prefix key to backtick +set-option -g prefix ` +unbind C-b +bind-key ` send-prefix + +# Split panes using - and = with current path +unbind '"' +bind - splitw -v -c '#{pane_current_path}' +unbind '%' +bind = splitw -h -c '#{pane_current_path}' + +# Vi mode settings +bind-key -T copy-mode-vi Y send-keys -X copy-pipe 'yank > #{pane_tty}' +set-window-option -g mode-keys vi + +# Other settings +set-option -g escape-time 0 +set-option -g base-index 1 +set-window-option -g mouse on +set -g history-limit 100000 diff --git a/docker/configs/.vimrc b/docker/configs/.vimrc new file mode 100644 index 000000000..d4414000b --- /dev/null +++ b/docker/configs/.vimrc @@ -0,0 +1,45 @@ +function! Yank(text) abort + let escape = system('yank', a:text) + if v:shell_error + echoerr escape + else + call writefile([escape], '/dev/tty', 'b') + endif +endfunction + +noremap y y:call Yank(@0) + +" automatically run yank(1) whenever yanking in Vim +function! CopyYank() abort + call Yank(join(v:event.regcontents, "\n")) +endfunction + +autocmd TextYankPost * call CopyYank() + +" Basic settings +set number +syntax on +set mouse=a +filetype indent on + +" Indentation +set autoindent nosmartindent +set smarttab +set expandtab +set shiftwidth=4 +set softtabstop=4 + +" Visual guides +set colorcolumn=120 +highlight ColorColumn ctermbg=5 + +" Status line +set laststatus=2 +set statusline=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P + +" Backspace behavior +set backspace=2 + +" Encoding +set encoding=utf-8 +set fileencoding=utf-8 diff --git a/docker/configs/.zshrc b/docker/configs/.zshrc new file mode 100644 index 000000000..5c7113e05 --- /dev/null +++ b/docker/configs/.zshrc @@ -0,0 +1,27 @@ +export ZSH="/root/.oh-my-zsh" + +# Theme +ZSH_THEME="robbyrussell" + +# Plugins +plugins=( + git + z + zsh-autosuggestions + zsh-syntax-highlighting +) + +source $ZSH/oh-my-zsh.sh + +# Aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' +alias vi='vim' + +# Enhanced history +HISTSIZE=10000 +SAVEHIST=10000 +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_FIND_NO_DUPS +setopt INC_APPEND_HISTORY diff --git a/docker/configs/yank b/docker/configs/yank new file mode 100755 index 000000000..c9de641bc --- /dev/null +++ b/docker/configs/yank @@ -0,0 +1,12 @@ +#!/bin/bash +put() { + esc=$1 + test -n "$TMUX" -o -z "${TERM##screen*}" && esc="\033Ptmux;\033$esc\033\\" + printf "$esc" +} +put "\033]52;c;!\a" +buf=$( cat "$@" ) +len=$( printf %s "$buf" | wc -c ) max=74994 +test $len -gt $max && echo "$0: input is $(( len - max )) bytes too long" >&2 +put "\033]52;c;$( printf %s "$buf" | head -c $max | base64 | tr -d '\r\n' )\a" +test -n "$TMUX" && tmux set-buffer "$buf" ||: