Dockerfile lint errors fix (#1493)

Fix the Dockerfile linter errors and most warnings
This commit is contained in:
TianlongLiang 2022-09-22 13:06:11 +08:00 committed by GitHub
parent ba3af0b196
commit ee210d019f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 102 additions and 191 deletions

View File

@ -9,29 +9,35 @@ 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 \
RUN apt-get update \
&& apt-get 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
unzip valgrind vim wget zip --no-install-recommends \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
#
# 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 \
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
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 \
&& 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 \
&& apt-get update \
&& rm /usr/share/keyrings/kitware-archive-keyring.gpg \
&& apt install -y kitware-archive-keyring \
&& apt install -y cmake
&& apt-get install -y kitware-archive-keyring --no-install-recommends \
&& apt-get install -y cmake --no-install-recommends \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
#
# install emsdk
RUN cd /opt \
&& git clone https://github.com/emscripten-core/emsdk.git
RUN cd /opt/emsdk \
&& git pull \
WORKDIR /opt
RUN git clone https://github.com/emscripten-core/emsdk.git
WORKDIR /opt/emsdk
RUN git pull \
&& ./emsdk install 2.0.26 \
&& ./emsdk activate 2.0.26 \
&& echo "source /opt/emsdk/emsdk_env.sh" >> /root/.bashrc
@ -39,60 +45,64 @@ RUN cd /opt/emsdk \
#
# 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
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 \
&& 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 \
&& 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
RUN wget -c --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/wabt-${WABT_VER}-ubuntu.tar.gz -P /opt \
&& tar xf /opt/wabt-${WABT_VER}-ubuntu.tar.gz -C /opt \
&& ln -fs /opt/wabt-${WABT_VER} /opt/wabt \
&& 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 \
RUN mkdir /opt/bazelisk \
&& wget -c --progress=dot:giga https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VER}/bazelisk-linux-amd64 -P /opt/bazelisk \
&& 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 \
WORKDIR /etc/apt/apt.conf.d
RUN 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
RUN ln -sf /usr/bin/clang-format-12 /usr/bin/clang-format
WORKDIR /tmp
RUN wget --progress=dot:giga https://apt.llvm.org/llvm.sh \
&& chmod a+x ./llvm.sh \
&& /tmp/llvm.sh 12 all \
&& ln -sf /usr/bin/clang-format-12 /usr/bin/clang-format \
&& rm -rf /tmp/*
#
# [Optional]
#
# Install pip
RUN apt update && apt install -y --reinstall python3-venv python3-pip
RUN python3 -m pip install --upgrade pip
RUN apt-get update \
&& apt-get install -y --reinstall python3-venv python3-pip --no-install-recommends \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
#
# Install required python packages
RUN pip3 install --user black nose pycparser pylint
RUN python3 -m pip install --no-cache-dir --upgrade pip \
&& pip3 install --no-cache-dir --user black nose pycparser pylint
# set path
# set path, PS and clean up
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 \
RUN echo "export PATH=/opt/bazelisk:/opt/clang-llvm/bin:${PATH}" >> /root/.bashrc \
&& printf "%s\n" "PS1='\n[ \u@wamr-dev-docker \W ]\n$ '" >> /root/.bashrc \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*
# set workdir when container run
VOLUME /workspace
WORKDIR /workspace

View File

@ -25,6 +25,7 @@ Getting started
- [Build WASM applications](./doc/build_wasm_app.md)
- [Port WAMR to a new platform](./doc/port_wamr.md)
- [Benchmarks](./tests/benchmarks) and [Samples](./samples)
- [VS Code development container](./doc/devcontainer.md)
iwasm VM core
=========================

View File

@ -1,92 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# tie the ${VARIANT} and a llvm binary release together
# please find a matched version on https://github.com/llvm/llvm-project/releases
ARG VARIANT=focal
FROM ubuntu:${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 (may not necessary ?)
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 clang and llvm release
ARG CLANG_VER=13.0.0
RUN wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${CLANG_VER}/clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04.tar.xz -P /opt
RUN cd /opt \
&& tar xf clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04.tar.xz \
&& ln -sf clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04 clang-llvm
RUN rm /opt/clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04.tar.xz
#
# install wasi-sdk
ARG WASI_SDK_VER=14
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.24
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.10.1
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
RUN apt update && apt install -y clang-format
# set path
ENV PATH "$PATH:/opt/wasi-sdk/bin:/opt/wabt/bin:/opt/binaryen/bin:/opt/bazelisk:/opt/clang-llvm/bin"
RUN echo "export PATH=/opt/wasi-sdk/bin:/opt/wabt/bin:/opt/binaryen/bin:/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/*
VOLUME /workspace
WORKDIR /workspace

View File

@ -9,7 +9,7 @@ readonly VARIANT=$(lsb_release -c | awk '{print $2}')
docker build \
--memory=4G --cpu-quota=50000 \
-t wamr_dev_${VARIANT}:0.1 -f "${CURRENT_PATH}"/Dockerfile "${CURRENT_PATH}" \
-t wamr_dev_${VARIANT}:0.1 -f "${ROOT}"/.devcontainer/Dockerfile "${ROOT}"/.devcontainer \
&& docker run --rm -it \
--cap-add=SYS_PTRACE \
--cpus=".5" \

25
doc/devcontainer.md Normal file
View File

@ -0,0 +1,25 @@
# Visual Studio Code development container
We all know Docker containers and may use them a lot in school or work. It resolves dependency management for our projects/applications, prevents package version confusion and conflict, and contamination of the local environment.
Now WAMR has a Dockerfile under path `.devontainer` to create a container image, dev container images that you could easily use in VS Code. In case you prefer other IDE like Clion, you can also build it and use for the IDE you like.
## How to use it
It's straightforward to use Docker in VS Code! First, you have VS Code and Docker installed(if not yet, check [next section](#learn-more-about-docker-and-vs-code) for howto). Then you need to download Docker in VS Code extensions marketplace.
And that's it, and you are good to go! When you open the root folder of WAMR, in the bottom right corner, the Docker extension will pop a notification and ask if you like to reopen the folder in a container.
If you encounter any problems or get stuck somewhere, may this video [demo](https://youtu.be/Uvf2FVS1F8k) for docker usage in VS Code will help.
## Learn more about Docker and VS Code
[Install Docker](https://docs.docker.com/get-docker/)
[Install VS Code](https://code.visualstudio.com/)
[Docker extension for VS Code](https://code.visualstudio.com/docs/containers/overview)
[Remote development with Docker in VS Code](https://code.visualstudio.com/docs/remote/containers#_getting-started)
[What is dev container image in VS Code](https://code.visualstudio.com/docs/remote/containers#_prebuilding-dev-container-images)

View File

@ -1,37 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
FROM ubuntu:20.04
ARG DOCKER_UID=1000
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -qq update && apt-get -qq dist-upgrade && apt install -qq -y python3-pip git wget ninja-build
WORKDIR /tmp
RUN mkdir /opt/cmake && wget -q https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-linux-x86_64.sh && sh cmake-3.22.1-linux-x86_64.sh --skip-license --prefix=/opt/cmake && rm cmake-3.22.1-linux-x86_64.sh
ENV PATH="/opt/cmake/bin:$PATH"
RUN useradd -m wamr -u ${DOCKER_UID} -G dialout
USER wamr
ENV PATH="/home/wamr/.local/bin:$PATH"
RUN pip3 install --user west
RUN west init ~/zephyrproject && cd ~/zephyrproject && west update && west zephyr-export
RUN pip3 install --user -r ~/zephyrproject/zephyr/scripts/requirements.txt
WORKDIR /home/wamr/zephyrproject
RUN west espressif install
ENV ZEPHYR_BASE=/home/wamr/zephyrproject/zephyr
ENV ESPRESSIF_TOOLCHAIN_PATH=/home/wamr/.espressif/tools/zephyr
WORKDIR /home/wamr/source/product-mini/platforms/zephyr/simple

View File

@ -13,7 +13,7 @@ readonly VARIANT=$(lsb_release -c | awk '{print $2}')
docker build \
--build-arg VARIANT=${VARIANT} \
--memory 4G --cpu-quota 50000 \
-t wamr_dev_${VARIANT}:0.1 -f "${ROOT}"/ci/Dockerfile "${ROOT}"/ci &&
-t wamr_dev_${VARIANT}:0.1 -f "${ROOT}"/.devcontainer/Dockerfile "${ROOT}"/.devcontainer &&
docker run --rm -it \
--memory 4G \
--cpus ".5" \

View File

@ -1,9 +1,9 @@
FROM python:3.5
WORKDIR /app
ADD . /app
COPY . /app
RUN pip install django
RUN pip install django --no-cache-dir
ENTRYPOINT ["python", "manage.py", "runserver", "0.0.0.0:80"]

View File

@ -1,6 +1,6 @@
FROM python:3.5
WORKDIR /app
ADD server/wasm_server.py /app/server/
COPY server/wasm_server.py /app/server/
ENTRYPOINT ["python", "server/wasm_server.py"]

View File

@ -8,18 +8,19 @@ WORKDIR /root/
COPY resource /root/
## - download cmake with wget and set up
RUN wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.tar.gz \
RUN wget --progress=dot:giga https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.tar.gz \
&& tar -zxvf cmake-3.21.1-linux-x86_64.tar.gz \
&& rm -f cmake-3.21.1-linux-x86_64.tar.gz \
&& mv cmake-3.21.1-linux-x86_64 /opt/cmake \
&& ln -s /opt/cmake/bin/cmake /bin/cmake \
&& apt-get install make
&& apt-get -y install make --no-install-recommends
## -clone wamr-repo and build iwasm
RUN git clone -b main --depth=1 https://github.com/bytecodealliance/wasm-micro-runtime.git \
&& cd /root/wasm-micro-runtime/product-mini/platforms/linux \
&& mkdir build && cd build \
&& cmake .. -DWAMR_BUILD_DEBUG_INTERP=1 && make \
&& mkdir -p /root/wasm-micro-runtime/product-mini/platforms/linux/build
WORKDIR /root/wasm-micro-runtime/product-mini/platforms/linux/build
RUN cmake .. -DWAMR_BUILD_DEBUG_INTERP=1 && make \
&& cp /root/wasm-micro-runtime/product-mini/platforms/linux/build/iwasm /root/iwasm \
&& rm -fr /root/wasm-micro-runtime

View File

@ -10,12 +10,12 @@ WORKDIR /root/
COPY resource /root/
## - download cmake with wget and set up
RUN wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.tar.gz \
RUN wget --progress=dot:giga https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.tar.gz \
&& tar -zxvf cmake-3.21.1-linux-x86_64.tar.gz \
&& rm -f cmake-3.21.1-linux-x86_64.tar.gz \
&& mv cmake-3.21.1-linux-x86_64 /opt/cmake \
&& ln -s /opt/cmake/bin/cmake /bin/cmake \
&& apt-get install make
&& apt-get -y install make --no-install-recommends
## set compilation environment for wamrc
# - wamr repo
@ -24,19 +24,20 @@ RUN wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1
# - wamr-sdk
## - download wasi-sdk with wget and set up to /opt/wasi-sdk
RUN wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-14/wasi-sdk-14.0-linux.tar.gz \
RUN wget --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-14/wasi-sdk-14.0-linux.tar.gz \
&& tar -zxvf wasi-sdk-14.0-linux.tar.gz \
&& mv wasi-sdk-14.0 /opt/wasi-sdk/ \
&& rm -f wasi-sdk-14.0-linux.tar.gz
## - clone wamr repo
RUN git clone -b main --depth=1 https://github.com/bytecodealliance/wasm-micro-runtime.git \
&& cd /root/wasm-micro-runtime/wamr-compiler \
&& ./build_llvm.sh \
&& cd /root/wasm-micro-runtime/wamr-compiler \
&& mkdir build \
&& cd build \
&& cmake .. \
RUN git clone -b main --depth=1 https://github.com/bytecodealliance/wasm-micro-runtime.git
WORKDIR /root/wasm-micro-runtime/wamr-compiler
RUN ./build_llvm.sh \
&& mkdir build
WORKDIR /root/wasm-micro-runtime/wamr-compiler/build
RUN cmake .. \
&& make \
# - copy the wamrc to /root
&& cp /root/wasm-micro-runtime/wamr-compiler/build/wamrc /root/wamrc \
@ -65,6 +66,8 @@ COPY --from=BASE /root/build_wasm.sh ${HOME_DIR}
RUN ln -s /opt/cmake/bin/cmake /usr/bin/cmake \
&& ln -s ${HOME_DIR}/wamrc /usr/bin/wamrc
RUN apt-get update && apt-get install make
RUN apt-get update && apt-get install -y make --no-install-recommends \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
WORKDIR ${HOME_DIR}