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:10002/o-ran-sc/bldr-ubuntu20-c-go:1.0.0 AS o1mediator-build
19 RUN apt update && apt install --reinstall -y \
22 update-ca-certificates
24 RUN apt-get update -y && apt-get install -y jq \
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}"
47 # ======================================================================
48 # First make the netconf sysrepo stuff
51 adduser --system netconf && \
52 echo "netconf:netconf" | chpasswd
54 # generate ssh keys for netconf user
56 mkdir -p /home/netconf/.ssh && \
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
61 # use /opt/dev as working directory
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 .. && \
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 .. && \
82 make install && make sr_clean && \
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 .. && \
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 .. && \
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 .. && \
113 # ======================================================================
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
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
124 # Install kubectl from Docker Hub
125 COPY --from=lachlanevenson/k8s-kubectl:v1.16.0 /usr/local/bin/kubectl /usr/local/bin/kubectl
132 && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \
133 && mv swagger_linux_amd64 swagger \
136 RUN mkdir -p /go/src/ws
138 WORKDIR "/go/src/ws/agent"
140 # Module prepare (if go.mod/go.sum updated)
141 RUN GO111MODULE=on go mod download
143 # Fetch xApp Manager REST API spec
146 && git clone "https://gerrit.o-ran-sc.org/r/ric-plt/appmgr" \
147 && cp appmgr/api/appmgr_rest_api.yaml api/ \
150 # generate swagger client
151 RUN /go/bin/swagger generate client -f api/appmgr_rest_api.yaml -t pkg/ -m appmgrmodel -c appmgrclient
153 # build and test o1agent
154 RUN ./build_o1agent.sh
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
164 #----------------------------------------------------------
165 FROM ubuntu:20.04 as o1mediator
167 RUN apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -y jq \
181 protobuf-c-compiler \
186 && pip install supervisor-stdout \
187 && pip install psutil \
190 RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
192 # update password policy
194 sed -i 's/pam_unix.so obscure sha512/pam_unix.so obscure sha512 rounds=12000/' /etc/pam.d/common-password
198 adduser --system netconf && \
199 echo "netconf:netconf" | chpasswd
201 # generate ssh keys for netconf user
203 mkdir -p /home/netconf/.ssh && \
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
208 # copy the supervisor config
209 ARG CONFIGDIR=/etc/supervisor
210 RUN mkdir -p ${CONFIGDIR}
211 COPY config/supervisord.conf ${CONFIGDIR}/supervisord.conf
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
222 # copy yang models with data
223 COPY --from=o1mediator-build /etc/sysrepo /etc/sysrepo
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/
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
235 CMD ["/usr/bin/supervisord"]