Skip to content

Commit

Permalink
Dockerfile lint errors fix (bytecodealliance#1493)
Browse files Browse the repository at this point in the history
Fix the Dockerfile linter errors and most warnings
  • Loading branch information
TianlongLiang authored Sep 22, 2022
1 parent ba3af0b commit ee210d0
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 191 deletions.
92 changes: 51 additions & 41 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,90 +9,100 @@ 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

#
# 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
=========================
Expand Down
92 changes: 0 additions & 92 deletions ci/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion ci/build_wamr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
25 changes: 25 additions & 0 deletions doc/devcontainer.md
Original file line number Diff line number Diff line change
@@ -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)
37 changes: 0 additions & 37 deletions product-mini/platforms/zephyr/simple/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion samples/workload/docker/build_workload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
4 changes: 2 additions & 2 deletions test-tools/IoT-APP-Store-Demo/wasm_django/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

Original file line number Diff line number Diff line change
@@ -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"]
11 changes: 6 additions & 5 deletions test-tools/wamr-ide/WASM-Debug-Server/Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit ee210d0

Please sign in to comment.