Release 1.2.2
[ric-app/ts.git] / Dockerfile
1 # vim: ts=4 sw=4 noet:
2 #==================================================================================
3 #       Copyright (c) 2018-2019 AT&T Intellectual Property.
4 #
5 #   Licensed under the Apache License, Version 2.0 (the "License");
6 #   you may not use this file except in compliance with the License.
7 #   You may obtain a copy of the License at
8 #
9 #          http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #   Unless required by applicable law or agreed to in writing, software
12 #   distributed under the License is distributed on an "AS IS" BASIS,
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #   See the License for the specific language governing permissions and
15 #   limitations under the License.
16 #==================================================================================
17
18
19 # --------------------------------------------------------------------------------------
20 #       Mnemonic:       Dockerfile
21 #       Abstract:       This dockerfile is used to create an image that can be used to
22 #                               run the traffic steering xAPP in a container.
23 #
24 #                               Building should be as simple as:
25 #
26 #                                       docker build -f Dockerfile -t ric-app-ts:[version] .
27 #
28 #       Date:           27 April 2020
29 #       Author:         E. Scott Daniels
30 # --------------------------------------------------------------------------------------
31
32 # the builder has: git, wget, cmake, gcc/g++, make, python2/3. v7 dropped nng support
33 #
34 FROM nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-ubuntu20-c-go:1.0.0 as buildenv
35
36 # spaces to save things in the build image to copy to final image
37 RUN mkdir -p /playpen/assets /playpen/src /playpen/bin
38 ARG SRC=.
39
40 WORKDIR /playpen
41
42 # versions we snarf from package cloud
43 ARG RMR_VER=4.8.1
44 # ARG SDL_VER=1.4.0
45 ARG XFCPP_VER=2.3.6
46
47 # package cloud urls for wget
48 ARG PC_REL_URL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch
49 # ARG PC_STG_URL=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch
50
51 # pull in rmr
52 RUN wget -nv --content-disposition ${PC_REL_URL}/rmr_${RMR_VER}_amd64.deb/download.deb && \
53         wget -nv --content-disposition ${PC_REL_URL}/rmr-dev_${RMR_VER}_amd64.deb/download.deb && \
54         dpkg -i rmr_${RMR_VER}_amd64.deb rmr-dev_${RMR_VER}_amd64.deb
55
56 # pull in xapp framework c++
57 RUN wget -nv --content-disposition ${PC_REL_URL}/ricxfcpp-dev_${XFCPP_VER}_amd64.deb/download.deb && \
58         wget -nv --content-disposition ${PC_REL_URL}/ricxfcpp_${XFCPP_VER}_amd64.deb/download.deb && \
59         dpkg -i ricxfcpp-dev_${XFCPP_VER}_amd64.deb ricxfcpp_${XFCPP_VER}_amd64.deb
60
61 # # snarf up SDL dependencies, then pull SDL package and install
62 # RUN apt-get update && apt-get install -y \
63 #       libboost-filesystem1.67.0 \
64 #       libboost-system1.67.0 \
65 #       libhiredis-dev \
66 #       libhiredis0.14 \
67 #       && apt-get clean
68 # RUN wget -nv --content-disposition ${PC_REL_URL}/sdl_${SDL_VER}-1_amd64.deb/download.deb && \
69 #       wget -nv --content-disposition ${PC_REL_URL}/sdl-dev_${SDL_VER}-1_amd64.deb/download.deb &&\
70 #       dpkg -i sdl-dev_${SDL_VER}-1_amd64.deb sdl_${SDL_VER}-1_amd64.deb
71
72 RUN git clone https://github.com/Tencent/rapidjson && \
73    cd rapidjson && \
74    mkdir build && \
75    cd build && \
76    cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
77    make install && \
78    cd ../../ && \
79    rm -rf rapidjson
80
81 # install curl and gRPC dependencies
82 RUN apt-get update && apt-get install -y \
83         libcurl4-openssl-dev \
84         libprotobuf-dev \
85         libgrpc++-dev
86
87 #
88 # build and install the application(s)
89 #
90 COPY . /playpen/src/
91 RUN cd /playpen/src && \
92         rm -fr .build &&\
93         mkdir  .build && \
94         cd .build && \
95         cmake .. && \
96         make install
97
98 # non-programme things that we need to push to final image
99 #
100 COPY assets/bootstrap.rt /playpen/assets
101
102 #
103 # any scripts that are needed; copy to /playpen/bin
104 #
105
106
107 # -----  create final, smaller, image ----------------------------------
108 FROM ubuntu:20.04
109
110 # # package cloud urls for wget
111 # ARG PC_REL_URL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch
112 # ARG PC_STG_URL=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch
113 # ARG SDL_VER=1.0.4
114
115 # # sdl doesn't install into /usr/local like everybody else, and we don't want to
116 # # hunt for it or copy all of /usr, so we must pull and reinstall it.
117 # RUN apt-get update && apt-get install -y \
118 #       libboost-filesystem1.67.0 \
119 #       libboost-system1.67.0 \
120 #       libhiredis-dev \
121 #       libhiredis0.14 \
122 #       && apt-get clean
123 # RUN wget -nv --content-disposition ${PC_REL_URL}/sdl_${SDL_VER}-1_amd64.deb/download.deb && \
124 #       wget -nv --content-disposition ${PC_REL_URL}/sdl-dev_${SDL_VER}-1_amd64.deb/download.deb &&\
125 #       dpkg -i sdl-dev_${SDL_VER}-1_amd64.deb sdl_${SDL_VER}-1_amd64.deb
126
127 # RUN rm -fr /var/lib/apt/lists
128
129 # install curl and gRPC dependencies in the final image
130 RUN apt-get update && apt-get install -y \
131         libcurl4-openssl-dev \
132         libprotobuf-dev \
133         libgrpc++-dev && \
134         rm -rf /var/lib/apt/lists/*
135
136
137 # snarf the various sdl, rmr, and cpp-framework libraries as well as any binaries
138 # created (e.g. rmr_rprobe) and the application binary itself
139 #
140 COPY --from=buildenv /usr/local/lib /usr/local/lib/
141 COPY --from=buildenv /usr/local/bin/rmr_probe /usr/local/bin/ts_xapp /usr/local/bin/
142 COPY --from=buildenv /playpen/bin /usr/local/bin/
143 COPY --from=buildenv /playpen/assets /data
144
145
146 ENV PATH=/usr/local/bin:$PATH
147 ENV LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib
148
149 WORKDIR /data
150 COPY --from=buildenv /playpen/assets/* /data
151
152 # if needed, set RMR vars
153 ENV RMR_SEED_RT=/data/bootstrap.rt
154 #ENV RMR_RTG_SVC=rm-host:port
155 ENV RMR_SRC_ID=service-ricxapp-trafficxapp-rmr.ricxapp:4560
156 ENV RMR_VCTL_FILE=/tmp/rmr.v
157 RUN echo "2" >/tmp/rmr.v
158
159 CMD [ "/usr/local/bin/ts_xapp" ]