Skip to content

Commit ebf3f2b

Browse files
committed
Localize dev. env.
- add my extensions - use privileged mode for development - copilot - intellisense -> clangd - jupyter notebook - SGX - opam
1 parent fed0fe9 commit ebf3f2b

File tree

4 files changed

+136
-83
lines changed

4 files changed

+136
-83
lines changed

.devcontainer/Dockerfile

+82-62
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/cpp/.devcontainer/base.Dockerfile
55
# [Choice] Debian / Ubuntu version (use Debian 12/11/9, Ubuntu 18.04/21.04 on local arm64/Apple Silicon): debian-12, debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
6-
ARG VARIANT=debian-12
7-
FROM mcr.microsoft.com/vscode/devcontainers/cpp:${VARIANT}
6+
ARG VARIANT=jammy
7+
FROM mcr.microsoft.com/devcontainers/base:${VARIANT}
88

99
ARG DEBIAN_FRONTEND=noninteractive
1010
ENV TZ=Asian/Shanghai
@@ -13,13 +13,11 @@ ENV TZ=Asian/Shanghai
1313
RUN apt-get update \
1414
&& apt-get upgrade -y \
1515
&& apt-get install -y apt-transport-https apt-utils build-essential \
16-
ca-certificates ccache cmake curl g++-multilib git gnupg \
17-
libgcc-12-dev lib32gcc-12-dev lsb-release \
18-
ninja-build ocaml ocamlbuild \
16+
ca-certificates ccache clang curl g++-multilib git gnupg \
17+
libgcc-12-dev lib32gcc-12-dev libstdc++-12-dev lsb-release llvm \
18+
ninja-build opam ocaml ocamlbuild \
1919
software-properties-common tree tzdata \
20-
unzip valgrind vim wget zip --no-install-recommends \
21-
&& apt-get clean -y \
22-
&& rm -rf /var/lib/apt/lists/*
20+
unzip valgrind vim wget zip --no-install-recommends
2321

2422
#
2523
# binaryen
@@ -36,12 +34,12 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
3634
# hadolint ignore=DL3008
3735
ARG CMAKE_VER=3.27.0
3836
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-Linux-x86_64.sh \
39-
-q -O /tmp/cmake-install.sh \
40-
&& chmod u+x /tmp/cmake-install.sh \
41-
&& mkdir /opt/cmake-${CMAKE_VER} \
42-
&& /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-${CMAKE_VER} \
43-
&& rm /tmp/cmake-install.sh \
44-
&& ln -s /opt/cmake-${CMAKE_VER}/bin/* /usr/local/bin
37+
-q -O /tmp/cmake-install.sh \
38+
&& chmod u+x /tmp/cmake-install.sh \
39+
&& mkdir /opt/cmake-${CMAKE_VER} \
40+
&& /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-${CMAKE_VER} \
41+
&& rm /tmp/cmake-install.sh \
42+
&& ln -s /opt/cmake-${CMAKE_VER}/bin/* /usr/local/bin
4543

4644
#
4745
# install emsdk
@@ -57,19 +55,19 @@ RUN git pull \
5755

5856
#
5957
# install wasi-sdk
60-
ARG WASI_SDK_VER=20
58+
ARG WASI_SDK_VER=21
6159
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 \
6260
&& tar xf /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -C /opt \
6361
&& ln -sf /opt/wasi-sdk-${WASI_SDK_VER}.0 /opt/wasi-sdk \
6462
&& rm /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz
6563

6664
#
6765
#install wabt
68-
ARG WABT_VER=1.0.33
69-
RUN wget -c --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/wabt-${WABT_VER}-ubuntu.tar.gz -P /opt \
70-
&& tar xf /opt/wabt-${WABT_VER}-ubuntu.tar.gz -C /opt \
66+
ARG WABT_VER=1.0.34
67+
RUN wget -c --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/wabt-${WABT_VER}-ubuntu-20.04.tar.gz -P /opt \
68+
&& tar xf /opt/wabt-${WABT_VER}-ubuntu-20.04.tar.gz -C /opt \
7169
&& ln -sf /opt/wabt-${WABT_VER} /opt/wabt \
72-
&& rm /opt/wabt-${WABT_VER}-ubuntu.tar.gz
70+
&& rm /opt/wabt-${WABT_VER}-ubuntu-20.04.tar.gz
7371

7472
#
7573
# install bazelisk
@@ -81,47 +79,18 @@ RUN mkdir /opt/bazelisk \
8179

8280
#
8381
# install clang+llvm
84-
ARG LLVM_VER=16
85-
RUN apt-get purge -y clang-14 llvm-14 && apt-get autoremove -y
86-
WORKDIR /etc/apt/apt.conf.d
87-
RUN touch 99verfiy-peer.conf \
88-
&& echo "Acquire { https::Verify-Peer false }" > 99verfiy-peer.conf
89-
90-
WORKDIR /tmp
91-
#RUN wget --progress=dot:giga https://apt.llvm.org/llvm.sh \
92-
# && chmod a+x ./llvm.sh \
93-
# && ./llvm.sh ${LLVM_VER} all
94-
95-
# Workaround due to https://github.com/llvm/llvm-project/issues/62475
96-
# hadolint ignore=DL3008
97-
RUN set -ex \
98-
&& echo "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-${LLVM_VER} main" > /etc/apt/sources.list.d/apt.llvm.org.list \
99-
&& wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc \
100-
&& apt-get update \
101-
&& apt-get install -y \
102-
clang-${LLVM_VER} lldb-${LLVM_VER} lld-${LLVM_VER} clangd-${LLVM_VER} clang-tidy-${LLVM_VER} clang-format-${LLVM_VER} clang-tools-${LLVM_VER} \
103-
llvm-${LLVM_VER}-dev lld-${LLVM_VER} lldb-${LLVM_VER} llvm-${LLVM_VER}-tools libomp-${LLVM_VER}-dev libc++-${LLVM_VER}-dev libc++abi-${LLVM_VER}-dev \
104-
libclang-common-${LLVM_VER}-dev libclang-${LLVM_VER}-dev libclang-cpp${LLVM_VER}-dev libunwind-${LLVM_VER}-dev \
105-
libclang-rt-${LLVM_VER}-dev libpolly-${LLVM_VER}-dev --no-install-recommends \
106-
&& apt-get clean -y \
107-
&& rm -rf /var/lib/apt/lists/*
108-
109-
#
110-
# [Optional]
82+
ARG LLVM_VER=15.0.6
83+
RUN wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VER}/clang+llvm-${LLVM_VER}-x86_64-linux-gnu-ubuntu-18.04.tar.xz
84+
RUN tar -xvf clang+llvm-${LLVM_VER}-x86_64-linux-gnu-ubuntu-18.04.tar.xz \
85+
&& mv clang+llvm-${LLVM_VER}-x86_64-linux-gnu-ubuntu-18.04 llvm-${LLVM_VER} \
86+
&& rm clang+llvm-${LLVM_VER}-x86_64-linux-gnu-ubuntu-18.04.tar.xz
11187

11288
#
11389
# Install pip
11490
# hadolint ignore=DL3008
11591
RUN apt-get update \
11692
&& apt-get install -y --reinstall python3-venv python3-pip --no-install-recommends \
117-
&& apt-get clean -y \
118-
&& rm -rf /var/lib/apt/lists/*
119-
120-
#
121-
# Install required python packages
122-
# hadolint ignore=DL3013
123-
RUN python3 -m pip install --no-cache-dir --break-system-packages --upgrade pip \
124-
&& pip3 install --no-cache-dir --break-system-packages black nose pycparser pylint
93+
&& pip install --no-cache-dir --upgrade pip
12594

12695
#
12796
# Install github-cli. It doens't work as a feature of devcontainer.json
@@ -132,19 +101,70 @@ RUN wget -q https://github.com/cli/cli/releases/download/v${GH_CLI_VER}/gh_${GH_
132101

133102
#
134103
# Install NodeJS
135-
RUN wget -qO- https://deb.nodesource.com/setup_20.x | bash -
136-
# hadolint ignore=DL3008
137-
RUN apt-get install -y nodejs --no-install-recommends
104+
# RUN wget -qO- https://deb.nodesource.com/setup_20.x | bash -
105+
# # hadolint ignore=DL3008
106+
# RUN apt-get install -y nodejs --no-install-recommends
107+
108+
#
109+
# SGX setup
110+
RUN mkdir -p /opt/intel
111+
112+
WORKDIR /opt/intel
113+
RUN wget -q https://download.01.org/intel-sgx/sgx-linux/2.21/distro/ubuntu22.04-server/sgx_linux_x64_sdk_2.21.100.1.bin \
114+
&& chmod +x sgx_linux_x64_sdk_2.21.100.1.bin
115+
RUN echo 'yes' | ./sgx_linux_x64_sdk_2.21.100.1.bin
116+
RUN source /opt/intel/sgxsdk/environment
117+
118+
RUN echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu jammy main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list \
119+
&& wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | apt-key add -
120+
121+
RUN apt update \
122+
&& apt install -y libsgx-launch libsgx-urts
123+
124+
#
125+
# Install wasm-tools from binary releasing
126+
ARG WASM_TOOLS_VER=1.201.0
127+
WORKDIR /opt
128+
RUN wget -c --progress=dot:giga https://github.com/bytecodealliance/wasm-tools/releases/download/v${WASM_TOOLS_VER}/wasm-tools-${WASM_TOOLS_VER}-x86_64-linux.tar.gz
129+
RUN tar xzf wasm-tools-${WASM_TOOLS_VER}-x86_64-linux.tar.gz \
130+
&& rm wasm-tools-${WASM_TOOLS_VER}-x86_64-linux.tar.gz \
131+
&& ln -sf /opt/wasm-tools-${WASM_TOOLS_VER}-x86_64-linux/wasm-tools /usr/bin/wasm-tools
132+
133+
#
134+
# Install wit-bindgen
135+
ARG WIT_BINDGEN_VER=0.21.0
136+
WORKDIR /opt
137+
RUN wget -c --progress=dot:giga https://github.com/bytecodealliance/wit-bindgen/releases/download/v${WIT_BINDGEN_VER}/wit-bindgen-${WIT_BINDGEN_VER}-x86_64-linux.tar.gz
138+
RUN tar xzf wit-bindgen-${WIT_BINDGEN_VER}-x86_64-linux.tar.gz \
139+
&& rm wit-bindgen-${WIT_BINDGEN_VER}-x86_64-linux.tar.gz
140+
141+
#
142+
# Install perf
143+
ARG KERNEL_VER=5.15.0-97
144+
RUN apt update \
145+
&& apt-get install -y linux-tools-generic linux-tools-${KERNEL_VER}-generic \
146+
&& apt-get install -y linux-headers-${KERNEL_VER}
147+
148+
#
149+
# Install extra clang tools and lldb
150+
RUN apt update \
151+
&& apt install -y clang-tools clang-tidy clang-format clangd \
152+
&& apt install -y lldb python3-lldb
153+
154+
#
155+
# Install Rust
156+
ENV CARGO_HOME=/home/vscode/.cargo
157+
ENV RUSTUP_HOME=/home/vscode/.rustup
158+
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y
159+
ENV PATH="${CARGO_HOME}/bin:${PATH}"
138160

139161
# set path
140-
ENV PATH="/opt/bazelisk:/usr/lib/llvm-${LLVM_VER}/bin:${PATH}"
141-
ENV CC=/usr/lib/llvm-${LLVM_VER}/bin/clang CXX=/usr/lib/llvm-${LLVM_VER}/bin/clang++
142-
RUN printf "%s\n" "PS1='\n[ \u@wamr-dev-docker \W ]\n$ '" >> /root/.bashrc \
143-
&& apt-get autoremove -y \
162+
ENV PATH="/home/vscode/.opam/default/bin:/opt/bazelisk:/usr/lib/llvm-${LLVM_VER}/bin:${PATH}"
163+
# clean
164+
RUN apt-get autoremove -y \
144165
&& apt-get clean -y \
145166
&& rm -rf /var/lib/apt/lists/* \
146167
&& rm -rf /tmp/*
147168

148169
# set workdir when container run
149-
VOLUME /workspaces
150170
WORKDIR /workspaces

.devcontainer/devcontainer.json

+23-21
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,44 @@
99
// Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-12, debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
1010
// Use Debian 12, Debian 11, Debian 9, Ubuntu 18.04 or Ubuntu 21.04 on local arm64/Apple Silicon
1111
"args": {
12-
"BINARYEN_VER": "114",
13-
"BAZELISK_VER": "1.17.0",
12+
"BAZELISK_VER": "1.19.0",
13+
"BINARYEN_VER": "117",
1414
"CMAKE_VER": "3.27.0",
1515
"EMSDK_VER": "3.1.43",
16-
"GH_CLI_VER": "2.32.0",
17-
"LLVM_VER": "16",
18-
"VARIANT": "debian-12",
19-
"WASI_SDK_VER": "20",
20-
"WABT_VER": "1.0.33"
16+
"GH_CLI_VER": "2.50.0",
17+
"LLVM_VER": "15.0.6",
18+
"WABT_VER": "1.0.35",
19+
"WASI_SDK_VER": "22",
20+
"WASM_TOOLS_VER": "1.209.0",
21+
"WIT_BINDGEN_VER": "0.26.0",
22+
"VARIANT": "jammy",
2123
}
2224
},
23-
"runArgs": [
24-
"--cap-add=SYS_PTRACE",
25-
"--security-opt",
26-
"seccomp=unconfined"
27-
],
25+
"privileged": true,
2826
// Configure tool-specific properties.
2927
"customizations": {
3028
// Configure properties specific to VS Code.
3129
"vscode": {
32-
// Set *default* container specific settings.json values on container create.
33-
"settings": {},
3430
// Add the IDs of extensions you want installed when the container is created.
3531
"extensions": [
36-
"dtsvet.vscode-wasm",
37-
"llvm-vs-code-extensions.vscode-clangd",
32+
"esbenp.prettier-vscode",
33+
"ms-python.debugpy",
3834
"ms-python.python",
39-
"ms-python.vscode-pylance",
40-
"ms-vscode.cmake-tools"
35+
"ms-python.black-formatter",
36+
"ms-toolsai.jupyter",
37+
"ms-vscode.cpptools",
38+
"streetsidesoftware.code-spell-checker",
39+
"vadimcn.vscode-lldb",
4140
]
4241
}
4342
},
4443
// Use 'forwardPorts' to make a list of ports inside the container available locally.
4544
// "forwardPorts": [],
4645
// Use 'postCreateCommand' to run commands after the container is created.
47-
"postCreateCommand": "curl https://sh.rustup.rs -sSf | bash -s -- -y",
46+
"postCreateCommand": "bash -euvx .devcontainer/finalize.sh",
4847
// Comment out this line to run as root instead.
49-
"remoteUser": "vscode"
50-
}
48+
"remoteUser": "vscode",
49+
"mounts": [
50+
"source=/mnt/workspace/SDF,target=/SDF,type=bind"
51+
]
52+
}

.devcontainer/finalize.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash -euvx
2+
3+
printf "Running 'postCreateCommand' Script ...\n"
4+
5+
printf "Installing Rust Targets\n"
6+
sudo chown -R vscode ${CARGO_HOME}
7+
sudo chown -R vscode ${RUSTUP_HOME}
8+
# rustup update stable --no-self-update
9+
# rustup default stable
10+
rustup target add wasm32-unknown-unknown
11+
rustup target add wasm32-wasi
12+
rustup component add clippy
13+
rustup component add rustfmt
14+
15+
printf "Installing Python Dependencies\n"
16+
pip install -r .devcontainer/requirements.txt
17+
18+
printf "Installing NPM Dependencies\n"
19+
20+
printf "Installing Ocaml stuff\n"
21+
opam init --yes --shell-setup
22+
eval $(opam env --switch=default)
23+
opam install --yes dune menhir
24+
25+
printf "'postCreateCommand' Script Done\n"

.devcontainer/requirements.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
black
2+
jupyter
3+
nose
4+
numpy
5+
pycparser
6+
pylint

0 commit comments

Comments
 (0)