Fetch RIC active alarms via O1
[ric-plt/o1.git] / Dockerfile
1 #   Copyright (c) 2019 AT&T Intellectual Property.
2 #   Copyright (c) 2019 Nokia.
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #
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,
12 #   WITHOUT 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 FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:4-u18.04-nng AS o1mediator-build
18
19 RUN apt-get update -y && apt-get install -y jq \
20       git \
21       cmake \
22       build-essential \
23       vim \
24       supervisor \
25       libpcre3-dev \
26       pkg-config \
27       libavl-dev \
28       libev-dev \
29       libprotobuf-c-dev \
30       protobuf-c-compiler \
31       libssh-dev \
32       libssl-dev \
33       swig \
34       iputils-ping \
35       python-dev
36
37 ENV PATH="/usr/local/go/bin:${PATH}"
38 ENV GOPATH="/go"
39
40 # ======================================================================
41 # First make the netconf sysrepo stuff
42 # add netconf user
43 RUN \
44       adduser --system netconf && \
45       echo "netconf:netconf" | chpasswd
46
47 # generate ssh keys for netconf user
48 RUN \
49       mkdir -p /home/netconf/.ssh && \
50       ssh-keygen -A && \
51       ssh-keygen -t dsa -P '' -f /home/netconf/.ssh/id_dsa && \
52       cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys
53
54 # use /opt/dev as working directory
55 RUN mkdir /opt/dev
56 WORKDIR /opt/dev
57
58 # libyang
59 RUN \
60       cd /opt/dev && \
61       git clone https://github.com/CESNET/libyang.git && \
62       cd libyang && mkdir build && cd build && \
63       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
64       make -j2 && \
65       make install && \
66       ldconfig
67
68 # sysrepo
69 RUN \
70       cd /opt/dev && \
71       git clone https://github.com/sysrepo/sysrepo.git && \
72       cd sysrepo && sed -i -e 's/2000/30000/g;s/5000/30000/g' src/common.h.in && \
73       mkdir build && cd build && \
74       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_TESTS=OFF -DREPOSITORY_LOC:PATH=/etc/sysrepo .. && \
75       make -j2 && \
76       make install && make sr_clean && \
77       ldconfig
78
79 # libnetconf2
80 RUN \
81       cd /opt/dev && \
82       git clone https://github.com/CESNET/libnetconf2.git && \
83       cd libnetconf2 && mkdir build && cd build && \
84       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
85       make -j2 && \
86       make install && \
87       ldconfig
88
89 # netopeer2
90 RUN \
91       cd /opt/dev && \
92       git clone https://github.com/CESNET/Netopeer2.git && \
93       cd Netopeer2/server && mkdir build && cd build && \
94       cmake -DCMAKE_BUILD_TYPE:String="Release" -DNP2SRV_DATA_CHANGE_TIMEOUT=30000 -DNP2SRV_DATA_CHANGE_WAIT=ON .. && \
95       make -j2 && \
96       make install && \
97       cd ../../cli && mkdir build && cd build && \
98       cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
99       make -j2 && \
100       make install
101       
102 # ======================================================================
103
104 # RMR
105 ARG RMRVERSION=3.6.3
106 ARG RMRLIBURL=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb
107 ARG RMRDEVURL=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb
108
109 RUN wget --content-disposition ${RMRLIBURL} && dpkg -i rmr_${RMRVERSION}_amd64.deb
110 RUN wget --content-disposition ${RMRDEVURL} && dpkg -i rmr-dev_${RMRVERSION}_amd64.deb
111 RUN rm -f rmr_${RMRVERSION}_amd64.deb rmr-dev_${RMRVERSION}_amd64.deb
112
113 # Install kubectl from Docker Hub
114 COPY --from=lachlanevenson/k8s-kubectl:v1.16.0 /usr/local/bin/kubectl /usr/local/bin/kubectl
115
116 RUN ldconfig
117
118 # Swagger
119 RUN mkdir -p /go/bin
120 RUN cd /go/bin \
121     && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \
122     && mv swagger_linux_amd64 swagger \
123     && chmod +x swagger
124
125 RUN mkdir -p /go/src/ws
126 COPY . /go/src/ws
127 WORKDIR "/go/src/ws/agent"
128
129 # Module prepare (if go.mod/go.sum updated)
130 RUN GO111MODULE=on go mod download
131
132 # Fetch xApp Manager REST API spec
133 RUN mkdir -p api \
134     && mkdir -p pkg \
135     && git clone "https://gerrit.o-ran-sc.org/r/ric-plt/appmgr" \
136     && cp appmgr/api/appmgr_rest_api.yaml api/ \
137     && rm -rf appmgr
138     
139 # generate swagger client
140 RUN /go/bin/swagger generate client -f api/appmgr_rest_api.yaml -t pkg/ -m appmgrmodel -c appmgrclient
141
142 # build and test o1agent
143 RUN ./build_o1agent.sh
144
145 # Install the data models based on the ric yang model
146 RUN /usr/local/bin/sysrepoctl -i /go/src/ws/agent/yang/o-ran-sc-ric-xapp-desc-v1.yang
147 RUN /usr/local/bin/sysrepoctl -i /go/src/ws/agent/yang/o-ran-sc-ric-ueec-config-v1.yang
148 RUN /usr/local/bin/sysrepoctl -i /go/src/ws/agent/yang/o-ran-sc-ric-gnb-status-v1.yang
149 RUN /usr/local/bin/sysrepoctl -i /go/src/ws/agent/yang/o-ran-sc-ric-alarm-v1.yang
150
151 CMD ["/bin/bash"]
152
153 #----------------------------------------------------------
154 FROM ubuntu:18.04 as o1mediator
155
156 RUN apt-get update -y && apt-get install -y jq \
157       net-tools \
158       tcpdump \
159       netcat \
160       keychain \
161       nano \
162       supervisor \
163       openssl \
164       python-pip \
165       libpcre3-dev \
166       pkg-config \
167       libavl-dev \
168       libev-dev \
169       libprotobuf-c-dev \
170       protobuf-c-compiler \
171       libssh-dev \
172       libssl-dev \
173       swig \
174       python-dev \
175       && pip install supervisor-stdout \
176       && pip install psutil \
177       && apt-get clean
178
179 RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
180
181 # add netconf user
182 RUN \
183       adduser --system netconf && \
184       echo "netconf:netconf" | chpasswd
185
186 # generate ssh keys for netconf user
187 RUN \
188       mkdir -p /home/netconf/.ssh && \
189       ssh-keygen -A && \
190       ssh-keygen -t dsa -P '' -f /home/netconf/.ssh/id_dsa && \
191       cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys
192
193 # copy the supervisor config
194 ARG CONFIGDIR=/etc/supervisor
195 RUN mkdir -p ${CONFIGDIR}
196 COPY config/supervisord.conf ${CONFIGDIR}/supervisord.conf
197     
198 # libraries and binaries & config
199 COPY --from=o1mediator-build /usr/local/share/ /usr/local/share/
200 COPY --from=o1mediator-build /usr/local/etc/ /usr/local/etc/
201 COPY --from=o1mediator-build /usr/local/bin/ /usr/local/bin/
202 COPY --from=o1mediator-build /usr/local/lib/ /usr/local/lib/
203 COPY --from=o1mediator-build /usr/local/bin/kubectl /usr/local/bin/kubectl
204
205 RUN ldconfig
206
207 # copy yang models with data
208 COPY --from=o1mediator-build /etc/sysrepo /etc/sysrepo
209
210 COPY --from=o1mediator-build /go/src/ws/agent/o1agent /usr/local/bin
211 COPY --from=o1mediator-build /go/src/ws/manager/src/process-state.py /usr/local/bin
212 RUN mkdir -p /etc/o1agent
213 COPY --from=o1mediator-build /go/src/ws/agent/config/* /etc/o1agent/
214
215 # ports available outside 8080 for mediator and 9001 supervise http control interrface
216 # port 830 for netconf client ssh session
217 # port 3000 for process-event handler web server
218 EXPOSE 9001 830 8080 3000
219
220 CMD ["/usr/bin/supervisord"]