Dockerfile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. FROM ubuntu:18.04 as builder
  2. #
  3. # install clang and llvm
  4. COPY llvm.sh /tmp
  5. RUN apt update \
  6. && apt install -y lsb-release wget software-properties-common build-essential \
  7. && cd /tmp \
  8. && chmod a+x llvm.sh \
  9. && ./llvm.sh 11
  10. ARG WASI_SDK_VER=11.0
  11. ARG WABT_VER=1.0.19
  12. ARG CMAKE_VER=3.16.2
  13. ARG BINARYEN_VER=version_97
  14. ARG BAZEL_VER=3.7.0
  15. #
  16. # install wasi-sdk
  17. ARG WASI_SDK_FILE="wasi-sdk-${WASI_SDK_VER}-linux.tar.gz"
  18. COPY ${WASI_SDK_FILE} /opt
  19. RUN cd /opt \
  20. && tar zxf ${WASI_SDK_FILE} \
  21. && rm ${WASI_SDK_FILE} \
  22. && ln -sf /opt/wasi-sdk-${WASI_SDK_VER} /opt/wasi-sdk \
  23. && ln -sf /opt/wasi-sdk/lib/clang/10.0.0/lib/wasi/ /usr/lib/llvm-11/lib/clang/11.0.1/lib/
  24. #
  25. # install wabt
  26. ARG WABT_FILE="wabt-${WABT_VER}-ubuntu.tar.gz"
  27. COPY ${WABT_FILE} /opt
  28. RUN cd /opt \
  29. && tar zxf ${WABT_FILE} \
  30. && rm ${WABT_FILE} \
  31. && ln -sf /opt/wabt-${WABT_VER} /opt/wabt
  32. #
  33. # install cmake
  34. ARG CMAKE_FILE="cmake-${CMAKE_VER}-Linux-x86_64.sh"
  35. COPY ${CMAKE_FILE} /tmp
  36. RUN cd /tmp \
  37. && chmod a+x ${CMAKE_FILE} \
  38. && mkdir /opt/cmake \
  39. && ./${CMAKE_FILE} --prefix=/opt/cmake --skip-license \
  40. && ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake
  41. #
  42. # install tools
  43. RUN apt update \
  44. && apt install -y git tree
  45. #
  46. # install emsdk
  47. RUN cd /opt \
  48. && git clone https://github.com/emscripten-core/emsdk.git \
  49. && cd emsdk \
  50. && git pull \
  51. && ./emsdk install latest \
  52. && ./emsdk activate latest \
  53. && echo "source /opt/emsdk/emsdk_env.sh" >> /root/.bashrc
  54. #
  55. # install binaryen
  56. ARG BINARYEN_FILE="binaryen-${BINARYEN_VER}-x86_64-linux.tar.gz"
  57. COPY ${BINARYEN_FILE} /opt
  58. RUN cd /opt \
  59. && tar zxf ${BINARYEN_FILE} \
  60. && rm ${BINARYEN_FILE} \
  61. && ln -sf /opt/binaryen-${BINARYEN_VER} /opt/binaryen
  62. RUN apt install -y unzip zip
  63. #
  64. # install bazel
  65. ARG BAZEL_FILE=bazel-${BAZEL_VER}-installer-linux-x86_64.sh
  66. COPY ${BAZEL_FILE} /tmp
  67. RUN cd /tmp \
  68. && chmod a+x ${BAZEL_FILE} \
  69. && ./${BAZEL_FILE}
  70. #
  71. # Clean up
  72. RUN apt-get autoremove -y \
  73. && apt-get clean -y \
  74. && rm -rf /var/lib/apt/lists/* \
  75. && rm -rf /tmp/*
  76. VOLUME /data
  77. #
  78. #
  79. RUN touch /build.sh \
  80. && echo "\
  81. #!/bin/bash \n\
  82. if [[ -d /data/project/build ]]; then \n\
  83. rm -r /data/project/build \n\
  84. fi \n\
  85. mkdir /data/project/build \n\
  86. cd /data/project/build \n\
  87. source /opt/emsdk/emsdk_env.sh \n\
  88. cmake .. \n\
  89. make \n\
  90. cd - > /dev/null" > /build.sh \
  91. && chmod a+x /build.sh