Dockerfile 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. FROM ubuntu:jammy
  2. LABEL maintainer="Jeremy Zheng"
  3. ENV DEBIAN_FRONTEND noninteractive
  4. RUN apt update
  5. RUN apt install -y lsb-release apt-utils \
  6. debian-keyring debian-archive-keyring apt-transport-https software-properties-common curl wget gnupg
  7. # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
  8. ENV AMD64_GCC_VERSION 13
  9. ENV GCC_VERSION 12
  10. RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
  11. RUN echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse" > /etc/apt/sources.list
  12. RUN echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse" >> /etc/apt/sources.list
  13. RUN echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-security main restricted universe multiverse" >> /etc/apt/sources.list
  14. # https://apt.llvm.org/
  15. ENV CLANG_VERSION 18
  16. RUN echo "deb [arch=amd64] http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${CLANG_VERSION} main" > /etc/apt/sources.list.d/llvm.list
  17. RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
  18. # https://wiki.debian.org/ToolChain/Cross
  19. RUN dpkg --add-architecture armhf
  20. RUN dpkg --add-architecture arm64
  21. RUN dpkg --add-architecture riscv64
  22. RUN echo "deb [arch=armhf,arm64,riscv64] http://ports.ubuntu.com/ $(lsb_release -cs) main restricted universe multiverse" >> /etc/apt/sources.list
  23. RUN echo "deb [arch=armhf,arm64,riscv64] http://ports.ubuntu.com/ $(lsb_release -cs)-security main restricted universe multiverse" >> /etc/apt/sources.list
  24. RUN echo "deb [arch=armhf,arm64,riscv64] http://ports.ubuntu.com/ $(lsb_release -cs)-updates main restricted universe multiverse" >> /etc/apt/sources.list
  25. RUN apt update
  26. RUN apt -y upgrade
  27. RUN apt -y install zsh git locales locales-all \
  28. vim tzdata zip unzip tree tmux \
  29. build-essential g++-${GCC_VERSION} libstdc++-${GCC_VERSION}-dev \
  30. g++-${AMD64_GCC_VERSION} libstdc++-${AMD64_GCC_VERSION}-dev \
  31. crossbuild-essential-arm64 g++-${GCC_VERSION}-aarch64-linux-gnu libstdc++-${GCC_VERSION}-dev:arm64 \
  32. crossbuild-essential-armhf g++-${GCC_VERSION}-arm-linux-gnueabihf libstdc++-${GCC_VERSION}-dev:armhf \
  33. crossbuild-essential-riscv64 g++-${GCC_VERSION}-riscv64-linux-gnu libstdc++-${GCC_VERSION}-dev:riscv64 \
  34. clang-${CLANG_VERSION} clangd-${CLANG_VERSION} clang-tools-${CLANG_VERSION} clang-format-${CLANG_VERSION} clang-tidy-${CLANG_VERSION} lldb-${CLANG_VERSION} lld-${CLANG_VERSION} \
  35. cmake pkg-config libtool automake autoconf autoconf-archive binutils cpio mold \
  36. debhelper bison flex ninja-build \
  37. erlang elixir \
  38. python3-full python3-dev
  39. RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${CLANG_VERSION} 100 \
  40. && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${CLANG_VERSION} 100 \
  41. && update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-${CLANG_VERSION} 100 \
  42. && update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-${CLANG_VERSION} 100 \
  43. && update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-${CLANG_VERSION} 100 \
  44. && update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${CLANG_VERSION} 100 \
  45. && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${AMD64_GCC_VERSION} 100 \
  46. && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${AMD64_GCC_VERSION} 100 \
  47. && update-alternatives --install /usr/bin/aarch64-linux-gnu-gcc aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-gnu-gcc-${GCC_VERSION} 100 \
  48. && update-alternatives --install /usr/bin/aarch64-linux-gnu-g++ aarch64-linux-gnu-g++ /usr/bin/aarch64-linux-gnu-g++-${GCC_VERSION} 100 \
  49. && update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-${GCC_VERSION} 100 \
  50. && update-alternatives --install /usr/bin/arm-linux-gnueabihf-g++ arm-linux-gnueabihf-g++ /usr/bin/arm-linux-gnueabihf-g++-${GCC_VERSION} 100 \
  51. && update-alternatives --install /usr/bin/riscv64-linux-gnu-gcc riscv64-linux-gnu-gcc /usr/bin/riscv64-linux-gnu-gcc-${GCC_VERSION} 100 \
  52. && update-alternatives --install /usr/bin/riscv64-linux-gnu-g++ riscv64-linux-gnu-g++ /usr/bin/riscv64-linux-gnu-g++-${GCC_VERSION} 100
  53. RUN apt -y autoremove
  54. RUN apt -y clean
  55. RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
  56. RUN locale-gen
  57. RUN update-locale LANG=en_US.UTF-8
  58. RUN update-alternatives --set editor /usr/bin/vim.basic
  59. RUN mkdir -p $HOME/downloads $HOME/build $HOME/local $HOME/tmp
  60. # https://github.com/ohmyzsh/ohmyzsh
  61. RUN git clone https://github.com/ohmyzsh/ohmyzsh.git $HOME/.oh-my-zsh
  62. RUN cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc
  63. RUN echo 'export LANG=en_US.UTF-8' >> $HOME/.zshrc
  64. RUN echo 'export LC_ALL=en_US.UTF-8' >> $HOME/.zshrc
  65. RUN echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.zshrc
  66. RUN git config --global core.quotepath false \
  67. && git config --global http.version HTTP/1.1 \
  68. && git config --global pull.rebase false \
  69. && git config --global url."https://".insteadOf git://
  70. RUN echo 'set-option -g history-limit 102400' > $HOME/.tmux.conf \
  71. && echo 'set-option -g default-shell "/bin/zsh"' >> $HOME/.tmux.conf
  72. # https://musl.cc/
  73. RUN wget -q -P $HOME/downloads https://more.musl.cc/x86_64-linux-musl/x86_64-linux-musl-cross.tgz \
  74. && tar xf $HOME/downloads/x86_64-linux-musl-cross.tgz -C $HOME/local \
  75. && echo 'export PATH=$HOME/local/x86_64-linux-musl-cross/bin:$PATH' >> $HOME/.zshrc
  76. RUN wget -q -P $HOME/downloads https://more.musl.cc/x86_64-linux-musl/armv7l-linux-musleabihf-cross.tgz \
  77. && tar xf $HOME/downloads/armv7l-linux-musleabihf-cross.tgz -C $HOME/local \
  78. && echo 'export PATH=$HOME/local/armv7l-linux-musleabihf-cross/bin:$PATH' >> $HOME/.zshrc
  79. RUN wget -q -P $HOME/downloads https://more.musl.cc/x86_64-linux-musl/aarch64-linux-musl-cross.tgz \
  80. && tar xf $HOME/downloads/aarch64-linux-musl-cross.tgz -C $HOME/local \
  81. && echo 'export PATH=$HOME/local/aarch64-linux-musl-cross/bin:$PATH' >> $HOME/.zshrc
  82. RUN wget -q -P $HOME/downloads https://more.musl.cc/x86_64-linux-musl/riscv64-linux-musl-cross.tgz \
  83. && tar xf $HOME/downloads/riscv64-linux-musl-cross.tgz -C $HOME/local \
  84. && echo 'export PATH=$HOME/local/riscv64-linux-musl-cross/bin:$PATH' >> $HOME/.zshrc
  85. # https://github.com/nvm-sh/nvm
  86. ENV NVM_VERSION "v0.40.1"
  87. RUN git clone -b ${NVM_VERSION} https://github.com/nvm-sh/nvm.git $HOME/.nvm
  88. RUN echo 'export NVM_DIR="$HOME/.nvm"' >> $HOME/.zshrc
  89. RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $HOME/.zshrc
  90. RUN echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> $HOME/.zshrc
  91. RUN zsh -c "source $HOME/.zshrc \
  92. && nvm install --lts"
  93. ENV JDK_VERSION "23-open"
  94. # https://docs.gradle.org/current/userguide/compatibility.html
  95. RUN curl -s "https://get.sdkman.io" | bash
  96. RUN sed -i -e 's/sdkman_auto_answer=false/sdkman_auto_answer=true/g' $HOME/.sdkman/etc/config
  97. RUN zsh -c "source $HOME/.zshrc \
  98. && sdk install java ${JDK_VERSION} \
  99. && sdk install maven \
  100. && sdk install gradle"
  101. # https://go.dev/doc/install
  102. ENV GO_VERSION "1.23.4"
  103. RUN wget -q -P $HOME/downloads https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz
  104. RUN tar xf $HOME/downloads/go${GO_VERSION}.linux-amd64.tar.gz -C $HOME/local
  105. RUN echo 'export PATH=$HOME/local/go/bin:$PATH' >> $HOME/.zshrc \
  106. && echo 'export GOPATH=$HOME/go' >> $HOME/.zshrc \
  107. && echo 'export PATH="$(go env GOPATH)/bin:$PATH"' >> $HOME/.zshrc
  108. # https://grpc.io/docs/languages/go/quickstart/
  109. RUN zsh -c "source $HOME/.zshrc \
  110. && go install google.golang.org/protobuf/cmd/protoc-gen-go@latest \
  111. && go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest"
  112. # https://www.rust-lang.org/tools/install
  113. RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
  114. RUN zsh -c "source $HOME/.cargo/env \
  115. && rustup target add x86_64-unknown-linux-musl \
  116. && rustup target add armv7-unknown-linux-gnueabihf \
  117. && rustup target add aarch64-unknown-linux-gnu \
  118. && rustup target add aarch64-unknown-linux-musl \
  119. && rustup target add riscv64gc-unknown-linux-gnu"
  120. # https://github.com/microsoft/vcpkg
  121. RUN git clone https://github.com/microsoft/vcpkg.git $HOME/local/vcpkg
  122. RUN $HOME/local/vcpkg/bootstrap-vcpkg.sh \
  123. && echo 'export VCPKG_DISABLE_METRICS=1' >> $HOME/.zshrc
  124. # https://github.com/grpc/grpc
  125. ENV GRPC_VERSION "v1.68.2"
  126. RUN git clone --recurse-submodules -b $GRPC_VERSION https://github.com/grpc/grpc.git $HOME/downloads/grpc
  127. RUN apt install -y libssl-dev
  128. RUN zsh -c "source $HOME/.zshrc \
  129. && mkdir -pv $HOME/build/grpc \
  130. && cd $HOME/build/grpc \
  131. && cmake -DCMAKE_BUILD_TYPE=Release \
  132. -DgRPC_INSTALL=ON \
  133. -DgRPC_SSL_PROVIDER=package \
  134. -DgRPC_BUILD_TESTS=OFF \
  135. -DCMAKE_INSTALL_PREFIX=$HOME/.local $HOME/downloads/grpc \
  136. && make -j $(nproc --ignore=2) \
  137. && make install"
  138. RUN echo "$(date -u +%4Y%m%d%H%M%S)" | tee /VERSION
  139. VOLUME /workspace
  140. WORKDIR /workspace
  141. CMD ["/bin/zsh", "-l"]