From f7b69b887f7d9022dfdf4128e0c1af0c512f6f2d Mon Sep 17 00:00:00 2001 From: "E. Scott Daniels" Date: Tue, 28 Apr 2020 14:17:08 -0400 Subject: [PATCH] Add docker file to build image Issue-ID: RIC-349 Signed-off-by: E. Scott Daniels Change-Id: I48c498970e02727009fc1ca17cdb1df5bf8cf3d8 --- Dockerfile | 143 +++++++++++++++++++++------------------------------ README | 5 +- assets/bootstrap.rt | 8 +++ examples/Makefile | 3 ++ examples/ts_xapp.cpp | 2 +- rmr-version.yaml | 2 +- 6 files changed, 75 insertions(+), 88 deletions(-) create mode 100644 assets/bootstrap.rt diff --git a/Dockerfile b/Dockerfile index a5e2925..1e29e25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,124 +18,101 @@ # -------------------------------------------------------------------------------------- # Mnemonic: Dockerfile -# Abstract: This can be used to create a base environment for using the xAPP -# framework. It will install RMR and the framework libraries. It also -# installs make and g++ so that it can be used as a builder environment. -# -# The unit tests are executed as a part of the build process; if they are -# not passing then the build will fail. +# Abstract: This dockerfile is used to create an image that can be used to +# run the traffic steering xAPP in a container. # # Building should be as simple as: # -# docker build -f Dockerfile -t ricxfcpp:[version] +# docker build -f Dockerfile -t ric-app-ts:[version] # -# Date: 23 March 2020 +# Date: 27 April 2020 # Author: E. Scott Daniels # -------------------------------------------------------------------------------------- +# nexus seems to use ports rather than adding release, prod, staging to the url :( +# the builder has: git, wget, cmake, gcc/g++, make, python2/3. v7 dropped nng support +# +FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:7-u18.04 as buildenv -FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:6-u18.04-nng as buildenv -RUN mkdir /playpen - -RUN apt-get update && apt-get install -y cmake gcc make git g++ wget - -RUN mkdir /playpen/bin /playpen/factory /playpen/factory/src /playpen/factory/test +# spaces to save things in the build image to copy to final image +RUN mkdir -p /playpen/assets /playpen/src /playpen/bin ARG SRC=. WORKDIR /playpen -# Install RMr (runtime and dev) from debian package cached on packagecloud.io -ARG RMR_VER=3.6.2 - -# if package cloud is actually working, this is preferred -# -#RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_${RMR_VER}_amd64.deb/download.deb -#RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_${RMR_VER}_amd64.deb/download.deb -#RUN dpkg -i rmr_${RMR_VER}_amd64.deb -#RUN dpkg -i rmr-dev_${RMR_VER}_amd64.deb -# -# else this: -# -RUN git config --global http.proxy http://one.proxy.att.com:8080 - - -RUN apt-get install -y cpputest -RUN apt-get remove -y libboost-all-dev -RUN apt-get install -y libboost-all-dev -RUN apt-get install -y libhiredis-dev -RUN apt-get install -y valgrind +# versions we snarf from package cloud +ARG RMR_VER=4.0.2 +ARG SDL_VER=1.0.4 +ARG XFCPP_VER=1.0.0 -RUN git clone https://gerrit.o-ran-sc.org/r/ric-plt/sdl -RUN cd sdl && \ - ./autogen.sh && \ - ./configure && \ - make all && \ - # make test && \ - make install +# package cloud urls for wget +ARG PC_REL_URL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch +ARG PC_STG_URL=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch +# pull in rmr +RUN wget -nv --content-disposition ${PC_REL_URL}/rmr_${RMR_VER}_amd64.deb/download.deb && \ + wget -nv --content-disposition ${PC_REL_URL}/rmr-dev_${RMR_VER}_amd64.deb/download.deb && \ + dpkg -i rmr_${RMR_VER}_amd64.deb rmr-dev_${RMR_VER}_amd64.deb -COPY ${SRC}/build_rmr.sh /playpen/bin -RUN bash /playpen/bin/build_rmr.sh -t ${RMR_VER} +# pull in xapp framework c++ +RUN wget -nv --content-disposition ${PC_STG_URL}/ricxfcpp-dev_${XFCPP_VER}_amd64.deb/download.deb && \ + wget -nv --content-disposition ${PC_STG_URL}/ricxfcpp_${XFCPP_VER}_amd64.deb/download.deb && \ + dpkg -i ricxfcpp-dev_${XFCPP_VER}_amd64.deb ricxfcpp_${XFCPP_VER}_amd64.deb -COPY ${SRC}/CMakeLists.txt /playpen/factory/ -COPY ${SRC}/src /playpen/factory/src/ -COPY ${SRC}/test /playpen/factory/test/ -#COPY ${SRC}/examples /tmp/examples/ +# snarf up SDL dependencies, then pull SDL package and install +RUN apt-get update +RUN apt-get install -y libboost-filesystem1.65.1 libboost-system1.65.1 libhiredis0.13 +RUN wget -nv --content-disposition ${PC_STG_URL}/sdl_${SDL_VER}-1_amd64.deb/download.deb && \ + wget -nv --content-disposition ${PC_STG_URL}/sdl-dev_${SDL_VER}-1_amd64.deb/download.deb &&\ + dpkg -i sdl-dev_${SDL_VER}-1_amd64.deb sdl_${SDL_VER}-1_amd64.deb -COPY ${SRC}/examples /playpen/factory/examples -COPY ${SRC}/routes.txt /playpen/factory/examples - # -# Run unit tests +# build and install the application # -COPY ${SRC}/test/* /playpen/factory/test/ -RUN cd /playpen/factory/test; bash unit_test.sh +COPY examples/* /playpen/src/ +RUN cd /playpen/src && make && make install + -# Go to the factory and build our stuff +# non-programme things that we need to push to final image # -ENV LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/lib -ENV C_INCLUDE_PATH=/usr/local/include -RUN cd /playpen/factory; rm -fr .build; mkdir .build; cd .build; cmake .. -DDEV_PKG=1; make install; cmake .. -DDEV_PKG=0; make install +COPY assets/bootstrap.rt /playpen/assets -RUN cd /playpen/factory/examples; make +# +# any scripts that are needed; copy to /playpen/bin +# -RUN ls /usr/local/lib -# ----- final, smaller image ---------------------------------- +# ----- create final, smaller, image ---------------------------------- FROM ubuntu:18.04 -# must add compile tools to make it a builder environmnent. If a build environment isn't needed -# comment out the next line and reduce the image size by more than 180M. -# -RUN apt-get update && apt-get install -y --no-install-recommends make g++ +# if bash doesn't cut it for something, grab ksh, then clean up as much as possible +#RUN apt-get update; apt-get install -y ksh +RUN rm -fr /var/lib/apt/lists -# if bash doesn't cut it for run_replay grab a real shell and clean up as much as we can -RUN apt-get update; apt-get install -y ksh -RUN rm -fr /var/lib/apt/lists - -RUN mkdir -p /usr/local/include/ricxfcpp +# snarf the various sdl, rmr, and cpp-framework libraries as well as any binaries +# created (e.g. rmr_rprobe) and the application binary itself +# COPY --from=buildenv /usr/local/lib /usr/local/lib/ -COPY --from=buildenv /usr/local/include/ricxfcpp /usr/local/include/ricxfcpp/ -COPY --from=buildenv /usr/local/include/rmr /usr/local/include/rmr/ -COPY --from=buildenv /usr/local/lib /usr/local/lib +COPY --from=buildenv /usr/local/bin/rmr_probe /usr/local/bin/ts_xapp /usr/local/bin/ COPY --from=buildenv /usr/lib /usr/lib/ - -RUN mkdir -p /examples/ -COPY --from=buildenv /playpen/factory/examples/ts_xapp /examples/ -COPY --from=buildenv /playpen/factory/examples/routes.txt /examples/ +COPY --from=buildenv /playpen/bin /usr/local/bin/ +COPY --from=buildenv /playpen/assets /data +ENV PATH=/usr/local/bin:$PATH ENV LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib -ENV C_INCLUDE_PATH=/usr/local/include - -ENV RMR_SEED_RT="routes.txt" -#WORKDIR /factory +#ENV RMR_SEED_RT="routes.txt" -WORKDIR /examples/ +WORKDIR /data +COPY --from=buildenv /playpen/assets/* /data -#CMD [ "make" ] +# if needed, set RMR vars +#ENV RMR_RTG_SVC=rm-host:port +#ENV RMR_VCTL_FILE=/tmp/rmr.v +ENV RMR_SEED_RT=/data/bootstrap.rt -CMD ./ts_xapp +#CMD [ "ts_xapp_start.sh" ] +CMD [ "/usr/local/bin/ts_xapp" ] diff --git a/README b/README index e4dc3ff..a5ef7ae 100644 --- a/README +++ b/README @@ -16,7 +16,6 @@ limitations under the License. ================================================================================== -xAPP C++ Framework +Traffic Steering -This repository contains a "framework" on which C++ RIC applications (xAPPs) -can be built. +This repository contains the source for the RIC traffic steering application. diff --git a/assets/bootstrap.rt b/assets/bootstrap.rt new file mode 100644 index 0000000..5bf8602 --- /dev/null +++ b/assets/bootstrap.rt @@ -0,0 +1,8 @@ +# bootstrap route table + +newrt | start +rte | 20011 | service-ricplt-a1mediator-rmr:4562 + +# what is TS_UE_LIST's value? +#rte | TS_UE_LIST | service-ricxapp-qpd:4560 +newrt | end diff --git a/examples/Makefile b/examples/Makefile index 07830bc..08a350b 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -28,3 +28,6 @@ g++ $< -g -o $@ -lricxfcpp -lrmr_si -lpthread -lm -lsdl all:: ts_xapp + +install:: + cp ts_xapp /usr/local/bin/ diff --git a/examples/ts_xapp.cpp b/examples/ts_xapp.cpp index bd51be9..50ed0ab 100644 --- a/examples/ts_xapp.cpp +++ b/examples/ts_xapp.cpp @@ -98,7 +98,7 @@ void policy_callback( Message& mbuf, int mtype, int subid, int len, Msg_componen fprintf(stderr, "cb 2"); send_payload = msg->Get_payload(); // direct access to payload - snprintf( (char *) send_payload.get(), 2048, "{\"UEPredictionSet\" : [\"222\", \"333\", \"444\"]}", i ); + snprintf( (char *) send_payload.get(), 2048, "{\"UEPredictionSet\" : [\"222\", \"333\", \"444\"]}" ); fprintf(stderr, "cb 3"); diff --git a/rmr-version.yaml b/rmr-version.yaml index 5dd30dc..c03848e 100644 --- a/rmr-version.yaml +++ b/rmr-version.yaml @@ -1,3 +1,3 @@ # Communicate to CI which version of RMR to install in the build/vet environment --- -version: 3.6.2 +version: 4.0.2 -- 2.16.6