Update TS xApp for Release D use case
[ric-app/ts.git] / Dockerfile
index a5e2925..f443bbb 100644 (file)
 
 # --------------------------------------------------------------------------------------
 #      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
 # --------------------------------------------------------------------------------------
 
+# the builder has: git, wget, cmake, gcc/g++, make, python2/3. v7 dropped nng support
+#
+FROM nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-ubuntu18-c-go:1.9.0 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
+# versions we snarf from package cloud
+ARG RMR_VER=4.7.4
+# ARG SDL_VER=1.0.4
+ARG XFCPP_VER=2.3.3
+
+# 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
+
+# pull in xapp framework c++
+RUN wget -nv --content-disposition ${PC_REL_URL}/ricxfcpp-dev_${XFCPP_VER}_amd64.deb/download.deb && \
+       wget -nv --content-disposition ${PC_REL_URL}/ricxfcpp_${XFCPP_VER}_amd64.deb/download.deb && \
+       dpkg -i ricxfcpp-dev_${XFCPP_VER}_amd64.deb ricxfcpp_${XFCPP_VER}_amd64.deb
+
+# # 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
+
+RUN git clone https://github.com/Tencent/rapidjson && \
+   cd rapidjson && \
+   mkdir build && \
+   cd build && \
+   cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
+   make install && \
+   cd ${STAGE_DIR} && \
+   rm -rf rapidjson
+
+# install TS curl dependencies
+RUN apt-get update && \
+       apt-get install -y libcurl4-openssl-dev
+
 #
-#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
+# build and install the application(s)
 #
-# else this:
+COPY . /playpen/src/
+RUN cd /playpen/src && \
+       rm -fr .build &&\
+       mkdir  .build && \
+       cd .build && \
+       cmake .. && \
+       make install
+
+# non-programme things that we need to push to final image
 #
-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
-
-
-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
-
-
-COPY ${SRC}/build_rmr.sh /playpen/bin
-RUN bash /playpen/bin/build_rmr.sh -t ${RMR_VER}
-
-COPY ${SRC}/CMakeLists.txt /playpen/factory/
-COPY ${SRC}/src /playpen/factory/src/
-COPY ${SRC}/test /playpen/factory/test/
-#COPY ${SRC}/examples /tmp/examples/
-
-
-COPY ${SRC}/examples /playpen/factory/examples
-COPY ${SRC}/routes.txt /playpen/factory/examples
+COPY assets/bootstrap.rt /playpen/assets
 
 #
-# Run unit tests
+# any scripts that are needed; copy to /playpen/bin
 #
-COPY ${SRC}/test/* /playpen/factory/test/
-RUN cd /playpen/factory/test; bash unit_test.sh
 
-# Go to the factory and build our stuff
-#
-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
 
-RUN cd /playpen/factory/examples; make
+# -----  create final, smaller, image ----------------------------------
+FROM ubuntu:18.04
 
-RUN ls /usr/local/lib
+# # 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
+# ARG SDL_VER=1.0.4
 
+# # sdl doesn't install into /usr/local like everybody else, and we don't want to
+# # hunt for it or copy all of /usr, so we must pull and reinstall it.
+# RUN apt-get update
+# RUN apt-get install -y libboost-filesystem1.65.1 libboost-system1.65.1 libhiredis0.13 wget
+# 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
 
-# -----  final, smaller image ----------------------------------
-FROM ubuntu:18.04
+# RUN rm -fr /var/lib/apt/lists
 
-# 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 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 
+# install TS curl dependencies in the final image
+RUN apt-get update && \
+       apt-get install -y libcurl4-openssl-dev && \
+       apt-get clean
 
-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/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 /usr/local/bin/rmr_probe /usr/local/bin/ts_xapp /usr/local/bin/
+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
+WORKDIR /data
+COPY --from=buildenv /playpen/assets/* /data
 
-WORKDIR /examples/
+# if needed, set RMR vars
+ENV RMR_SEED_RT=/data/bootstrap.rt
+#ENV RMR_RTG_SVC=rm-host:port
+ENV RMR_SRC_ID=service-ricxapp-trafficxapp-rmr.ricxapp:4560
+ENV RMR_VCTL_FILE=/tmp/rmr.v
+RUN echo "2" >/tmp/rmr.v
 
-#CMD [ "make" ]
+# set TS env vars
+ENV TS_CONTROL_URL=http://localhost:5000/api/echo
 
-CMD ./ts_xapp
+CMD [ "/usr/local/bin/ts_xapp" ]