Set listener RMR repo reference to release
[ric-app/mc.git] / sidecars / listener / 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 #       Mnemonic:       Dockerfile
20 #       Abstract:       Build file which creaes a runtime image for the listener.
21 #                               Building should be as simple as:
22 #
23 #                                       docker build -f sidecars/listener/Dockerfile -t mc_listener:xx.xx .
24 #
25 #                               Running the image in a container:
26 #                                       The fifo output directory needs to be mounted to the container
27 #                                       e.g.  -v /exports/mcl/fifos:/tmp/mcl/fifos.  The internal
28 #                                       directory can be supplied on the command line using -d path, but
29 #                                       should not be needed.
30 #
31 #                                       The RMR listen port must be properly exposed to the container. The
32 #                                       internal default is 4560, and can be changed with the -p port option
33 #                                       on the command line (needed if running from docker-compose). Typical
34 #                                       exposure might be  -p <host-port>:4560  on the docker run command.
35 #
36 #                                       The MC listener application does NOT need route table updates and thus
37 #                                       there is NO need to expose the route table generator port on this
38 #                                       container.
39 #
40 #       Date:           22 August 2019
41 #       Author:         E. Scott Daniels
42
43
44 FROM nexus3.o-ran-sc.org:10004/o-ran-sc/bldr-ubuntu18-c-go:9-u18.04 as buildenv
45
46 RUN mkdir /playpen
47
48 RUN apt-get update && apt-get install -y cmake gcc make git g++ wget
49
50 WORKDIR /playpen
51 # Install RMr (runtime and dev) from debian package cached on packagecloud.io
52 ARG RMR_VER=4.4.6
53 ARG RMR_PC_REPO=release
54
55 RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/${RMR_PC_REPO}/packages/debian/stretch/rmr_${RMR_VER}_amd64.deb/download.deb
56 RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/${RMR_PC_REPO}/packages/debian/stretch/rmr-dev_${RMR_VER}_amd64.deb/download.deb
57 RUN dpkg -i rmr_${RMR_VER}_amd64.deb
58 RUN dpkg -i rmr-dev_${RMR_VER}_amd64.deb
59
60 RUN mkdir -p /playpen/bin /playpen/listener/src /playpen/listener/test
61 ARG SRC=src
62 COPY ${SRC}/*.ksh ${SRC}/Makefile ${SRC}/*.h ${SRC}/*.c /playpen/listener/src/
63 COPY ${SRC}/verify_replay.sh ${SRC}/verify.sh /playpen/listener/src/
64
65 ARG TEST=test
66 COPY ${TEST}/*.ksh ${TEST}/Makefile ${TEST}/*.h ${TEST}/*.c /playpen/listener/test/
67
68 # Build all binaries; verify scripts expect them to be in bin, so we must copy too
69 #
70 ENV LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib
71 ENV C_INCLUDE_PATH=/usr/local/include
72 RUN     cd /playpen/listener/src \
73         &&  make -B all \
74         &&  ls -al mc_listener \
75         &&  cp mc_listener sender pipe_reader rdc_replay rdc_extract /playpen/bin/
76
77 # Run unit tests. If they don't pass the build fails here. Tests can be run from src, but expect binaries in bin
78 # so that they can be run in the final image as well.
79 #
80 ENV PATH /playpen/bin:/playpen/listener/src:$PATH
81 RUN    cd /playpen/listener/test \
82         && ./run_unit_test.ksh
83
84 RUN        cd /playpen/listener/src \
85         && /playpen/listener/src/verify.sh \
86         && /playpen/listener/src/verify_replay.sh
87
88
89 # -----  final, smaller image ----------------------------------
90 FROM ubuntu:18.04
91
92 # bash doesn't cut it for run_replay so grab a real shell and clean up as much as we can
93 RUN apt-get update; apt-get install -y ksh
94 RUN rm -fr /var/lib/apt/lists
95
96 # must have rmr runtime to get health check etc
97 COPY --from=buildenv /playpen/rmr_*.deb /tmp/
98 RUN dpkg -i /tmp/rmr_*_amd64.deb
99
100 ARG SRC=src
101 ARG PPSRC=/playpen/listener/src
102
103 RUN mkdir -p /playpen/bin
104
105 # pull from the huge builder image
106 COPY --from=buildenv /usr/local/lib/* /usr/local/lib/
107 COPY --from=buildenv ${PPSRC}/mc_listener ${PPSRC}/sender ${PPSRC}/pipe_reader ${PPSRC}/rdc_replay ${PPSRC}/rdc_extract /playpen/bin/
108
109 # pull from the source
110 COPY ${SRC}/verify_replay.sh ${SRC}/verify.sh ${SRC}/run_replay.sh /playpen/bin/
111 COPY ${SRC}/help.sh /playpen/bin/help
112
113 RUN chmod 755 /playpen/bin/*
114
115 ENV PATH=/playpen/bin:$PATH
116 ENV LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib
117 ENV C_INCLUDE_PATH=/usr/local/include
118
119 CMD [ "/playpen/bin/mc_listener" ]