Skip to content

Commit f71165f

Browse files
authored
update Dockerfile and devcontainer configuration (#4773)
The goal is to keep the devcontainer image minimal and its build time as fast as possible. - Remove all rarely used tools. - Change the base image to the latest template. - Synchronize the WASI-SDK and WABT versions with those used by the CI. Add libzstd for LLVM linking
1 parent 3c337dc commit f71165f

File tree

4 files changed

+40
-152
lines changed

4 files changed

+40
-152
lines changed

.devcontainer/Dockerfile

Lines changed: 21 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,43 @@
11
# Copyright (C) 2019 Intel Corporation. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4-
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/cpp/.devcontainer/base.Dockerfile
5-
# [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
4+
# hadolint global ignore=DL3008,DL3009
5+
66
ARG VARIANT=debian-12
7-
FROM mcr.microsoft.com/vscode/devcontainers/cpp:${VARIANT}
7+
FROM mcr.microsoft.com/devcontainers/cpp:${VARIANT}
88

99
ARG DEBIAN_FRONTEND=noninteractive
10-
ENV TZ=Asian/Shanghai
10+
ENV TZ=Asia/Shanghai
1111

12-
# hadolint ignore=DL3008
1312
RUN apt-get update \
14-
&& apt-get upgrade -y \
15-
&& 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 \
13+
&& apt-get upgrade -y
14+
15+
RUN apt-get install -y apt-transport-https apt-utils build-essential \
16+
ca-certificates ccache clang-format-14 curl file g++-multilib git gnupg \
17+
libgcc-12-dev lib32gcc-12-dev libzstd-dev lsb-release \
1818
ninja-build ocaml ocamlbuild \
19+
python3-venv python3-pip \
1920
software-properties-common tree tzdata \
2021
unzip valgrind vim wget zip --no-install-recommends \
2122
&& apt-get clean -y \
2223
&& rm -rf /var/lib/apt/lists/*
2324

24-
#
25-
# binaryen
26-
ARG BINARYEN_VER=114
27-
WORKDIR /opt
28-
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 \
29-
&& tar xf binaryen-version_${BINARYEN_VER}-x86_64-linux.tar.gz \
30-
&& ln -sf /opt/binaryen-version_${BINARYEN_VER} /opt/binaryen \
31-
&& rm binaryen-version_${BINARYEN_VER}-x86_64-linux.tar.gz
32-
33-
#
34-
# CMAKE (https://apt.kitware.com/)
35-
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
36-
# hadolint ignore=DL3008
37-
ARG CMAKE_VER=3.27.0
38-
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
45-
46-
#
47-
# install emsdk
4825
WORKDIR /opt
49-
RUN git clone https://github.com/emscripten-core/emsdk.git
50-
51-
ARG EMSDK_VER=3.1.43
52-
WORKDIR /opt/emsdk
53-
RUN git pull \
54-
&& ./emsdk install ${EMSDK_VER} \
55-
&& ./emsdk activate ${EMSDK_VER} \
56-
&& echo "source /opt/emsdk/emsdk_env.sh" >> /root/.bashrc
57-
58-
#
59-
# install wasi-sdk
60-
ARG WASI_SDK_VER=20
61-
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 \
62-
&& tar xf /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -C /opt \
63-
&& ln -sf /opt/wasi-sdk-${WASI_SDK_VER}.0 /opt/wasi-sdk \
64-
&& rm /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz
65-
66-
#
67-
#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 \
71-
&& ln -sf /opt/wabt-${WABT_VER} /opt/wabt \
72-
&& rm /opt/wabt-${WABT_VER}-ubuntu.tar.gz
73-
74-
#
75-
# install bazelisk
76-
ARG BAZELISK_VER=1.17.0
77-
RUN mkdir /opt/bazelisk \
78-
&& wget -c --progress=dot:giga https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VER}/bazelisk-linux-amd64 -P /opt/bazelisk \
79-
&& chmod a+x /opt/bazelisk/bazelisk-linux-amd64 \
80-
&& ln -fs /opt/bazelisk/bazelisk-linux-amd64 /opt/bazelisk/bazel
81-
82-
#
83-
# 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
8926

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
27+
ARG WASI_SDK_VER=25
28+
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-x86_64-linux.tar.gz -P /tmp \
29+
&& tar xf /tmp/wasi-sdk-${WASI_SDK_VER}.0-x86_64-linux.tar.gz -C /opt \
30+
&& ln -sf /opt/wasi-sdk-${WASI_SDK_VER}.0-x86_64-linux /opt/wasi-sdk
9431

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]
111-
112-
#
113-
# Install pip
114-
# hadolint ignore=DL3008
115-
RUN apt-get update \
116-
&& 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
125-
126-
#
127-
# Install github-cli. It doens't work as a feature of devcontainer.json
128-
ARG GH_CLI_VER=2.32.0
129-
WORKDIR /tmp
130-
RUN wget -q https://github.com/cli/cli/releases/download/v${GH_CLI_VER}/gh_${GH_CLI_VER}_linux_amd64.deb \
131-
&& dpkg -i gh_${GH_CLI_VER}_linux_amd64.deb
132-
133-
#
134-
# 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
32+
ARG WABT_VER=1.0.37
33+
RUN wget -c --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/wabt-${WABT_VER}-ubuntu-20.04.tar.gz -P /tmp \
34+
&& tar xf /tmp/wabt-${WABT_VER}-ubuntu-20.04.tar.gz -C /opt \
35+
&& ln -sf /opt/wabt-${WABT_VER} /opt/wabt
13836

13937
# 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 \
38+
39+
# clean up
40+
RUN apt-get autoremove -y \
14441
&& apt-get clean -y \
14542
&& rm -rf /var/lib/apt/lists/* \
14643
&& rm -rf /tmp/*
147-
148-
# set workdir when container run
149-
VOLUME /workspaces
150-
WORKDIR /workspaces

.devcontainer/devcontainer.json

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,29 @@
1-
// Copyright (C) 2019 Intel Corporation. All rights reserved.
2-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3-
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
4-
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/cpp
51
{
62
"name": "WAMR-Dev",
73
"build": {
84
"dockerfile": "Dockerfile",
9-
// 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
10-
// Use Debian 12, Debian 11, Debian 9, Ubuntu 18.04 or Ubuntu 21.04 on local arm64/Apple Silicon
115
"args": {
12-
"BINARYEN_VER": "114",
13-
"BAZELISK_VER": "1.17.0",
14-
"CMAKE_VER": "3.27.0",
15-
"EMSDK_VER": "3.1.43",
16-
"GH_CLI_VER": "2.32.0",
17-
"LLVM_VER": "16",
186
"VARIANT": "debian-12",
19-
"WASI_SDK_VER": "20",
20-
"WABT_VER": "1.0.33"
7+
"WASI_SDK_VER": "25",
8+
"WABT_VER": "1.0.37"
219
}
2210
},
2311
"runArgs": [
2412
"--cap-add=SYS_PTRACE",
2513
"--security-opt",
2614
"seccomp=unconfined"
2715
],
28-
// Configure tool-specific properties.
2916
"customizations": {
30-
// Configure properties specific to VS Code.
3117
"vscode": {
32-
// Set *default* container specific settings.json values on container create.
3318
"settings": {},
34-
// Add the IDs of extensions you want installed when the container is created.
3519
"extensions": [
3620
"dtsvet.vscode-wasm",
37-
"llvm-vs-code-extensions.vscode-clangd",
3821
"ms-python.python",
3922
"ms-python.vscode-pylance",
4023
"ms-vscode.cmake-tools"
4124
]
4225
}
4326
},
44-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
45-
// "forwardPorts": [],
46-
// Use 'postCreateCommand' to run commands after the container is created.
47-
"postCreateCommand": "curl https://sh.rustup.rs -sSf | bash -s -- -y",
48-
// Comment out this line to run as root instead.
27+
"postCreateCommand": "bash .devcontainer/finalize.sh",
4928
"remoteUser": "vscode"
5029
}

.devcontainer/finalize.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
echo "Running finalize script..."
2+
3+
#
4+
# Python Package Installation
5+
#
6+
7+
# Upgrade pip first
8+
python3 -m pip install --no-cache-dir --break-system-packages --upgrade pip
9+
# Install required packages
10+
pip3 install --no-cache-dir --break-system-packages -r .devcontainer/requirements.txt
11+
12+
echo "Finalize script completed. ✅"

.devcontainer/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
black
2+
nose
3+
pycparser
4+
pylint

0 commit comments

Comments
 (0)