Adding Dockerfile to the repo
[ric-app/hw.git] / Dockerfile-Unit-Tests
1 #/*
2 #==================================================================================
3 #        Copyright (c) 2018-2019 AT&T Intellectual Property.
4 #
5 #   Licensed under the Apache License, Version 2.0 (the "License");
6 #   you may not use this file except in compliance with the License.
7 #   You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #   Unless required by applicable law or agreed to in writing, software
12 #   distributed under the License is distributed on an "AS IS" BASIS,
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #   See the License for the specific language governing permissions and
15 #   limitations under the License.
16 #==================================================================================
17 #*/
18 ARG SCHEMA_PATH=schemas
19 ARG STAGE_DIR=/tmp/helloworld-xapp
20
21 #==================================================================================
22 FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu16-c-go@sha256:f4ebcc792b501f283c7848018b6f106bbcecf1f9e699035950614460b3c330f8 as ricbuild
23
24 # to override repo base, pass in repo argument when running docker build:
25 # docker build --build-arg REPOBASE=http://abc.def.org . ....
26 ARG REPOBASE=https://gerrit.oran-osc.org/r
27 ARG SCHEMA_FILE
28 ARG SCHEMA_PATH
29 ARG STAGE_DIR
30
31 # Install necessary packages
32 WORKDIR ${STAGE_DIR}
33 RUN apt-get update  \
34      && apt-get install -y \
35      libcurl4-openssl-dev \
36      libcurl3 \
37      cmake \
38      git \
39      build-essential \
40      automake \
41      autoconf-archive \
42      autoconf \
43      pkg-config \
44      gawk \
45      libtool \
46      wget \
47      zlib1g-dev \
48      libffi-dev \
49      && apt-get clean
50
51 # Install mdclog using debian package hosted at packagecloud.io
52 ARG MDC_VER=0.0.4-1
53 RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/mdclog_${MDC_VER}_amd64.deb/download.deb
54 RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/mdclog-dev_${MDC_VER}_amd64.deb/download.deb
55 RUN dpkg -i mdclog_${MDC_VER}_amd64.deb
56 RUN dpkg -i mdclog-dev_${MDC_VER}_amd64.deb
57
58 # Install RMr using debian package hosted at packagecloud.io
59 ARG RMR_VER=3.6.2
60 RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_${RMR_VER}_amd64.deb/download.deb
61 RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_${RMR_VER}_amd64.deb/download.deb
62 RUN dpkg -i rmr_${RMR_VER}_amd64.deb
63 RUN dpkg -i rmr-dev_${RMR_VER}_amd64.deb
64
65 ##Iinstall Google test
66
67 WORKDIR ${STAGE_DIR}
68 RUN apt-get install libgtest-dev
69 RUN cd /usr/src/gtest \
70     && cmake CMakeLists.txt \
71     && make \
72     && cp *.a /usr/local/lib
73
74
75 ## Install SDL Libraries
76 WORKDIR ${STAGE_DIR}
77 RUN apt-get install -y cpputest
78 RUN apt-get remove -y libboost-all-dev
79 RUN apt-get install -y  libboost-all-dev
80 RUN apt-get install -y libhiredis-dev
81 RUN apt-get install -y valgrind
82
83 RUN git config --global http.proxy http://one.proxy.att.com:8080
84 RUN git clone https://gerrit.o-ran-sc.org/r/ric-plt/dbaas
85 RUN cd dbaas/redismodule && \
86     ./autogen.sh && \
87     ./configure && \
88     make all && \
89 ##    make test && \
90     make install
91
92 WORKDIR ${STAGE_DIR}
93 RUN git clone https://gerrit.o-ran-sc.org/r/ric-plt/sdl
94 RUN cd sdl && \
95     ./autogen.sh && \
96     ./configure && \
97     make all && \
98 #    make test && \
99     make install
100
101 RUN git config --global --unset http.proxy
102
103 WORKDIR ${STAGE_DIR}
104 ## Install rapidjson
105     #git checkout tags/v1.1.0 && \
106
107 RUN git clone https://github.com/Tencent/rapidjson && \
108     cd rapidjson && \
109     mkdir build && \
110     cd build && \
111     cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
112     make install && \
113     cd ${STAGE_DIR} && \
114     rm -rf rapidjson
115
116 ### Copy RNIB library and include rnib.
117 RUN mkdir /usr/local/include/rnib
118
119 ##-----------------------------------
120 # Now install the program
121 #------------------------------------
122 COPY ./ ${STAGE_DIR}
123 RUN ls -al
124 COPY ${STAGE}/rnib/*.h /usr/local/include/rnib/
125 COPY ${STAGE}/rnibreader_old.a /usr/local/lib/
126
127 RUN export CPATH=$CPATH:/usr/local/include && \ 
128     cd test && \
129     make clean && \
130     make install 
131
132 COPY ${SCHEMA_PATH}/* /etc/xapp/
133 COPY init/init_script.py /etc/xapp/init_script.py
134
135
136 #---------------------------------------------
137 # #Build the final version
138 ##FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu16-c-go:1-u16.04-nng1.1.1
139
140 FROM ubuntu:16.04
141
142 ARG SCHEMA_PATH
143 ARG STAGE_DIR
144
145 ## copy just the needed libraries install it into the final image
146 COPY --from=ricbuild ${STAGE_DIR}/*.deb /tmp/
147 #COPY --from=ricbuild /usr/local/libexec/. /usr/local/libexec/.
148 COPY --from=ricbuild /usr/local/lib/librmr_si* /usr/local/lib/
149 COPY --from=ricbuild /usr/local/lib/libgtest* /usr/local/lib/
150 COPY --from=ricbuild /usr/local/lib/libsdl* /usr/local/lib/
151 COPY --from=ricbuild /usr/local/libexec/redismodule/libredis* /usr/local/libexec/redismodule/
152 RUN dpkg -i /tmp/*.deb
153 RUN apt-get update && \
154     apt-get install -y libcurl3 python3 && \
155     apt-get install -y libboost-all-dev cpputest libhiredis-dev valgrind && \
156     apt-get clean
157 COPY --from=ricbuild /etc/xapp/* /etc/xapp/
158 COPY --from=ricbuild /usr/local/bin/hw_unit_tests /usr/local/bin/hw_unit_tests
159 COPY --from=ricbuild ${STAGE_DIR}/rnib/*.h /usr/local/include/rnib/
160 COPY --from=ricbuild ${STAGE_DIR}/rnibreader_old.a /usr/local/lib/
161
162 ##COPY --from=ricbuild /usr/local/bin/e2e-test-client /usr/local/bin/e2e-test-client
163 ##COPY --from=ricbuild /usr/local/bin/mock-e2term-server /usr/local/bin/mock-e2term-server
164 ##COPY --from=ricbuild /usr/local/bin/e2e-perf-client /usr/local/bin/e2e-perf-client
165 ##COPY --from=ricbuild /usr/local/bin/e2e-perf-server /usr/local/bin/e2e-perf-server
166 ##COPY --from=ricbuild /usr/local/bin/mock-a1-server /usr/local/bin/mock-a1-server
167
168
169 RUN ldconfig
170
171
172 ##ENV  PYTHONHOME=/opt/python3 \
173 ##     PYTHONPATH=/opt/python3 \
174 ENV  RMR_RTG_SVC="9999" \
175      LD_LIBRARY_PATH="/usr/local/lib:/usr/local/libexec" \
176      NAME=ADM_CTRL_XAPP \
177      PORT=tcp:4560 \
178      THREADS=1\
179      VERBOSE=0 \
180      MESSAGE_TYPE=10002 \
181      RATE=1 \
182      CONFIG_FILE=/opt/ric/config/config-file.json \
183      EXE_FILE=/usr/local/bin/hw_unit_tests     
184       
185
186 CMD python3 /etc/xapp/init_script.py $CONFIG_FILE $EXE_FILE