Switching to riclibe2ap
[ric-app/hw.git] / Dockerfile
1 #/*
2 #==================================================================================
3 #
4 #        Copyright (c) 2020-2021 AT&T Intellectual Property.
5 #
6 #   Licensed under the Apache License, Version 2.0 (the "License");
7 #   you may not use this file except in compliance with the License.
8 #   You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 #   Unless required by applicable law or agreed to in writing, software
13 #   distributed under the License is distributed on an "AS IS" BASIS,
14 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #   See the License for the specific language governing permissions and
16 #   limitations under the License.
17 #==================================================================================
18 # */
19
20 ARG SCHEMA_PATH=schemas
21 ARG STAGE_DIR=/tmp/helloworld-xapp
22
23 #==================================================================================
24 FROM nexus3.o-ran-sc.org:10001/ubuntu:18.04 as ricbuild
25
26 # to override repo base, pass in repo argument when running docker build:
27 # docker build --build-arg REPOBASE=http://abc.def.org . ....
28 ARG REPOBASE=https://gerrit.oran-osc.org/r
29 ARG SCHEMA_FILE
30 ARG SCHEMA_PATH
31 ARG STAGE_DIR
32
33 # Install necessary packages
34 WORKDIR ${STAGE_DIR}
35 RUN apt-get update  \
36      && apt-get install -y \
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/release/packages/debian/stretch/mdclog_${MDC_VER}_amd64.deb/download.deb
54 RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/release/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=4.4.6
60 RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr_${RMR_VER}_amd64.deb/download.deb
61 RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/release/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 #Install ASN1C library package hosted at packagecloud.io
66 ARG ASN1C_VER=0.1.0
67 RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/riclibe2ap_${ASN1C_VER}_amd64.deb/download.deb
68 RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/riclibe2ap-dev_${ASN1C_VER}_amd64.deb/download.deb
69 RUN dpkg -i riclibe2ap_${ASN1C_VER}_amd64.deb
70 RUN dpkg -i riclibe2ap-dev_${ASN1C_VER}_amd64.deb
71
72
73 #Install RNIB libraries
74 ARG RNIB_VER=1.0.0
75 RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rnib_${RNIB_VER}_all.deb/download.deb
76 RUN dpkg -i rnib_${RNIB_VER}_all.deb
77
78 ## Install SDL Libraries
79 WORKDIR ${STAGE_DIR}
80 RUN apt-get install -y cpputest
81 RUN apt-get remove -y libboost-all-dev
82 RUN apt-get install -y  libboost-all-dev
83 RUN apt-get install -y libhiredis-dev
84 #RUN apt-get install -y valgrind
85
86 RUN git clone https://gerrit.o-ran-sc.org/r/ric-plt/dbaas
87 RUN cd dbaas/redismodule && \
88     ./autogen.sh && \
89     ./configure && \
90     make all && \
91     make install
92
93 WORKDIR ${STAGE_DIR}
94 RUN git clone https://gerrit.o-ran-sc.org/r/ric-plt/sdl
95 RUN cd sdl && \
96     ./autogen.sh && \
97     ./configure && \
98     make all && \
99     make install
100
101
102 WORKDIR ${STAGE_DIR}
103 ## Install rapidjson
104
105 RUN git clone https://github.com/Tencent/rapidjson && \
106     cd rapidjson && \
107     mkdir build && \
108     cd build && \
109     cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
110     make install && \
111     cd ${STAGE_DIR} && \
112     rm -rf rapidjson
113
114 ##-----------------------------------
115 # Now install the program
116 #------------------------------------
117 COPY ./ ${STAGE_DIR}
118 RUN ls -al
119
120
121 RUN export CPATH=$CPATH:/usr/local/include && \ 
122     cd src && \
123 #    source ./xapp_env.sh \
124     make clean && \
125     make install 
126
127 COPY ${SCHEMA_PATH}/* /etc/xapp/ 
128 COPY init/init_script.py /etc/xapp/init_script.py
129 COPY init/routes.txt  /etc/xapp/routes.txt
130 #---------------------------------------------
131 # #Build the final version
132
133 FROM ubuntu:18.04
134 ARG SCHEMA_PATH
135 ARG STAGE_DIR
136
137 ## copy just the needed libraries install it into the final image
138 COPY --from=ricbuild ${STAGE_DIR}/*.deb /tmp/
139 COPY --from=ricbuild /usr/local/lib/librmr_si* /usr/local/lib/
140 COPY --from=ricbuild /usr/local/lib/libsdl* /usr/local/lib/
141 COPY --from=ricbuild /usr/local/include/riclibe2ap /usr/local/include/
142 COPY --from=ricbuild /usr/local/libexec/redismodule/libredis* /usr/local/libexec/redismodule/
143 RUN dpkg -i /tmp/*.deb
144 RUN apt-get update && \
145     apt-get install -y libcurl3 python3 && \
146     apt-get install -y libboost-all-dev cpputest libhiredis-dev valgrind && \
147     apt-get clean
148 COPY --from=ricbuild /etc/xapp/* /etc/xapp/
149 COPY --from=ricbuild /usr/local/bin/hw_xapp_main /usr/local/bin/hw_xapp_main
150 COPY --from=ricbuild /usr/local/include/rnib/*.h /usr/local/include/rnib/
151 COPY --from=ricbuild /usr/local/include/rnib/rnibreader.a /usr/local/include/rnib/
152
153
154 RUN ldconfig
155 RUN sysctl -w net.ipv6.conf.lo.disable_ipv6=1
156
157 ##ENV  PYTHONHOME=/opt/python3 \
158 ##     PYTHONPATH=/opt/python3 \
159 ENV  RMR_RTG_SVC="9999" \
160      RMR_SEED_RT="/etc/xapp/routes.txt" \
161      LD_LIBRARY_PATH="/usr/local/lib:/usr/local/libexec" \
162      VERBOSE=0 \
163      CONFIG_FILE=/opt/ric/config/config-file.json
164      
165       
166
167 CMD python3 /etc/xapp/init_script.py $CONFIG_FILE