From 0efaef2a7a1310ecf3320cb72bac712561a44dc1 Mon Sep 17 00:00:00 2001 From: liam Date: Fri, 1 Jul 2022 03:03:38 +0800 Subject: [PATCH] add a dev container to WAMR repo - in vscode, open the workspace in container with *Remote-Containers* - in codespaces, codespaces will create a container --- .devcontainer/Dockerfile | 90 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 41 +++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..c7a1ec4a36 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,90 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/cpp/.devcontainer/base.Dockerfile +# [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 +ARG VARIANT=ubuntu-20.04 +FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT} + +ARG DEBIAN_FRONTEND=noninteractive +ENV TZ=Asian/Shanghai + +RUN apt update \ + && apt install -y apt-transport-https apt-utils build-essential \ + ca-certificates curl g++-multilib git gnupg \ + libgcc-9-dev lib32gcc-9-dev lsb-release \ + ninja-build ocaml ocamlbuild python2.7 \ + software-properties-common tree tzdata \ + unzip valgrind vim wget zip + +# +# CMAKE (https://apt.kitware.com/) +RUN wget -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 \ + && 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 \ + && apt update \ + && rm /usr/share/keyrings/kitware-archive-keyring.gpg \ + && apt install -y kitware-archive-keyring \ + && apt install -y cmake + +# +# install emsdk +RUN cd /opt \ + && git clone https://github.com/emscripten-core/emsdk.git +RUN cd /opt/emsdk \ + && git pull \ + && ./emsdk install 2.0.26 \ + && ./emsdk activate 2.0.26 \ + && echo "source /opt/emsdk/emsdk_env.sh" >> /root/.bashrc + +# +# install wasi-sdk +ARG WASI_SDK_VER=16 +RUN wget -c https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER}/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -P /opt +RUN tar xf /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -C /opt \ + && ln -fs /opt/wasi-sdk-${WASI_SDK_VER}.0 /opt/wasi-sdk +RUN rm /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz + +# +#install wabt +ARG WABT_VER=1.0.29 +RUN wget -c https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/wabt-${WABT_VER}-ubuntu.tar.gz -P /opt +RUN tar xf /opt/wabt-${WABT_VER}-ubuntu.tar.gz -C /opt \ + && ln -fs /opt/wabt-${WABT_VER} /opt/wabt +RUN rm /opt/wabt-${WABT_VER}-ubuntu.tar.gz + +# +# install bazelisk +ARG BAZELISK_VER=1.12.0 +RUN mkdir /opt/bazelisk +RUN wget -c https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VER}/bazelisk-linux-amd64 -P /opt/bazelisk +RUN chmod a+x /opt/bazelisk/bazelisk-linux-amd64 \ + && ln -fs /opt/bazelisk/bazelisk-linux-amd64 /opt/bazelisk/bazel + +# +# install clang+llvm +RUN cd /etc/apt/apt.conf.d \ + && touch 99verfiy-peer.conf \ + && echo "Acquire { https::Verify-Peer false }" > 99verfiy-peer.conf +RUN cd /tmp \ + && wget https://apt.llvm.org/llvm.sh \ + && chmod a+x ./llvm.sh +RUN /tmp/llvm.sh 12 all + +# +# [Optional] + +# +# Install pip +RUN apt update && apt install -y --reinstall python3-venv python3-pip +RUN python3 -m pip install --upgrade pip + +# set path +ENV PATH "/opt/bazelisk:/opt/clang-llvm/bin:${PATH}" +RUN echo "export PATH=/opt/bazelisk:/opt/clang-llvm/bin:${PATH}" >> /root/.bashrc + +# +# PS +RUN echo "PS1='\n[ \u@wamr-dev-docker \W ]\n$ '" >> /root/.bashrc + +# Clean up +RUN apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/* diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..7f8efefded --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,41 @@ +// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/cpp +{ + "name": "WAMR-Dev", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04 + // Use Debian 11, Debian 9, Ubuntu 18.04 or Ubuntu 21.04 on local arm64/Apple Silicon + "args": { "VARIANT": "ubuntu-20.04" } + }, + "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": {}, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "dtsvet.vscode-wasm", + "esbenp.prettier-vscode", + "ms-python.python", + "ms-python.vscode-pylance", + "ms-vscode.cmake-tools", + "ms-vscode.cpptools", + "twxs.cmake" + ] + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "curl https://sh.rustup.rs -sSf | bash -s -- -y", + + // Comment out this line to run as root instead. + "remoteUser": "vscode" +}