1 # Copyright (c) 2019 AT&T Intellectual Property.
2 # Copyright (c) 2019 Nokia.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 #----------------------------------------------------------
17 FROM nexus3.o-ran-sc.org:10004/o-ran-sc/bldr-ubuntu18-c-go:9-u18.04 AS o1mediator-build
19 RUN apt-get update -y && apt-get install -y jq \
37 ENV PATH="/usr/local/go/bin:${PATH}"
40 # ======================================================================
41 # First make the netconf sysrepo stuff
44 adduser --system netconf && \
45 echo "netconf:netconf" | chpasswd
47 # generate ssh keys for netconf user
49 mkdir -p /home/netconf/.ssh && \
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
54 # use /opt/dev as working directory
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 .. && \
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 .. && \
76 make install && make sr_clean && \
82 git clone https://git.libssh.org/projects/libssh.git && cd libssh && \
83 mkdir build && cd build && \
84 cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE="Release" -DWITH_ZLIB=ON -DWITH_NACL=OFF -DWITH_PCAP=OFF .. && \
91 git clone https://github.com/CESNET/libnetconf2.git && \
92 cd libnetconf2 && mkdir build && cd build && \
93 cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
101 git clone https://github.com/CESNET/Netopeer2.git && \
102 cd Netopeer2 && mkdir build && cd build && \
103 cmake -DCMAKE_BUILD_TYPE:String="Release" -DNP2SRV_DATA_CHANGE_TIMEOUT=30000 -DNP2SRV_DATA_CHANGE_WAIT=ON .. && \
107 # ======================================================================
111 ARG RMRLIBURL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb
112 ARG RMRDEVURL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb
114 RUN wget --content-disposition ${RMRLIBURL} && dpkg -i rmr_${RMRVERSION}_amd64.deb
115 RUN wget --content-disposition ${RMRDEVURL} && dpkg -i rmr-dev_${RMRVERSION}_amd64.deb
116 RUN rm -f rmr_${RMRVERSION}_amd64.deb rmr-dev_${RMRVERSION}_amd64.deb
118 # Install kubectl from Docker Hub
119 COPY --from=lachlanevenson/k8s-kubectl:v1.16.0 /usr/local/bin/kubectl /usr/local/bin/kubectl
126 && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \
127 && mv swagger_linux_amd64 swagger \
130 RUN mkdir -p /go/src/ws
132 WORKDIR "/go/src/ws/agent"
134 # Module prepare (if go.mod/go.sum updated)
135 RUN GO111MODULE=on go mod download
137 # Fetch xApp Manager REST API spec
140 && git clone "https://gerrit.o-ran-sc.org/r/ric-plt/appmgr" \
141 && cp appmgr/api/appmgr_rest_api.yaml api/ \
144 # generate swagger client
145 RUN /go/bin/swagger generate client -f api/appmgr_rest_api.yaml -t pkg/ -m appmgrmodel -c appmgrclient
147 # build and test o1agent
148 RUN ./build_o1agent.sh
150 # Install the data models based on the ric yang model
151 RUN /usr/local/bin/sysrepoctl -i /go/src/ws/agent/yang/o-ran-sc-ric-xapp-desc-v1.yang
152 RUN /usr/local/bin/sysrepoctl -i /go/src/ws/agent/yang/o-ran-sc-ric-ueec-config-v1.yang
153 RUN /usr/local/bin/sysrepoctl -i /go/src/ws/agent/yang/o-ran-sc-ric-gnb-status-v1.yang
154 RUN /usr/local/bin/sysrepoctl -i /go/src/ws/agent/yang/o-ran-sc-ric-alarm-v1.yang
158 #----------------------------------------------------------
159 FROM ubuntu:18.04 as o1mediator
161 RUN apt-get update -y && apt-get install -y jq \
175 protobuf-c-compiler \
180 && pip install supervisor-stdout \
181 && pip install psutil \
184 RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
188 adduser --system netconf && \
189 echo "netconf:netconf" | chpasswd
191 # generate ssh keys for netconf user
193 mkdir -p /home/netconf/.ssh && \
195 ssh-keygen -t dsa -P '' -f /home/netconf/.ssh/id_dsa && \
196 cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys
198 # copy the supervisor config
199 ARG CONFIGDIR=/etc/supervisor
200 RUN mkdir -p ${CONFIGDIR}
201 COPY config/supervisord.conf ${CONFIGDIR}/supervisord.conf
203 # libraries and binaries & config
204 COPY --from=o1mediator-build /usr/local/share/ /usr/local/share/
205 COPY --from=o1mediator-build /usr/local/etc/ /usr/local/etc/
206 COPY --from=o1mediator-build /usr/local/bin/ /usr/local/bin/
207 COPY --from=o1mediator-build /usr/local/lib/ /usr/local/lib/
208 COPY --from=o1mediator-build /usr/local/bin/kubectl /usr/local/bin/kubectl
212 # copy yang models with data
213 COPY --from=o1mediator-build /etc/sysrepo /etc/sysrepo
215 COPY --from=o1mediator-build /go/src/ws/agent/o1agent /usr/local/bin
216 COPY --from=o1mediator-build /go/src/ws/manager/src/process-state.py /usr/local/bin
217 RUN mkdir -p /etc/o1agent
218 COPY --from=o1mediator-build /go/src/ws/agent/config/* /etc/o1agent/
220 # ports available outside 8080 for mediator and 9001 supervise http control interrface
221 # port 830 for netconf client ssh session
222 # port 3000 for process-event handler web server
223 EXPOSE 9001 830 8080 3000
225 CMD ["/usr/bin/supervisord"]