Dockerfile 15 KB

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