From da6ab112d045032ff3064675ce68da53e4b4b78d Mon Sep 17 00:00:00 2001 From: Suru Dissanaike <suru.dissanaike@iopsys.eu> Date: Wed, 18 Dec 2019 09:46:08 +0100 Subject: [PATCH] added Docker file for code analysis --- docker/code-analysis/Dockerfile | 126 ++++++++++++++++++++++++++ docker/code-analysis/entrypoint.sh | 11 +++ docker/code-analysis/supervisord.conf | 8 ++ 3 files changed, 145 insertions(+) create mode 100644 docker/code-analysis/Dockerfile create mode 100755 docker/code-analysis/entrypoint.sh create mode 100644 docker/code-analysis/supervisord.conf diff --git a/docker/code-analysis/Dockerfile b/docker/code-analysis/Dockerfile new file mode 100644 index 0000000..2be343f --- /dev/null +++ b/docker/code-analysis/Dockerfile @@ -0,0 +1,126 @@ +FROM ubuntu:18.04 + +LABEL maintainer="suru.dissanaike@iopsys.eu" +LABEL build="docker build -t iopsys-codeanalysis ." +LABEL run="docker run -d --name codeanalysis --rm -v ${PWD}:/opt/work -e LOCAL_USER_ID=`id -u $USER` iopsys-codeanalysis" +LABEL exec="docker exec --user=user -it codeanalysis bash" + + +RUN \ + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + # general tools + git \ + cmake \ + wget \ + build-essential \ + lcov \ + apt-utils \ + autoconf \ + automake \ + pkg-config \ + libtool \ + vim \ + valgrind \ + gdb \ + clang-format \ + sudo \ + strace \ + supervisor \ + net-tools \ + iputils-ping + + +# Install dependent libraries +RUN \ + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + lua5.1-dev \ + lua5.1 \ + libssl-dev \ + libuv1-dev \ + cmocka-doc \ + libcmocka-dev \ + libcmocka0 + + + +# Remove cached packages. +RUN rm -rf /var/lib/apt/lists/* + +RUN mkdir /opt/dev + +# Install JSON-C +RUN \ + cd /opt/dev && \ + git clone https://github.com/json-c/json-c.git && \ + cd json-c && \ + sh autogen.sh && \ + ./configure && \ + make && \ + make install && \ + sudo ldconfig + +# ubox +RUN \ + cd /opt/dev && \ + git clone git://git.openwrt.org/project/libubox.git && \ + cd libubox && mkdir build && cd build && \ + git checkout fd57eea9f37e447814afbf934db626288aac23c4 && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE:String="Release" .. && \ + make -j2 && \ + make install + +# uci +RUN \ + cd /opt/dev && \ + git clone git://nbd.name/uci.git && \ + cd uci && \ + git checkout a536e300370cc3ad7b14b052b9ee943e6149ba4d && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE:String="Release" -DBUILD_LUA=OFF . && \ + make -j2 && \ + make install + +# ubus +RUN \ + cd /opt/dev && \ + git clone https://git.openwrt.org/project/ubus.git && \ + cd ubus && \ + git checkout 5f87f5480ebf004d735dbf44259d08cf8affd305 && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE:String="Release" -DBUILD_LUA=OFF -DBUILD_EXAMPLES=OFF . && \ + make -j2 && \ + make install + +# rpcd +RUN \ + cd /opt/dev && \ + git clone https://git.openwrt.org/project/rpcd.git && \ + cd rpcd && \ + git checkout cfe1e75c91bc1bac82e6caab3e652b0ebee59524 && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE:String="Release" -DIWINFO_SUPPORT=NO . && \ + make -j2 && \ + make install && \ + mkdir /usr/lib/rpcd && \ + cp file.so /usr/lib/rpcd + + +# json-editor +RUN \ + cd /opt/dev && \ + git clone https://dev.iopsys.eu/iopsys/json-editor.git && \ + cd json-editor && \ + git checkout 44b32937a062ec4ffc9f7355841dc94ab6efa50f && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE:String="Release" . && \ + make && \ + make install + + +RUN mkdir /etc/config + +WORKDIR /opt/work + +# Prepare supervisor +RUN mkdir -p /var/log/supervisor +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# Start entrypoint +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/docker/code-analysis/entrypoint.sh b/docker/code-analysis/entrypoint.sh new file mode 100755 index 0000000..2027807 --- /dev/null +++ b/docker/code-analysis/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Create user +USER_ID=${LOCAL_USER_ID:-9001} +useradd --shell /bin/bash -u $USER_ID -G sudo -o -c "" -m user +adduser --disabled-password user +export HOME=/home/user +echo "user ALL = NOPASSWD : ALL" >> /etc/sudoers + +# Start supervisor +/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf -l /var/log/supervisord.log -j /var/run/supervisord.pid diff --git a/docker/code-analysis/supervisord.conf b/docker/code-analysis/supervisord.conf new file mode 100644 index 0000000..648e140 --- /dev/null +++ b/docker/code-analysis/supervisord.conf @@ -0,0 +1,8 @@ +[supervisord] +nodaemon=true + +[program:ubusd] +command=/bin/bash -c "/usr/sbin/ubusd" + +[program:rpcd] +command=/bin/bash -c "/usr/sbin/rpcd" -- GitLab