|
| 1 | +ARG VARIANT=dev |
| 2 | +FROM ubuntu:22.04 as base |
| 3 | + |
| 4 | +ENV DEBIAN_FRONTEND noninteractive |
| 5 | + |
| 6 | +RUN apt update && \ |
| 7 | + apt install autoconf automake libtool curl wget make cmake g++ unzip git -y && \ |
| 8 | + rm -rf /var/lib/apt/lists/* |
| 9 | + |
| 10 | +# Install Bazel |
| 11 | +RUN apt update && apt install apt-transport-https curl gnupg -y && \ |
| 12 | + curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg && \ |
| 13 | + mv bazel-archive-keyring.gpg /usr/share/keyrings && \ |
| 14 | + echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list && \ |
| 15 | + apt update && \ |
| 16 | + wget https://github.com/bazelbuild/bazel/releases/download/7.3.1/bazel-7.3.1-installer-linux-x86_64.sh -O /tmp/bazel-installer.sh && \ |
| 17 | + chmod +x /tmp/bazel-installer.sh && \ |
| 18 | + /tmp/bazel-installer.sh |
| 19 | + |
| 20 | +# install Clang |
| 21 | +ENV CLANG 20 |
| 22 | +ENV CLANG_URL https://apt.llvm.org/llvm.sh |
| 23 | +RUN apt update && apt install -y lsb-release wget software-properties-common gnupg && \ |
| 24 | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ |
| 25 | + echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${CLANG} main" | tee /etc/apt/sources.list.d/llvm-toolchain.list && \ |
| 26 | + echo "deb-src http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${CLANG} main" | tee -a /etc/apt/sources.list.d/llvm-toolchain.list && \ |
| 27 | + apt update && \ |
| 28 | + apt install lsb-release wget software-properties-common gnupg -y && \ |
| 29 | + apt install --no-install-recommends -y \ |
| 30 | + clang-${CLANG} \ |
| 31 | + clang-tidy-${CLANG} \ |
| 32 | + clang-format-${CLANG} \ |
| 33 | + llvm-${CLANG}-dev \ |
| 34 | + clangd-${CLANG} \ |
| 35 | + libclang-${CLANG}-dev \ |
| 36 | + libclang-cpp${CLANG} && \ |
| 37 | + rm -rf /var/lib/apt/lists/* |
| 38 | + |
| 39 | +RUN apt update && \ |
| 40 | + apt install lsb-release wget software-properties-common gnupg -y && \ |
| 41 | + wget ${CLANG_URL} && \ |
| 42 | + chmod +x llvm.sh && \ |
| 43 | + ./llvm.sh ${CLANG} && \ |
| 44 | + ln -s /usr/bin/clang-20 /usr/bin/clang && \ |
| 45 | + ln -s /usr/bin/clang++-20 /usr/bin/clang++ && \ |
| 46 | + ln -s /usr/bin/clang-tidy-20 /usr/bin/clang-tidy && \ |
| 47 | + ln -s /usr/bin/clang-format-20 /usr/bin/clang-format && \ |
| 48 | + ln -s /usr/bin/clangd-20 /usr/bin/clangd && \ |
| 49 | + rm -rf llvm.sh && \ |
| 50 | + rm -rf /var/lib/apt/lists/* |
| 51 | + |
| 52 | +FROM base as dev-stage |
| 53 | +COPY --from=base /usr/local/include /usr/local/include |
| 54 | +COPY --from=base /usr/local/lib /usr/local/lib |
| 55 | +COPY --from=base /usr/local/bin /usr/local/bin |
| 56 | + |
| 57 | +# install Clangd |
| 58 | +ENV CLANGD 16.0.2 |
| 59 | +ENV CLANGD_URL https://github.com/clangd/clangd/releases/download/${CLANGD}/clangd-linux-${CLANGD}.zip |
| 60 | +WORKDIR /tmp |
| 61 | +RUN wget ${CLANGD_URL} && \ |
| 62 | + unzip clangd-linux-${CLANGD}.zip && \ |
| 63 | + mv clangd_${CLANGD}/lib/clang /usr/local/lib/ && \ |
| 64 | + mv clangd_${CLANGD}/bin/clangd /usr/local/bin/ && \ |
| 65 | + rm -rf clangd_${CLANGD} && \ |
| 66 | + rm -rf clangd-linux-${CLANGD}.zip |
| 67 | + |
| 68 | +# install GDB |
| 69 | +ENV GDB 12.1 |
| 70 | +ENV GDB_URL https://ftp.gnu.org/gnu/gdb/gdb-${GDB}.tar.gz |
| 71 | +WORKDIR /tmp |
| 72 | +RUN apt update && \ |
| 73 | + apt install -y --no-install-recommends libgmp-dev && \ |
| 74 | + rm -rf /var/lib/apt/lists/* && \ |
| 75 | + wget ${GDB_URL} && \ |
| 76 | + tar -zxvf gdb-${GDB}.tar.gz && \ |
| 77 | + cd gdb-${GDB} && \ |
| 78 | + ./configure && \ |
| 79 | + export CPP='g++ -E' && \ |
| 80 | + export CXX='g++' && \ |
| 81 | + export CC='gcc' && \ |
| 82 | + export LD='g++' && \ |
| 83 | + make -j$(nproc) && \ |
| 84 | + make install && \ |
| 85 | + cd /tmp && \ |
| 86 | + rm -rf /tmp/gdb-${GDB}* |
| 87 | + |
| 88 | +# install zsh & fix ssh env |
| 89 | +WORKDIR /tmp |
| 90 | +RUN apt update && apt install zsh openssh-client openssh-server -y && \ |
| 91 | + echo "export \$(cat /proc/1/environ |tr '\\0' '\\n' | xargs)" >> /etc/profile && \ |
| 92 | + echo "export \$(cat /proc/1/environ |tr '\\0' '\\n' | xargs)" >> /etc/zsh/zprofile && \ |
| 93 | + rm -rf ~/.oh-my-zsh || true && \ |
| 94 | + curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -o install.sh && \ |
| 95 | + chmod +x install.sh && \ |
| 96 | + ./install.sh --skip-chsh --unattended && \ |
| 97 | + rm install.sh && \ |
| 98 | + git clone http://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions && \ |
| 99 | + git clone http://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting && \ |
| 100 | + sed -e '/ZSH_THEME=/s/"robbyrussell"/"ys"/' \ |
| 101 | + -e '/plugins=(git/s/)/ zsh-autosuggestions zsh-syntax-highlighting)/' -i ~/.zshrc && \ |
| 102 | + chsh -s /bin/zsh root && \ |
| 103 | + rm -rf /var/lib/apt/lists/* |
| 104 | + |
| 105 | +# install vim & plugins |
| 106 | +RUN apt update && \ |
| 107 | + apt install -y --no-install-recommends \ |
| 108 | + git vim && \ |
| 109 | + rm -rf /var/lib/apt/lists/* && \ |
| 110 | + git config --global core.editor vim && \ |
| 111 | + git config --global http.sslverify false && \ |
| 112 | + git config --global https.sslverify false && \ |
| 113 | + git clone https://github.com/sickill/vim-monokai.git /tmp/vim-monokai && \ |
| 114 | + mkdir -p ~/.vim/colors && \ |
| 115 | + mv /tmp/vim-monokai/colors/* ~/.vim/colors && \ |
| 116 | + git config --global --unset http.sslverify && \ |
| 117 | + git config --global --unset https.sslverify && \ |
| 118 | + touch ~/.vimrc && \ |
| 119 | + vim -u ~/.vimrc +PlugInstall +qall |
| 120 | + |
| 121 | +FROM base as final-build |
| 122 | +USER root |
| 123 | +WORKDIR /workspace |
| 124 | +ENV PATH $PATH:/usr/local/cuda/bin:/usr/src/tensorrt/bin |
| 125 | +ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/targets/x86_64-linux/lib:/usr/lib/llvm-20/lib |
| 126 | +ENV LIBRARY_PATH $LIBRARY_PATH::/usr/local/lib:/usr/local/cuda/lib64:/usr/local/cuda/targets/x86_64-linux/lib:/usr/lib/llvm-20/lib |
| 127 | +ENV C_INCLUDE_PATH $C_INCLUDE_PATH:/usr/local/cuda/include:/usr/include/x86_64-linux-gnu:/usr/lib/llvm-20/include:/usr/include/llvm-20 |
| 128 | +ENV CPLUS_INCLUDE_PATH $CPLUS_INCLUDE_PATH:/usr/local/cuda/include://usr/include/x86_64-linux-gnu::/usr/lib/llvm-20/include:/usr/include/llvm-20 |
| 129 | + |
| 130 | +FROM dev-stage as final-dev |
| 131 | +USER root |
| 132 | +WORKDIR /workspace |
| 133 | +ENV PATH $PATH:/usr/local/cuda/bin:/usr/src/tensorrt/bin |
| 134 | +ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/targets/x86_64-linux/lib:/usr/lib/llvm-20/lib |
| 135 | +ENV LIBRARY_PATH $LIBRARY_PATH::/usr/local/lib:/usr/local/cuda/lib64:/usr/local/cuda/targets/x86_64-linux/lib:/usr/lib/llvm-20/lib |
| 136 | +ENV C_INCLUDE_PATH $C_INCLUDE_PATH:/usr/local/cuda/include:/usr/include/x86_64-linux-gnu:/usr/lib/llvm-20/include:/usr/include/llvm-20 |
| 137 | +ENV CPLUS_INCLUDE_PATH $CPLUS_INCLUDE_PATH:/usr/local/cuda/include://usr/include/x86_64-linux-gnu::/usr/lib/llvm-20/include:/usr/include/llvm-20 |
| 138 | + |
| 139 | +FROM final-${VARIANT} as final |
0 commit comments