Commit 381adfc4 authored by Pitchaiah Murugan's avatar Pitchaiah Murugan
Browse files

Peripheral Manager: Add the Dockerfile for PM

parent 6b951825
Pipeline #1377 passed with stage
in 16 seconds
FROM ubuntu:16.04
ENV TOOLS_INSTALL_DIR="/opt/lib"
# Install all the tools in docker image
COPY docker/install_tools.sh $TOOLS_INSTALL_DIR/
RUN $TOOLS_INSTALL_DIR/install_tools.sh
# Install json library in docker image
COPY docker/install_json.sh $TOOLS_INSTALL_DIR/
RUN $TOOLS_INSTALL_DIR/install_json.sh
# Install libubox library in docker image
COPY docker/install_ubox.sh $TOOLS_INSTALL_DIR/
RUN $TOOLS_INSTALL_DIR/install_ubox.sh
# Install uci library in docker image
COPY docker/install_uci.sh $TOOLS_INSTALL_DIR/
RUN $TOOLS_INSTALL_DIR/install_uci.sh
# Install ubus library in docker image
COPY docker/install_ubus.sh $TOOLS_INSTALL_DIR/
RUN $TOOLS_INSTALL_DIR/install_ubus.sh
# Expose ports
EXPOSE 22
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Start entrypoint
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
#!/bin/bash
set -e
DOCKER_IMAGE_NAME=iopsys/peripheral_manager
NAME=peripheral_manager
WORKDIR=/opt/work
DOCKER_FOLDER=$(dirname $0)
DOCKER_PORT=22
HOST_PORT=2222
LOCAL_USER_ID=`id -u $USER`
help() {
echo "This build_docker script to minimize the effort of running docker command all the time"
echo " $0 <command>"
echo " clean Cleans all hanging images or not labelled images "
echo " cleanall clean + removes the build image"
echo " build builds the docker image"
echo " service run the service container of ubusd daemon"
echo " run [args] runs image, with user command to execute on docker container"
echo " #################################################################### "
echo " ****** Steps to run the Docker Container ****** "
echo " ****** ./build_docker.sh build ****** "
echo " ****** ./build_docker.sh service (In one terminal) ****** "
echo " ****** ./build_docker.sh run bash (In another terminal) ****** "
echo " ****** OR ****** "
echo " ****** ./build_docker.sh run cmake -DCMAKE_BUILD_TYPE=Debug . ****** "
echo " ****** ./build_docker.sh run make (Builds the binary of UT) ****** "
echo " #################################################################### "
}
clean() {
echo Removing
docker image prune -f
docker container prune -f
}
cleanall() {
clean
docker rmi --force $DOCKER_IMAGE_NAME || exit $?
}
stop() {
docker stop $NAME
}
check_image() {
docker images $DOCKER_IMAGE_NAME
}
check_docker() {
check_docker=$(docker -v)
echo "$check_docker"
if [[ $check_docker =~ .*"Docker version"* ]]; then
echo "Docker is present and its starting to build the container"
else
echo "*** Please Install Docker, For reference Use the below link ******"
echo "*** https://docs.docker.com/engine/install/ubuntu/ *******"
exit 0
fi
}
build() {
check_docker
docker build -t $DOCKER_IMAGE_NAME $DOCKER_FOLDER $*
}
run() {
if [ -z "$*" ]; then
args="bash"
else
args=$*
fi
echo Running docker container with args: $args
docker exec -it $NAME $args
}
service() {
echo Running docker service container with args: $args
cmd="docker run -it --privileged --rm
--name=$NAME
--ipc=host
-e $LOCAL_USER_ID
--volume $(pwd):$WORKDIR
-p $HOST_PORT:$DOCKER_PORT
-w $WORKDIR
$DOCKER_IMAGE_NAME "
$cmd
}
if [ -z "$*" ]; then
help
else
cmd="$1"
shift
$cmd $*
fi
#!/bin/sh
#export HOME=/home/user
adduser --disabled-password --gecos "" user
adduser user sudo
echo "user ALL = NOPASSWD : ALL" >> /etc/sudoers
# Configure OpenSSH to allow login without password
sed -i -re 's/^user:[^:]+:/user::/' /etc/passwd /etc/shadow
pam_config="auth [success=1 default=ignore] pam_unix.so nullok\nauth requisite pam_deny.so\nauth required pam_permit.so"
sed -i "s/@include common-auth/$pam_config/" /etc/pam.d/sshd
#sudo chmod 777 /var/log/supervisord.log
# Start supervisor
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
#!/bin/sh
cd $TOOLS_INSTALL_DIR/
git clone https://github.com/json-c/json-c.git && \
cd json-c && \
mkdir build && cd build && \
cmake .. && \
make && \
make install && \
ldconfig
rm -rf ./json-c
#!/bin/sh
#Tools for unit testing , code analysis and code coverage.
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
git \
cmake \
wget \
build-essential \
lcov \
apt-utils \
autoconf \
automake \
pkg-config \
libtool \
vim \
valgrind \
gdb \
cppcheck \
python3 \
python3-setuptools \
openssh-server \
clang-format \
sudo \
strace \
supervisor \
net-tools \
iputils-ping \
lua5.1-dev \
lua5.1 \
libssl-dev \
libuv1-dev \
cmocka-doc \
libcmocka-dev \
libcmocka0
# Configure OpenSSH server
mkdir /var/run/sshd && \
echo 'root:root' | chpasswd && \
sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed -i 's/PermitEmptyPasswords no/PermitEmptyPasswords yes/' /etc/ssh/sshd_config && \
sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
# Configure gdb-dashboard
easy_install3 pip && \
pip3 install Pygments
wget -P ~ git.io/.gdbinit
mkdir ~/.gdbinit.d && \
touch ~/.gdbinit.d/init && \
echo "dashboard -layout source" >> ~/.gdbinit.d/init && \
echo "dashboard source -style context 20" >> ~/.gdbinit.d/init && \
echo "dashboard -style syntax_highlighting 'monokai'" >> ~/.gdbinit.d/init
#Craete directory to copy supervisior config and uci config file
mkdir /etc/config && \
mkdir -p /var/log/supervisor
# last !
rm -rf /var/lib/apt/lists/*
#!/bin/sh
cd $TOOLS_INSTALL_DIR/
CHECKOUT_ID=fd57eea9f37e447814afbf934db626288aac23c4
INSTALL_PREFIX=/usr
git clone git://git.openwrt.org/project/libubox.git && \
cd libubox && \
git checkout $CHECKOUT_ID && \
mkdir build && cd build && \
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE:String="Release" -DBUILD_LUA=OFF .. && \
make -j2 && \
make install && \
ldconfig
rm -rf ./libubox
#!/bin/sh
cd $TOOLS_INSTALL_DIR/
CHECKOUT_ID=221ce7e7ff1bd1a0c9995fa9d32f58e865f7207f
INSTALL_PREFIX=/usr
git clone https://git.openwrt.org/project/ubus.git && \
cd ubus && \
git checkout $CHECKOUT_ID && \
mkdir build && cd build && \
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE:String="Release" -DBUILD_LUA=OFF -DBUILD_EXAMPLES=OFF .. && \
make -j2 && \
make install && \
ldconfig
rm -rf ./ubus
#!/bin/sh
cd $TOOLS_INSTALL_DIR/
CHECKOUT_ID=a536e300370cc3ad7b14b052b9ee943e6149ba4d
INSTALL_PREFIX=/usr
git clone git://nbd.name/uci.git && \
cd uci && \
git checkout $CHECKOUT_ID && \
mkdir build && cd build && \
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE:String="Release" -DBUILD_LUA=OFF .. && \
make -j2 && \
make install && \
ldconfig
rm -rf ./uci
[supervisord]
nodaemon=true
[program:ubusd]
startsecs = 0
autorestart = false
command=/bin/bash -c "/usr/sbin/ubusd"
[program:sshd]
startsecs = 0
autorestart = false
command=/usr/sbin/sshd -D
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment