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