From 84f85ee9ad86254ba15cc4d237a8b9758304c5e9 Mon Sep 17 00:00:00 2001 From: Naga Sugguna Date: Tue, 3 Dec 2019 07:21:14 +0000 Subject: [PATCH] [VAL-87] Bluval Containerization Intention of this change is to simplify BluVal installation Now steps should be 1. clone the project 2. Update variables.yaml & volumes.yaml 3. ./blucon.sh -l -o -n host blucon.sh builds the docker image takes few minutes first time later on it should be quick. Change-Id: I4b00e00baecc6d7eb81595d1d8866af67e2c53cf Signed-off-by: Naga Sugguna --- .coafile | 1 + bluval/Dockerfile | 30 +++++++++++++++++++++++++ bluval/blucon.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ bluval/requirements.txt | 5 +++++ 4 files changed, 94 insertions(+) create mode 100644 bluval/Dockerfile create mode 100755 bluval/blucon.sh diff --git a/.coafile b/.coafile index 50e636c..fd4a0cc 100644 --- a/.coafile +++ b/.coafile @@ -1,6 +1,7 @@ [all] ignore = .tox/**, .py35/**, + .py36/**, .git/**, .gitignore, .gitreview, diff --git a/bluval/Dockerfile b/bluval/Dockerfile new file mode 100644 index 0000000..08753f7 --- /dev/null +++ b/bluval/Dockerfile @@ -0,0 +1,30 @@ +############################################################################## +# Copyright (c) 2019 AT&T, ENEA Nokia and others # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you maynot use this file except in compliance with the License. # +# # +# You may obtain a copy of the License at # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +############################################################################## + +# ref: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#use-multi-stage-builds +FROM ubuntu:18.04 as build + +RUN apt-get update && apt-get -y install git python3-pip python3.6 + +# Build binaries +RUN git clone https://gerrit.akraino.org/r/validation /opt/akraino/validation +RUN pip3 install -r /opt/akraino/validation/bluval/requirements.txt + +ENV LC_ALL=C.UTF-8 +ENV LANG=C.UTF-8 + +WORKDIR /opt/akraino/validation +ENTRYPOINT ["python3", "bluval/blucon.py"] \ No newline at end of file diff --git a/bluval/blucon.sh b/bluval/blucon.sh new file mode 100755 index 0000000..3cc1e5e --- /dev/null +++ b/bluval/blucon.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2019 AT&T, ENEA Nokia and others # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you maynot use this file except in compliance with the License. # +# # +# You may obtain a copy of the License at # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +############################################################################## + +if [ -z "$AKRAINO_HOME" ] +then + echo "AKRAINO_HOME not available. Setting..." + this_file="$(readlink -f $0)" + bluval_dir="$(dirname $this_file)" + validation_dir="$(dirname $bluval_dir)" + parent_dir="$(dirname $validation_dir)" + export AKRAINO_HOME="$parent_dir" +fi +echo "AKRAINO_HOME=$AKRAINO_HOME" + +if [ "$#" -eq 0 ] +then + echo 'Usage: sh blucon.sh [OPTIONS] BLUEPRINT + + Invokes blucon.py and passes parameters as it is. + You can pass all the parameters blucon.py accepts, + and as of now here is the list + + Options: + -l, --layer TEXT + -n, --network TEXT + -o, --optional_also + --help Show this message and exit.' + + exit 1 +fi + +echo "Building docker image" +image_tag=$( (git branch || echo "* local") | grep "^\*" | awk '{print $2}') +docker build -t akraino/validation:blucon-$image_tag $AKRAINO_HOME/validation/bluval + +set -x + +docker run --rm \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v /usr/bin/docker:/usr/bin/docker \ + -v $AKRAINO_HOME/results:/opt/akraino/results \ + -v $AKRAINO_HOME/validation:/opt/akraino/validation \ + akraino/validation:blucon-$image_tag "$@" diff --git a/bluval/requirements.txt b/bluval/requirements.txt index bdd48f9..7784bcd 100644 --- a/bluval/requirements.txt +++ b/bluval/requirements.txt @@ -1,2 +1,7 @@ pyyaml click +robotframework +robotframework-httplibrary +robotframework-jsonlibrary +robotframework-requests +robotframework-sshlibrary -- 2.16.6