Dockerfile 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. FROM ubuntu:jammy
  2. LABEL maintainer="Jeremy Zheng"
  3. ENV DEBIAN_FRONTEND noninteractive
  4. RUN apt update
  5. RUN apt -y upgrade
  6. RUN apt -y install debian-keyring debian-archive-keyring apt-transport-https software-properties-common curl wget gnupg
  7. # https://wiki.ubuntu.com/ToolChain
  8. RUN echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse" > /etc/apt/sources.list
  9. RUN echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse" >> /etc/apt/sources.list
  10. RUN echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-security main restricted universe multiverse" >> /etc/apt/sources.list
  11. RUN dpkg --add-architecture armhf
  12. RUN dpkg --add-architecture arm64
  13. RUN echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ $(lsb_release -cs) main restricted universe multiverse" >> /etc/apt/sources.list
  14. RUN echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ $(lsb_release -cs)-security main restricted universe multiverse" >> /etc/apt/sources.list
  15. RUN echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ $(lsb_release -cs)-updates main restricted universe multiverse" >> /etc/apt/sources.list
  16. RUN apt update
  17. RUN apt -y upgrade
  18. RUN apt -y install zsh git locales locales-all rsync openssh-client sshpass \
  19. vim tzdata pwgen zip unzip tree tmux dialog asciidoc doxygen \
  20. net-tools dnsutils net-tools iputils-arping iputils-ping telnet \
  21. imagemagick ffmpeg fonts-dejavu-extra texlive-full \
  22. build-essential cmake pkg-config libtool automake autoconf autoconf-archive binutils cpio mold \
  23. debhelper bison flex ninja-build \
  24. musl-tools musl-dev \
  25. crossbuild-essential-armhf crossbuild-essential-arm64 \
  26. python3 python3-distutils python3-dev python3-pip virtualenv \
  27. php-fpm php-mbstring php-json php-xml php-pear php-bcmath php-curl php-zip \
  28. php-mysql php-pgsql php-sqlite3 php-redis php-mongodb php-amqp php-zmq \
  29. php-imagick php-gd \
  30. nginx rabbitmq-server redis postgresql mariadb-server
  31. # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
  32. RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
  33. RUN apt update
  34. ENV GCC_VERSION 12
  35. RUN apt install -y g++-${GCC_VERSION} g++-${GCC_VERSION}-aarch64-linux-gnu g++-${GCC_VERSION}-arm-linux-gnueabihf
  36. RUN apt install -y libstdc++-${GCC_VERSION}-dev:amd64 libstdc++-${GCC_VERSION}-dev:arm64 libstdc++-${GCC_VERSION}-dev:armhf
  37. # https://apt.llvm.org/
  38. ENV CLANG_VERSION=15
  39. 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
  40. RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
  41. RUN apt update
  42. RUN apt install -y clang-${CLANG_VERSION} \
  43. clangd-${CLANG_VERSION} clang-tools-${CLANG_VERSION} clang-format-${CLANG_VERSION} \
  44. lldb-${CLANG_VERSION} lld-${CLANG_VERSION}
  45. RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${CLANG_VERSION} 100
  46. RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${CLANG_VERSION} 100
  47. RUN update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-${CLANG_VERSION} 100
  48. RUN update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-${CLANG_VERSION} 100
  49. RUN update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${CLANG_VERSION} 100
  50. # https://www.envoyproxy.io/docs/envoy/latest/start/install#install-envoy-on-ubuntu-linux
  51. RUN curl -sL 'https://deb.dl.getenvoy.io/public/gpg.8115BA8E629CC074.key' | gpg --dearmor -o /usr/share/keyrings/getenvoy-keyring.gpg
  52. RUN echo a077cb587a1b622e03aa4bf2f3689de14658a9497a9af2c427bba5f4cc3c4723 /usr/share/keyrings/getenvoy-keyring.gpg | sha256sum --check
  53. RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/getenvoy-keyring.gpg] https://deb.dl.getenvoy.io/public/deb/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/getenvoy.list
  54. RUN apt update
  55. RUN apt install -y getenvoy-envoy
  56. # https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/
  57. # RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
  58. # RUN echo "deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
  59. # RUN apt update
  60. # RUN apt install -y mongodb
  61. RUN apt -y autoremove
  62. RUN apt -y clean
  63. RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
  64. RUN locale-gen
  65. RUN update-locale LANG=en_US.UTF-8
  66. RUN update-alternatives --set editor /usr/bin/vim.basic
  67. RUN mkdir -p $HOME/downloads $HOME/build $HOME/local $HOME/tmp
  68. # https://github.com/ohmyzsh/ohmyzsh
  69. RUN git clone https://github.com/ohmyzsh/ohmyzsh.git $HOME/.oh-my-zsh
  70. RUN cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc
  71. RUN echo 'export LANG=en_US.UTF-8' >> $HOME/.zshrc
  72. RUN echo 'export LC_ALL=en_US.UTF-8' >> $HOME/.zshrc
  73. RUN echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.zshrc
  74. RUN git config --global core.quotepath false
  75. RUN git config --global http.version HTTP/1.1
  76. RUN git config --global pull.rebase false
  77. RUN git config --global url."https://".insteadOf git://
  78. RUN echo 'set-option -g history-limit 102400' > $HOME/.tmux.conf
  79. RUN echo 'set-option -g default-shell "/bin/zsh"' >> $HOME/.tmux.conf
  80. RUN zsh -c "source $HOME/.zshrc && pip3 install --user cmake"
  81. RUN zsh -c "source $HOME/.zshrc \
  82. && pip3 install --user ansible paramiko"
  83. RUN echo 'export ANSIBLE_HOST_KEY_CHECKING=False' >> $HOME/.zshrc
  84. RUN echo 'alias peony="ANSIBLE_LOG_PATH=$HOME/tmp/$(date +%Y%m%d%H%M%S).log ansible-playbook"' >> $HOME/.zshrc
  85. RUN zsh -c "source $HOME/.zshrc \
  86. && pip3 install --user conan \
  87. && conan profile new default --detect \
  88. && conan profile update settings.compiler.libcxx=libstdc++11 default"
  89. RUN zsh -c "source $HOME/.zshrc && pip3 install --user supervisor"
  90. # https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos
  91. RUN wget -q -O $HOME/downloads/composer https://getcomposer.org/installer
  92. RUN cd $HOME/downloads \
  93. && php composer \
  94. && mv composer.phar $HOME/.local/bin/composer
  95. # https://github.com/rui314/mold
  96. # RUN git clone -b v1.6.0 https://github.com/rui314/mold.git $HOME/downloads/mold
  97. # RUN apt install -y libssl-dev libxxhash-dev zlib1g-dev \
  98. # file bsdmainutils
  99. # RUN zsh -c "source $HOME/.zshrc \
  100. # && mkdir $HOME/build/mold \
  101. # && cd $HOME/build/mold \
  102. # && cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ $HOME/downloads/mold \
  103. # && make -j \
  104. # && make install "
  105. # https://github.com/richfelker/musl-cross-make
  106. RUN git clone https://github.com/richfelker/musl-cross-make.git $HOME/build/musl-cross-make
  107. RUN cd $HOME/build/musl-cross-make \
  108. && echo "TARGET=x86_64-linux-musl" > config.mak \
  109. && echo "OUTPUT=/opt/crosstools" >> config.mak \
  110. && make \
  111. && make install
  112. RUN cd $HOME/build/musl-cross-make \
  113. && echo "TARGET=aarch64-linux-musl" > config.mak \
  114. && echo "OUTPUT=/opt/crosstools" >> config.mak \
  115. && make \
  116. && make install
  117. RUN cd $HOME/build/musl-cross-make \
  118. && echo "TARGET=arm-linux-musleabihf" > config.mak \
  119. && echo "OUTPUT=/opt/crosstools" >> config.mak \
  120. && make \
  121. && make install
  122. ENV BAZEL_VERSION "v1.15.0"
  123. RUN wget -q -O $HOME/.local/bin/bazel \
  124. https://github.com/bazelbuild/bazelisk/releases/download/${BAZEL_VERSION}/bazelisk-linux-amd64
  125. RUN chmod +x $HOME/.local/bin/bazel
  126. # https://github.com/rbenv/rbenv
  127. RUN git clone https://github.com/rbenv/rbenv.git $HOME/.rbenv
  128. RUN cd $HOME/.rbenv && src/configure && make -C src
  129. RUN echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $HOME/.zshrc
  130. RUN echo 'eval "$(rbenv init -)"' >> $HOME/.zshrc
  131. RUN git clone https://github.com/rbenv/ruby-build.git $HOME/.rbenv/plugins/ruby-build
  132. RUN git clone https://github.com/rbenv/rbenv-vars.git $HOME/.rbenv/plugins/rbenv-vars
  133. ENV RUBY_VERSION "3.1.2"
  134. RUN apt install -y libssl-dev
  135. RUN zsh -c "source $HOME/.zshrc \
  136. && rbenv install ${RUBY_VERSION} \
  137. && rbenv global ${RUBY_VERSION} \
  138. && gem install bundler"
  139. ENV GO_VERSION "1.19.2"
  140. RUN wget -q -P $HOME/downloads https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz
  141. RUN tar xf $HOME/downloads/go${GO_VERSION}.linux-amd64.tar.gz -C $HOME/local
  142. RUN echo 'export GOROOT=$HOME/local/go' >> $HOME/.zshrc
  143. RUN echo 'export PATH=$GOROOT/bin:$PATH' >> $HOME/.zshrc
  144. RUN echo 'export GOPATH=$HOME/go' >> $HOME/.zshrc
  145. ENV JDK_VERSION "19.0.1-open"
  146. RUN curl -s "https://get.sdkman.io" | zsh
  147. RUN sed -i -e 's/sdkman_auto_answer=false/sdkman_auto_answer=true/g' $HOME/.sdkman/etc/config
  148. RUN zsh -c "source $HOME/.zshrc \
  149. && sdk install java ${JDK_VERSION} \
  150. && sdk install maven \
  151. && sdk install gradle"
  152. # https://github.com/nvm-sh/nvm
  153. ENV NVM_VERSION "v0.39.2"
  154. RUN git clone -b ${NVM_VERSION} https://github.com/nvm-sh/nvm.git $HOME/.nvm
  155. RUN echo 'export NVM_DIR="$HOME/.nvm"' >> $HOME/.zshrc
  156. RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $HOME/.zshrc
  157. RUN echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> $HOME/.zshrc
  158. RUN zsh -c "source $HOME/.zshrc \
  159. && nvm install node \
  160. && nvm use node \
  161. && npm i yarn -g"
  162. RUN zsh -c "source $HOME/.zshrc \
  163. && nvm install --lts \
  164. && nvm use --lts \
  165. && npm i yarn -g"
  166. # https://stackoverflow.com/questions/37324519/node-sass-does-not-yet-support-your-current-environment-linux-64-bit-with-false
  167. RUN zsh -c "source $HOME/.zshrc \
  168. && nvm install lts/fermium \
  169. && nvm use lts/fermium \
  170. && npm i yarn -g"
  171. RUN echo 'export PATH=$HOME/.yarn/bin:$PATH' >> $HOME/.zshrc
  172. # https://www.rust-lang.org/tools/install
  173. RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
  174. # https://doc.rust-lang.org/nightly/rustc/platform-support.html
  175. RUN zsh -c "source $HOME/.cargo/env \
  176. && rustup component add rust-analyzer \
  177. && rustup target add armv7-unknown-linux-gnueabihf \
  178. && rustup target add aarch64-unknown-linux-gnu \
  179. && rustup target add x86_64-unknown-linux-musl \
  180. && rustup target add aarch64-unknown-linux-musl"
  181. RUN apt install -y libpq-dev libmysqlclient-dev libsqlite3-dev
  182. RUN zsh -c "source $HOME/.zshrc \
  183. && cargo install diesel_cli \
  184. && cargo install --locked cargo-outdated \
  185. && cargo install mdbook"
  186. # https://opensearch.org/downloads.html#opensearch
  187. ENV OPENSEARCH_VERSION "2.3.0"
  188. RUN wget -q -P $HOME/downloads \
  189. https://artifacts.opensearch.org/releases/bundle/opensearch/${OPENSEARCH_VERSION}/opensearch-${OPENSEARCH_VERSION}-linux-x64.tar.gz
  190. RUN tar xf $HOME/downloads/opensearch-${OPENSEARCH_VERSION}-linux-x64.tar.gz -C /opt
  191. # https://min.io/download#/linux
  192. RUN wget -q -O /usr/bin/minio \
  193. https://dl.min.io/server/minio/release/linux-amd64/minio
  194. RUN chmod +x /usr/bin/minio
  195. ENV GRPC_VERSION "v1.50.1"
  196. RUN git clone --recurse-submodules -b $GRPC_VERSION https://github.com/grpc/grpc.git $HOME/downloads/grpc
  197. RUN zsh -c "source $HOME/.zshrc \
  198. && mkdir -pv $HOME/build/grpc \
  199. && cd $HOME/build/grpc \
  200. && cmake -DCMAKE_BUILD_TYPE=Release \
  201. -DgRPC_INSTALL=ON \
  202. -DgRPC_SSL_PROVIDER=package \
  203. -DgRPC_BUILD_TESTS=OFF \
  204. -DCMAKE_INSTALL_PREFIX=$HOME/.local $HOME/downloads/grpc \
  205. && make -j \
  206. && make install"
  207. # https://github.com/grpc/grpc-web#code-generator-plugin
  208. ENV GRPC_WEB_PLUGIN_VERSION "1.4.2"
  209. RUN wget -q -O $HOME/.local/bin/protoc-gen-grpc-web \
  210. https://github.com/grpc/grpc-web/releases/download/${GRPC_WEB_PLUGIN_VERSION}/protoc-gen-grpc-web-${GRPC_WEB_PLUGIN_VERSION}-linux-x86_64
  211. RUN chmod +x $HOME/.local/bin/protoc-gen-grpc-web
  212. # https://github.com/protocolbuffers/protobuf-javascript
  213. ENV GRPC_JS_PLUGIN_VERSION "3.21.2"
  214. RUN wget -q -P $HOME/downloads \
  215. https://github.com/protocolbuffers/protobuf-javascript/releases/download/v${GRPC_JS_PLUGIN_VERSION}/protobuf-javascript-${GRPC_JS_PLUGIN_VERSION}-linux-x86_64.tar.gz
  216. RUN mkdir -p $HOME/build/protobuf-javascript \
  217. && cd $HOME/build/protobuf-javascript \
  218. && tar xf $HOME/downloads/protobuf-javascript-${GRPC_JS_PLUGIN_VERSION}-linux-x86_64.tar.gz \
  219. && cp bin/protoc-gen-js $HOME/.local/bin/
  220. # https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/
  221. ENV GRPC_JAVA_PLUGIN_VERSION "1.50.2"
  222. RUN wget -q -O $HOME/.local/bin/grpc_java_plugin \
  223. https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/${GRPC_JAVA_PLUGIN_VERSION}/protoc-gen-grpc-java-${GRPC_JAVA_PLUGIN_VERSION}-linux-x86_64.exe
  224. RUN chmod +x $HOME/.local/bin/grpc_java_plugin
  225. ENV FLATBUFFERS_VERSION "v22.10.26"
  226. RUN git clone -b $FLATBUFFERS_VERSION https://github.com/google/flatbuffers.git $HOME/downloads/flatbuffers
  227. RUN zsh -c "source $HOME/.zshrc \
  228. && mkdir -pv $HOME/build/flatbuffers \
  229. && cd $HOME/build/flatbuffers \
  230. && cmake -DCMAKE_BUILD_TYPE=Release \
  231. -DCMAKE_INSTALL_PREFIX=$HOME/.local $HOME/downloads/flatbuffers \
  232. && make -j \
  233. && make install"
  234. RUN git clone https://github.com/microsoft/vcpkg.git $HOME/local/vcpkg
  235. RUN $HOME/local/vcpkg/bootstrap-vcpkg.sh
  236. RUN echo 'export VCPKG_DISABLE_METRICS=1' >> $HOME/.zshrc
  237. ADD conan /opt/conan
  238. # RUN zsh -c "source $HOME/.zshrc && cd /opt/conan && ./install.sh amd64"
  239. # RUN zsh -c "source $HOME/.zshrc && cd /opt/conan && ./install.sh arm64"
  240. # RUN zsh -c "source $HOME/.zshrc && cd /opt/conan && ./install.sh armhf"
  241. # https://opensearch.org/docs/latest/opensearch/install/tar/
  242. RUN echo "network.host: 0.0.0.0" >> /opt/opensearch-${OPENSEARCH_VERSION}/config/opensearch.yml
  243. RUN echo "discovery.type: single-node" >> /opt/opensearch-${OPENSEARCH_VERSION}/config/opensearch.yml
  244. RUN echo "plugins.security.disabled: true" >> /opt/opensearch-${OPENSEARCH_VERSION}/config/opensearch.yml
  245. RUN chown -R nobody /opt/opensearch-${OPENSEARCH_VERSION}
  246. RUN mkdir -p /var/lib/minio/data
  247. RUN chown -R nobody /var/lib/minio
  248. RUN sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/mariadb.conf.d/50-server.cnf
  249. RUN su - postgres -c "/usr/lib/postgresql/14/bin/initdb -D /var/lib/postgresql/data"
  250. RUN echo "listen_addresses = '0.0.0.0'" >> /var/lib/postgresql/data/postgresql.conf
  251. RUN cd /var/lib \
  252. && mkdir redis-s redis-1 redis-2 redis-3 redis-4 redis-5 redis-6 \
  253. && chown redis:redis redis-s redis-1 redis-2 redis-3 redis-4 redis-5 redis-6 \
  254. && chmod 750 redis-s redis-1 redis-2 redis-3 redis-4 redis-5 redis-6
  255. ADD etc/redis/* /etc/redis/
  256. RUN mkdir /run/php
  257. RUN echo "<?php phpinfo(); ?>" > /var/www/html/info.php
  258. RUN echo "daemon off;" >> /etc/nginx/nginx.conf
  259. ADD etc/nginx.conf /etc/nginx/sites-enabled/default
  260. ADD etc/envoy.yaml /etc/
  261. ADD etc/supervisor /etc/supervisor
  262. RUN echo "$(date -u +%4Y%m%d%H%M%S)" | tee /VERSION
  263. VOLUME /workspace
  264. WORKDIR /workspace
  265. CMD ["/bin/zsh", "-l"]