Dockerfile 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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 \
  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 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 echo 'set-option -g history-limit 102400' > $HOME/.tmux.conf
  78. RUN echo 'set-option -g default-shell "/bin/zsh"' >> $HOME/.tmux.conf
  79. RUN zsh -c "source $HOME/.zshrc && pip3 install --user cmake"
  80. RUN zsh -c "source $HOME/.zshrc \
  81. && pip3 install --user ansible paramiko"
  82. RUN echo 'export ANSIBLE_HOST_KEY_CHECKING=False' >> $HOME/.zshrc
  83. RUN echo 'alias peony="ANSIBLE_LOG_PATH=$HOME/tmp/$(date +%Y%m%d%H%M%S).log ansible-playbook"' >> $HOME/.zshrc
  84. RUN zsh -c "source $HOME/.zshrc \
  85. && pip3 install --user conan \
  86. && conan profile new default --detect \
  87. && conan profile update settings.compiler.libcxx=libstdc++11 default"
  88. RUN zsh -c "source $HOME/.zshrc && pip3 install --user supervisor"
  89. # https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos
  90. RUN wget -q -O $HOME/downloads/composer https://getcomposer.org/installer
  91. RUN cd $HOME/downloads \
  92. && php composer \
  93. && mv composer.phar $HOME/.local/bin/composer
  94. # https://github.com/richfelker/musl-cross-make
  95. RUN git clone https://github.com/richfelker/musl-cross-make.git $HOME/build/musl-cross-make
  96. RUN cd $HOME/build/musl-cross-make \
  97. && echo "TARGET=x86_64-linux-musl" > config.mak \
  98. && echo "OUTPUT=/opt/crosstools" >> config.mak \
  99. && make \
  100. && make install
  101. RUN cd $HOME/build/musl-cross-make \
  102. && echo "TARGET=aarch64-linux-musl" > config.mak \
  103. && echo "OUTPUT=/opt/crosstools" >> config.mak \
  104. && make \
  105. && make install
  106. RUN cd $HOME/build/musl-cross-make \
  107. && echo "TARGET=arm-linux-musleabihf" > config.mak \
  108. && echo "OUTPUT=/opt/crosstools" >> config.mak \
  109. && make \
  110. && make install
  111. ENV BAZEL_VERSION "v1.14.0"
  112. RUN wget -q -O $HOME/.local/bin/bazel \
  113. https://github.com/bazelbuild/bazelisk/releases/download/${BAZEL_VERSION}/bazelisk-linux-amd64
  114. RUN chmod +x $HOME/.local/bin/bazel
  115. # https://github.com/rbenv/rbenv
  116. RUN git clone https://github.com/rbenv/rbenv.git $HOME/.rbenv
  117. RUN cd $HOME/.rbenv && src/configure && make -C src
  118. RUN echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $HOME/.zshrc
  119. RUN echo 'eval "$(rbenv init -)"' >> $HOME/.zshrc
  120. RUN git clone https://github.com/rbenv/ruby-build.git $HOME/.rbenv/plugins/ruby-build
  121. RUN git clone https://github.com/rbenv/rbenv-vars.git $HOME/.rbenv/plugins/rbenv-vars
  122. ENV RUBY_VERSION "3.1.2"
  123. RUN apt install -y libssl-dev
  124. RUN zsh -c "source $HOME/.zshrc \
  125. && rbenv install ${RUBY_VERSION} \
  126. && rbenv global ${RUBY_VERSION} \
  127. && gem install bundler"
  128. ENV GO_VERSION "1.19.2"
  129. RUN wget -q -P $HOME/downloads https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz
  130. RUN tar xf $HOME/downloads/go${GO_VERSION}.linux-amd64.tar.gz -C $HOME/local
  131. RUN echo 'export GOROOT=$HOME/local/go' >> $HOME/.zshrc
  132. RUN echo 'export PATH=$GOROOT/bin:$PATH' >> $HOME/.zshrc
  133. RUN echo 'export GOPATH=$HOME/go' >> $HOME/.zshrc
  134. ENV JDK_VERSION "19.0.1-open"
  135. RUN curl -s "https://get.sdkman.io" | zsh
  136. RUN sed -i -e 's/sdkman_auto_answer=false/sdkman_auto_answer=true/g' $HOME/.sdkman/etc/config
  137. RUN zsh -c "source $HOME/.zshrc \
  138. && sdk install java ${JDK_VERSION} \
  139. && sdk install maven \
  140. && sdk install gradle"
  141. # https://github.com/nvm-sh/nvm
  142. ENV NVM_VERSION "v0.39.2"
  143. RUN git clone -b ${NVM_VERSION} https://github.com/nvm-sh/nvm.git $HOME/.nvm
  144. RUN echo 'export NVM_DIR="$HOME/.nvm"' >> $HOME/.zshrc
  145. RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $HOME/.zshrc
  146. RUN echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> $HOME/.zshrc
  147. RUN zsh -c "source $HOME/.zshrc \
  148. && nvm install node \
  149. && nvm use node \
  150. && npm i yarn -g"
  151. RUN zsh -c "source $HOME/.zshrc \
  152. && nvm install --lts \
  153. && nvm use --lts \
  154. && npm i yarn -g"
  155. # https://stackoverflow.com/questions/37324519/node-sass-does-not-yet-support-your-current-environment-linux-64-bit-with-false
  156. RUN zsh -c "source $HOME/.zshrc \
  157. && nvm install lts/fermium \
  158. && nvm use lts/fermium \
  159. && npm i yarn -g"
  160. RUN echo 'export PATH=$HOME/.yarn/bin:$PATH' >> $HOME/.zshrc
  161. # https://www.rust-lang.org/tools/install
  162. RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
  163. # https://doc.rust-lang.org/nightly/rustc/platform-support.html
  164. RUN zsh -c "source $HOME/.cargo/env \
  165. && rustup component add rust-analyzer \
  166. && rustup target add armv7-unknown-linux-gnueabihf \
  167. && rustup target add aarch64-unknown-linux-gnu \
  168. && rustup target add x86_64-unknown-linux-musl \
  169. && rustup target add aarch64-unknown-linux-musl"
  170. RUN apt install -y libpq-dev libmysqlclient-dev libsqlite3-dev
  171. RUN zsh -c "source $HOME/.zshrc \
  172. && cargo install diesel_cli \
  173. && cargo install --locked cargo-outdated \
  174. && cargo install mdbook"
  175. # https://opensearch.org/downloads.html#opensearch
  176. ENV OPENSEARCH_VERSION "2.3.0"
  177. RUN wget -q -P $HOME/downloads \
  178. https://artifacts.opensearch.org/releases/bundle/opensearch/${OPENSEARCH_VERSION}/opensearch-${OPENSEARCH_VERSION}-linux-x64.tar.gz
  179. RUN tar xf $HOME/downloads/opensearch-${OPENSEARCH_VERSION}-linux-x64.tar.gz -C /opt
  180. # https://min.io/download#/linux
  181. RUN wget -q -O /usr/bin/minio \
  182. https://dl.min.io/server/minio/release/linux-amd64/minio
  183. RUN chmod +x /usr/bin/minio
  184. ENV GRPC_VERSION "v1.50.1"
  185. RUN git clone --recurse-submodules -b $GRPC_VERSION https://github.com/grpc/grpc.git $HOME/downloads/grpc
  186. RUN zsh -c "source $HOME/.zshrc \
  187. && mkdir -pv $HOME/build/grpc \
  188. && cd $HOME/build/grpc \
  189. && cmake -DCMAKE_BUILD_TYPE=Release \
  190. -DgRPC_INSTALL=ON \
  191. -DgRPC_SSL_PROVIDER=package \
  192. -DgRPC_BUILD_TESTS=OFF \
  193. -DCMAKE_INSTALL_PREFIX=$HOME/.local $HOME/downloads/grpc \
  194. && make -j \
  195. && make install"
  196. # https://github.com/grpc/grpc-web#code-generator-plugin
  197. ENV GRPC_WEB_PLUGIN_VERSION "1.4.2"
  198. RUN wget -q -O $HOME/.local/bin/protoc-gen-grpc-web \
  199. https://github.com/grpc/grpc-web/releases/download/${GRPC_WEB_PLUGIN_VERSION}/protoc-gen-grpc-web-${GRPC_WEB_PLUGIN_VERSION}-linux-x86_64
  200. RUN chmod +x $HOME/.local/bin/protoc-gen-grpc-web
  201. # https://github.com/protocolbuffers/protobuf-javascript
  202. ENV GRPC_JS_PLUGIN_VERSION "3.21.2"
  203. RUN wget -q -P $HOME/downloads \
  204. https://github.com/protocolbuffers/protobuf-javascript/releases/download/v${GRPC_JS_PLUGIN_VERSION}/protobuf-javascript-${GRPC_JS_PLUGIN_VERSION}-linux-x86_64.tar.gz
  205. RUN mkdir -p $HOME/build/protobuf-javascript \
  206. && cd $HOME/build/protobuf-javascript \
  207. && tar xf $HOME/downloads/protobuf-javascript-${GRPC_JS_PLUGIN_VERSION}-linux-x86_64.tar.gz \
  208. && cp bin/protoc-gen-js $HOME/.local/bin/
  209. # https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/
  210. ENV GRPC_JAVA_PLUGIN_VERSION "1.50.2"
  211. RUN wget -q -O $HOME/.local/bin/grpc_java_plugin \
  212. 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
  213. RUN chmod +x $HOME/.local/bin/grpc_java_plugin
  214. ENV FLATBUFFERS_VERSION "v22.10.26"
  215. RUN git clone -b $FLATBUFFERS_VERSION https://github.com/google/flatbuffers.git $HOME/downloads/flatbuffers
  216. RUN zsh -c "source $HOME/.zshrc \
  217. && mkdir -pv $HOME/build/flatbuffers \
  218. && cd $HOME/build/flatbuffers \
  219. && cmake -DCMAKE_BUILD_TYPE=Release \
  220. -DCMAKE_INSTALL_PREFIX=$HOME/.local $HOME/downloads/flatbuffers \
  221. && make -j \
  222. && make install"
  223. RUN git clone https://github.com/microsoft/vcpkg.git $HOME/local/vcpkg
  224. RUN $HOME/local/vcpkg/bootstrap-vcpkg.sh
  225. RUN echo 'export VCPKG_DISABLE_METRICS=1' >> $HOME/.zshrc
  226. ADD conan /opt/conan
  227. # RUN zsh -c "source $HOME/.zshrc && cd /opt/conan && ./install.sh amd64"
  228. # RUN zsh -c "source $HOME/.zshrc && cd /opt/conan && ./install.sh arm64"
  229. # RUN zsh -c "source $HOME/.zshrc && cd /opt/conan && ./install.sh armhf"
  230. # https://opensearch.org/docs/latest/opensearch/install/tar/
  231. RUN echo "network.host: 0.0.0.0" >> /opt/opensearch-${OPENSEARCH_VERSION}/config/opensearch.yml
  232. RUN echo "discovery.type: single-node" >> /opt/opensearch-${OPENSEARCH_VERSION}/config/opensearch.yml
  233. RUN echo "plugins.security.disabled: true" >> /opt/opensearch-${OPENSEARCH_VERSION}/config/opensearch.yml
  234. RUN chown -R nobody /opt/opensearch-${OPENSEARCH_VERSION}
  235. RUN mkdir -p /var/lib/minio/data
  236. RUN chown -R nobody /var/lib/minio
  237. RUN sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/mariadb.conf.d/50-server.cnf
  238. RUN su - postgres -c "/usr/lib/postgresql/14/bin/initdb -D /var/lib/postgresql/data"
  239. RUN echo "listen_addresses = '0.0.0.0'" >> /var/lib/postgresql/data/postgresql.conf
  240. RUN cd /var/lib \
  241. && mkdir redis-s redis-1 redis-2 redis-3 redis-4 redis-5 redis-6 \
  242. && chown redis:redis redis-s redis-1 redis-2 redis-3 redis-4 redis-5 redis-6 \
  243. && chmod 750 redis-s redis-1 redis-2 redis-3 redis-4 redis-5 redis-6
  244. ADD etc/redis/* /etc/redis/
  245. RUN mkdir /run/php
  246. RUN echo "<?php phpinfo(); ?>" > /var/www/html/info.php
  247. RUN echo "daemon off;" >> /etc/nginx/nginx.conf
  248. ADD etc/nginx.conf /etc/nginx/sites-enabled/default
  249. ADD etc/envoy.yaml /etc/
  250. ADD etc/supervisor /etc/supervisor
  251. RUN echo "$(date -u +%4Y%m%d%H%M%S)" | tee /VERSION
  252. VOLUME /workspace
  253. WORKDIR /workspace
  254. CMD ["/bin/zsh", "-l"]