Dockerfile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/cpp/.devcontainer/base.Dockerfile
  4. # [Choice] Debian / Ubuntu version (use Debian 11/9, Ubuntu 18.04/21.04 on local arm64/Apple Silicon): debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
  5. ARG VARIANT=ubuntu-20.04
  6. FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}
  7. ARG DEBIAN_FRONTEND=noninteractive
  8. ENV TZ=Asian/Shanghai
  9. # hadolint ignore=DL3008
  10. RUN apt-get update \
  11. && apt-get install -y apt-transport-https apt-utils build-essential \
  12. ca-certificates ccache curl g++-multilib git gnupg \
  13. libgcc-9-dev lib32gcc-9-dev lsb-release \
  14. ninja-build ocaml ocamlbuild python2.7 \
  15. software-properties-common tree tzdata \
  16. unzip valgrind vim wget zip --no-install-recommends \
  17. && apt-get clean -y \
  18. && rm -rf /var/lib/apt/lists/*
  19. #
  20. # binaryen
  21. ARG BINARYEN_VER=111
  22. WORKDIR /opt
  23. RUN wget -c --progress=dot:giga https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VER}/binaryen-version_${BINARYEN_VER}-x86_64-linux.tar.gz \
  24. && tar xf binaryen-version_${BINARYEN_VER}-x86_64-linux.tar.gz \
  25. && ln -sf /opt/binaryen-version_111 /opt/binaryen \
  26. && rm binaryen-version_${BINARYEN_VER}-x86_64-linux.tar.gz
  27. #
  28. # CMAKE (https://apt.kitware.com/)
  29. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  30. # hadolint ignore=DL3008
  31. RUN wget --progress=dot:giga -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg > /dev/null \
  32. && echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ bionic main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null \
  33. && apt-get update \
  34. && rm /usr/share/keyrings/kitware-archive-keyring.gpg \
  35. && apt-get install -y kitware-archive-keyring --no-install-recommends \
  36. && apt-get install -y cmake --no-install-recommends \
  37. && apt-get clean -y \
  38. && rm -rf /var/lib/apt/lists/*
  39. #
  40. # install emsdk
  41. WORKDIR /opt
  42. RUN git clone https://github.com/emscripten-core/emsdk.git
  43. ARG EMSDK_VER=3.0.0
  44. WORKDIR /opt/emsdk
  45. RUN git pull \
  46. && ./emsdk install ${EMSDK_VER} \
  47. && ./emsdk activate ${EMSDK_VER} \
  48. && echo "source /opt/emsdk/emsdk_env.sh" >> /root/.bashrc
  49. #
  50. # install wasi-sdk
  51. ARG WASI_SDK_VER=19
  52. RUN wget -c --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER}/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -P /opt \
  53. && tar xf /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -C /opt \
  54. && ln -sf /opt/wasi-sdk-${WASI_SDK_VER}.0 /opt/wasi-sdk \
  55. && rm /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz
  56. #
  57. #install wabt
  58. ARG WABT_VER=1.0.29
  59. RUN wget -c --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/wabt-${WABT_VER}-ubuntu.tar.gz -P /opt \
  60. && tar xf /opt/wabt-${WABT_VER}-ubuntu.tar.gz -C /opt \
  61. && ln -sf /opt/wabt-${WABT_VER} /opt/wabt \
  62. && rm /opt/wabt-${WABT_VER}-ubuntu.tar.gz
  63. #
  64. # install bazelisk
  65. ARG BAZELISK_VER=1.12.0
  66. RUN mkdir /opt/bazelisk \
  67. && wget -c --progress=dot:giga https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VER}/bazelisk-linux-amd64 -P /opt/bazelisk \
  68. && chmod a+x /opt/bazelisk/bazelisk-linux-amd64 \
  69. && ln -fs /opt/bazelisk/bazelisk-linux-amd64 /opt/bazelisk/bazel
  70. #
  71. # install clang+llvm
  72. ARG LLVM_VER=14
  73. RUN apt-get purge -y clang-10 llvm-10 && apt autoremove -y
  74. WORKDIR /etc/apt/apt.conf.d
  75. RUN touch 99verfiy-peer.conf \
  76. && echo "Acquire { https::Verify-Peer false }" > 99verfiy-peer.conf
  77. WORKDIR /tmp
  78. RUN wget --progress=dot:giga https://apt.llvm.org/llvm.sh \
  79. && chmod a+x ./llvm.sh \
  80. && ./llvm.sh ${LLVM_VER} all
  81. #
  82. # [Optional]
  83. #
  84. # Install pip
  85. # hadolint ignore=DL3008
  86. RUN apt-get update \
  87. && apt-get install -y --reinstall python3-venv python3-pip --no-install-recommends \
  88. && apt-get clean -y \
  89. && rm -rf /var/lib/apt/lists/*
  90. #
  91. # Install required python packages
  92. # hadolint ignore=DL3013
  93. RUN python3 -m pip install --no-cache-dir --upgrade pip \
  94. && pip3 install --no-cache-dir black nose pycparser pylint
  95. #
  96. # Install github-cli. It doens't work as a feature of devcontainer.json
  97. RUN cd /tmp \
  98. && wget https://github.com/cli/cli/releases/download/v2.20.2/gh_2.20.2_linux_amd64.deb \
  99. && dpkg -i gh_2.20.2_linux_amd64.deb
  100. #
  101. # Install NodeJS
  102. RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash -
  103. RUN apt-get install -y nodejs
  104. # set path
  105. ENV PATH="/opt/bazelisk:/usr/lib/llvm-${LLVM_VER}/bin:${PATH}"
  106. ENV CC=/usr/lib/llvm-${LLVM_VER}/bin/clang CXX=/usr/lib/llvm-${LLVM_VER}/bin/clang++
  107. RUN printf "%s\n" "PS1='\n[ \u@wamr-dev-docker \W ]\n$ '" >> /root/.bashrc \
  108. && apt-get autoremove -y \
  109. && apt-get clean -y \
  110. && rm -rf /var/lib/apt/lists/* \
  111. && rm -rf /tmp/*
  112. # set workdir when container run
  113. VOLUME /workspaces
  114. WORKDIR /workspaces