Dockerfile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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 \
  22. clang clang-format lldb lld \
  23. build-essential cmake pkg-config libtool automake autoconf binutils cpio mold \
  24. debhelper bison flex ninja-build \
  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-redis php-amqp \
  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. # https://apt.llvm.org/
  37. ENV CLANG_VERSION=14
  38. 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
  39. RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
  40. RUN apt update
  41. RUN apt install -y clang-${CLANG_VERSION} \
  42. clangd-${CLANG_VERSION} clang-tools-${CLANG_VERSION} clang-format-${CLANG_VERSION} \
  43. lldb-${CLANG_VERSION} lld-${CLANG_VERSION}
  44. RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${CLANG_VERSION} 100
  45. RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${CLANG_VERSION} 100
  46. RUN update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-${CLANG_VERSION} 100
  47. RUN update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-${CLANG_VERSION} 100
  48. RUN update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${CLANG_VERSION} 100
  49. # https://www.envoyproxy.io/docs/envoy/latest/start/install#install-envoy-on-ubuntu-linux
  50. RUN curl -sL 'https://deb.dl.getenvoy.io/public/gpg.8115BA8E629CC074.key' | gpg --dearmor -o /usr/share/keyrings/getenvoy-keyring.gpg
  51. RUN echo a077cb587a1b622e03aa4bf2f3689de14658a9497a9af2c427bba5f4cc3c4723 /usr/share/keyrings/getenvoy-keyring.gpg | sha256sum --check
  52. 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
  53. RUN apt update
  54. RUN apt install -y getenvoy-envoy
  55. # https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/
  56. # RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
  57. # RUN echo "deb [arch=amd64,arm64] 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
  58. # RUN apt update
  59. # RUN apt install -y mongodb
  60. RUN apt -y autoremove
  61. RUN apt -y clean
  62. RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
  63. RUN locale-gen
  64. RUN update-locale LANG=en_US.UTF-8
  65. RUN update-alternatives --set editor /usr/bin/vim.basic
  66. RUN mkdir -p $HOME/downloads $HOME/build $HOME/local $HOME/tmp
  67. # https://github.com/ohmyzsh/ohmyzsh
  68. RUN git clone https://github.com/ohmyzsh/ohmyzsh.git $HOME/.oh-my-zsh
  69. RUN cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc
  70. RUN echo 'source $HOME/.profile' >> $HOME/.zshrc
  71. RUN echo 'export LANG=en_US.UTF-8' >> $HOME/.profile
  72. RUN echo 'export LC_ALL=en_US.UTF-8' >> $HOME/.profile
  73. RUN git config --global core.quotepath false
  74. RUN git config --global http.version HTTP/1.1
  75. RUN git config --global pull.rebase false
  76. RUN echo 'set-option -g history-limit 102400' > $HOME/.tmux.conf
  77. RUN sh -c ". $HOME/.profile && pip3 install --user cmake"
  78. RUN sh -c ". $HOME/.profile \
  79. && pip3 install --user ansible paramiko"
  80. RUN echo 'export ANSIBLE_HOST_KEY_CHECKING=False' >> $HOME/.profile
  81. RUN echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.profile
  82. RUN echo 'alias peony="ANSIBLE_LOG_PATH=$HOME/tmp/$(date +%Y%m%d%H%M%S).log ansible-playbook"' >> $HOME/.profile
  83. RUN sh -c ". $HOME/.profile \
  84. && pip3 install --user conan \
  85. && conan profile new default --detect \
  86. && conan profile update settings.compiler.libcxx=libstdc++11 default"
  87. RUN sh -c ". $HOME/.profile && pip3 install --user supervisor"
  88. # https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos
  89. RUN wget -q -O $HOME/.local/bin/composer https://getcomposer.org/installer
  90. RUN chmod +x $HOME/.local/bin/composer
  91. ENV BAZEL_VERSION "v1.14.0"
  92. RUN wget -q -O $HOME/.local/bin/bazel \
  93. https://github.com/bazelbuild/bazelisk/releases/download/${BAZEL_VERSION}/bazelisk-linux-amd64
  94. RUN chmod +x $HOME/.local/bin/bazel
  95. # https://github.com/nvm-sh/nvm
  96. RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | sh
  97. RUN sh -c ". $HOME/.profile \
  98. && nvm install node \
  99. && nvm use node \
  100. && npm i yarn -g"
  101. RUN sh -c ". $HOME/.profile \
  102. && nvm install --lts \
  103. && nvm use --lts \
  104. && npm i yarn -g"
  105. # https://stackoverflow.com/questions/37324519/node-sass-does-not-yet-support-your-current-environment-linux-64-bit-with-false
  106. RUN sh -c ". $HOME/.profile \
  107. && nvm install lts/fermium \
  108. && nvm use lts/fermium \
  109. && npm i yarn -g"
  110. RUN echo 'export PATH=$HOME/.yarn/bin:$PATH' >> $HOME/.profile
  111. ENV JDK_VERSION "19-open"
  112. RUN curl -s "https://get.sdkman.io" | zsh
  113. RUN sed -i -e 's/sdkman_auto_answer=false/sdkman_auto_answer=true/g' $HOME/.sdkman/etc/config
  114. RUN zsh -c "source $HOME/.zshrc \
  115. && sdk install java ${JDK_VERSION} \
  116. && sdk install maven \
  117. && sdk install gradle"
  118. # https://github.com/rbenv/rbenv
  119. RUN git clone https://github.com/rbenv/rbenv.git $HOME/.rbenv
  120. RUN cd $HOME/.rbenv && src/configure && make -C src
  121. RUN echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $HOME/.zshrc
  122. RUN echo 'eval "$(rbenv init -)"' >> $HOME/.zshrc
  123. RUN git clone https://github.com/rbenv/ruby-build.git $HOME/.rbenv/plugins/ruby-build
  124. RUN git clone https://github.com/rbenv/rbenv-vars.git $HOME/.rbenv/plugins/rbenv-vars
  125. ENV RUBY_VERSION "3.1.2"
  126. RUN apt install -y libssl-dev
  127. RUN zsh -c "source $HOME/.zshrc \
  128. && rbenv install ${RUBY_VERSION} \
  129. && rbenv global ${RUBY_VERSION} \
  130. && gem install bundler"
  131. ENV GO_VERSION "1.19.1"
  132. RUN wget -q -P $HOME/downloads https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz
  133. RUN tar xf $HOME/downloads/go${GO_VERSION}.linux-amd64.tar.gz -C $HOME/local
  134. RUN echo 'export GOROOT=$HOME/local/go' >> $HOME/.zshrc
  135. RUN echo 'export PATH=$GOROOT/bin:$PATH' >> $HOME/.zshrc
  136. RUN echo 'export GOPATH=$HOME/go' >> $HOME/.zshrc
  137. # https://www.rust-lang.org/tools/install
  138. RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
  139. # https://doc.rust-lang.org/nightly/rustc/platform-support.html
  140. RUN zsh -c "source $HOME/.cargo/env \
  141. && rustup component add rust-analyzer \
  142. && rustup target add armv7-unknown-linux-gnueabihf \
  143. && rustup target add aarch64-unknown-linux-gnu"
  144. # https://github.com/richfelker/musl-cross-make
  145. RUN git clone https://github.com/richfelker/musl-cross-make.git $HOME/build/musl-cross-make
  146. RUN cd $HOME/build/musl-cross-make \
  147. && echo "TARGET=x86_64-linux-musl" > config.mak \
  148. && echo "OUTPUT=/opt/cross" >> config.mak \
  149. && make \
  150. && make install
  151. RUN cd $HOME/build/musl-cross-make \
  152. && echo "TARGET=aarch64-linux-musl" > config.mak \
  153. && echo "OUTPUT=/opt/cross" >> config.mak \
  154. && make \
  155. && make install
  156. RUN cd $HOME/build/musl-cross-make \
  157. && echo "TARGET=arm-linux-musleabihf" > config.mak \
  158. && echo "OUTPUT=/opt/cross" >> config.mak \
  159. && make \
  160. && make install
  161. RUN apt install -y libpq-dev libmysqlclient-dev libsqlite3-dev
  162. RUN zsh -c "source $HOME/.zshrc \
  163. && cargo install diesel_cli \
  164. && cargo install --locked cargo-outdated \
  165. && cargo install mdbook"
  166. ADD conan /opt/conan
  167. RUN zsh -c "source $HOME/.zshrc && cd /opt/conan && ./install.sh amd64"
  168. RUN zsh -c "source $HOME/.zshrc && cd /opt/conan && ./install.sh arm64"
  169. RUN zsh -c "source $HOME/.zshrc && cd /opt/conan && ./install.sh armhf"
  170. ENV GRPC_VERSION "v1.49.1"
  171. RUN git clone --recurse-submodules -b $GRPC_VERSION https://github.com/grpc/grpc.git $HOME/downloads/grpc
  172. RUN zsh -c "source $HOME/.zshrc \
  173. && mkdir -pv $HOME/build/grpc \
  174. && cd $HOME/build/grpc \
  175. && cmake -DCMAKE_BUILD_TYPE=Release \
  176. -DgRPC_INSTALL=ON \
  177. -DgRPC_SSL_PROVIDER=package \
  178. -DgRPC_BUILD_TESTS=OFF \
  179. -DCMAKE_INSTALL_PREFIX=$HOME/.local $HOME/downloads/grpc \
  180. && make -j \
  181. && make install"
  182. # https://github.com/grpc/grpc-web#code-generator-plugin
  183. ENV GRPC_WEB_PLUGIN_VERSION "1.4.1"
  184. RUN wget -q -O $HOME/.local/bin/protoc-gen-grpc-web \
  185. https://github.com/grpc/grpc-web/releases/download/${GRPC_WEB_PLUGIN_VERSION}/protoc-gen-grpc-web-${GRPC_WEB_PLUGIN_VERSION}-linux-x86_64
  186. RUN chmod +x $HOME/.local/bin/protoc-gen-grpc-web
  187. # https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/
  188. ENV GRPC_JAVA_PLUGIN_VERSION "1.49.1"
  189. RUN wget -q -O $HOME/.local/bin/grpc_java_plugin \
  190. 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
  191. RUN chmod +x $HOME/.local/bin/grpc_java_plugin
  192. # https://opensearch.org/downloads.html#opensearch
  193. ENV OPENSEARCH_VERSION "2.3.0"
  194. RUN wget -q -P $HOME/downloads \
  195. https://artifacts.opensearch.org/releases/bundle/opensearch/${OPENSEARCH_VERSION}/opensearch-${OPENSEARCH_VERSION}-linux-x64.tar.gz
  196. RUN tar xf $HOME/downloads/opensearch-${OPENSEARCH_VERSION}-linux-x64.tar.gz -C /opt
  197. # https://min.io/download#/linux
  198. RUN wget -q -O /usr/bin/minio \
  199. https://dl.min.io/server/minio/release/linux-amd64/minio
  200. RUN chmod +x /usr/bin/minio
  201. # https://opensearch.org/docs/latest/opensearch/install/tar/
  202. RUN echo "network.host: 0.0.0.0" >> /opt/opensearch-${OPENSEARCH_VERSION}/config/opensearch.yml
  203. RUN echo "discovery.type: single-node" >> /opt/opensearch-${OPENSEARCH_VERSION}/config/opensearch.yml
  204. RUN echo "plugins.security.disabled: true" >> /opt/opensearch-${OPENSEARCH_VERSION}/config/opensearch.yml
  205. RUN chown -R nobody /opt/opensearch-${OPENSEARCH_VERSION}
  206. RUN mkdir -p /var/lib/minio/data
  207. RUN chown -R nobody /var/lib/minio
  208. RUN sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/mariadb.conf.d/50-server.cnf
  209. RUN su - postgres -c "/usr/lib/postgresql/14/bin/initdb -D /var/lib/postgresql/data"
  210. RUN echo "listen_addresses = '0.0.0.0'" >> /var/lib/postgresql/data/postgresql.conf
  211. RUN mkdir -p /var/lib/redis-1 /var/lib/redis-2 /var/lib/redis-3 /var/lib/redis-4 /var/lib/redis-5 /var/lib/redis-6
  212. ADD etc/redis/* /etc/redis/
  213. RUN mkdir /run/php
  214. RUN echo "<?php phpinfo(); ?>" > /var/www/html/info.php
  215. RUN echo "daemon off;" >> /etc/nginx/nginx.conf
  216. ADD etc/nginx.conf /etc/nginx/sites-enabled/default
  217. ADD etc/envoy.yaml /etc/
  218. ADD etc/supervisor /etc/supervisor
  219. RUN echo "$(date -u +%4Y%m%d%H%M%S)" | tee /VERSION
  220. VOLUME /workspace
  221. WORKDIR /workspace
  222. CMD ["/bin/zsh", "-l"]