Merge "Add validaton tests for KNI"
[validation.git] / docker / os / Dockerfile
1 ##############################################################################
2 # Copyright (c) 2019 AT&T, ENEA AB, Nokia and others                         #
3 #                                                                            #
4 # Licensed under the Apache License, Version 2.0 (the "License");            #
5 # you maynot use this file except in compliance with the License.            #
6 #                                                                            #
7 # You may obtain a copy of the License at                                    #
8 #       http://www.apache.org/licenses/LICENSE-2.0                           #
9 #                                                                            #
10 # Unless required by applicable law or agreed to in writing, software        #
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
13 # See the License for the specific language governing permissions and        #
14 # limitations under the License.                                             #
15 ##############################################################################
16
17 # ref: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#use-multi-stage-builds
18 FROM ubuntu:18.04 as build
19
20 # Install dependencies
21 COPY pip-requirements.txt /wheels/requirements/pip-requirements.txt
22 RUN apt-get update && apt-get -y install \
23     python3-pip \
24     gcc \
25     git \
26     libc-dev \
27     libffi6 \
28     libffi-dev \
29     make \
30     libssl-dev \
31     build-essential \
32     autoconf automake autotools-dev m4 \
33     linux-headers-generic \
34     libaio-dev libattr1-dev libcap-dev
35
36 # Build binaries
37 WORKDIR /wheels
38 RUN pip3 install wheel
39 RUN pip3 wheel -r /wheels/requirements/pip-requirements.txt
40 RUN git clone https://gerrit.akraino.org/r/validation /opt/akraino/validation
41
42 # Build ltp tests
43 RUN mkdir -p /opt/akraino /root/src
44 WORKDIR  /root/src
45 RUN git clone https://github.com/linux-test-project/ltp.git
46 WORKDIR /root/src/ltp
47 RUN make autotools && \
48     ./configure --prefix=/opt/ltp && \
49     make -j $(getconf _NPROCESSORS_ONLN) 2>&1 | tee ../build-log.txt && \
50     make install 2>&1 | tee ../install-log.txt
51 RUN tar czvf /opt/akraino/ltp.tar.gz /opt/ltp
52 WORKDIR /root/src
53 RUN git clone https://github.com/CISOfy/lynis && tar czvf /opt/akraino/lynis-remote.tar.gz ./lynis
54
55 # Copy binaries into the final container and install robot framework
56 FROM ubuntu:18.04
57 COPY --from=build /wheels /wheels
58 COPY --from=build /opt/akraino/validation /opt/akraino/validation
59 COPY --from=build /opt/akraino/ltp.tar.gz /opt/akraino/ltp.tar.gz
60 COPY --from=build /opt/akraino/lynis-remote.tar.gz /opt/akraino/lynis-remote.tar.gz
61
62
63 RUN apt-get update && apt-get -y install \
64     python3-pip python3.6 && \
65     cd /usr/bin && ln -s python3 python && \
66     pip3 install -r /wheels/requirements/pip-requirements.txt \
67                  -f /wheels && \
68     rm -rf /wheels && \
69     rm -rf /root/.cache/pip/* && \
70     rm -rf /var/cache/apt/* && \
71     rm -rf /var/lib/apt/lists/*
72
73 # Install bluval dependencies
74 RUN pip3 install -r /opt/akraino/validation/bluval/requirements.txt
75 ENV LC_ALL=C.UTF-8
76 ENV LANG=C.UTF-8