90fffc254f9ab9802e5ce59354ecbab587e5ad2f
[ric-app/mc.git] / ci / mc-core / Dockerfile
1 # -------------------------------------------------------------------------------
2 #    Copyright (c) 2018-2019 AT&T Intellectual Property.
3 #
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
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15 # -------------------------------------------------------------------------------
16
17 #       Mnemonic:       Dockerfile (mc_core)
18 #       Abstract:       Build file which creaes a runtime image for the MC-xAPP core process.
19 #                               Building should be as simple as:
20 #
21 #                                       docker build -f ci/mc_core/Dockerfile -t mcxapp .
22 #
23 #                               The build MUST be run from the repo root as it is impossible to 
24 #                               reference the needed source from inside of this directory.
25 #
26
27 ARG STAGE_DIR=/mc
28 ARG SRC=mc-core
29
30 FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu16-c-go:2-u16.04-nng AS project-build
31 # Update & installation of linux packages
32 RUN apt-get update -y && \
33         apt-get install -y curl && \
34         apt-get install -y procps && \
35         apt-get install -y python-pip
36
37 ARG STAGE_DIR
38 ARG SRC
39
40 COPY ${SRC}/mc ${STAGE_DIR}
41 WORKDIR ${STAGE_DIR}
42 RUN git clone https://github.com/protocolbuffers/protobuf.git
43 WORKDIR ${STAGE_DIR}/protobuf
44 RUN ./autogen.sh
45 RUN ./configure
46 RUN make clean
47 RUN make
48 RUN make install
49 RUN ldconfig
50 WORKDIR ${STAGE_DIR}
51 RUN git clone https://github.com/protobuf-c/protobuf-c.git
52 WORKDIR protobuf-c
53 RUN ./autogen.sh
54 ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig
55 RUN ./configure
56 RUN make
57 RUN make install
58 RUN ldconfig
59 RUN pip install protobuf
60 WORKDIR ${STAGE_DIR}
61 RUN git clone https://gerrit.o-ran-sc.org/r/com/gs-lite
62 WORKDIR ${STAGE_DIR}/gs-lite
63 COPY ${SRC}/mc/cfg ${STAGE_DIR}/gs-lite/cfg
64 COPY ${SRC}/mc/local_datasource ${STAGE_DIR}/gs-lite/src/lib/gscprts/local_datasource
65 COPY ${SRC}/mc/local ${STAGE_DIR}/gs-lite/include/lfta/local
66 COPY ${SRC}/mc/queries ${STAGE_DIR}/gs-lite/demo/queries
67 RUN ./build_and_install.sh
68 WORKDIR ${STAGE_DIR}/gs-lite/demo/queries
69 ENV GSLITE_ROOT ${STAGE_DIR}/gs-lite
70 RUN bash ${STAGE_DIR}/gs-lite/bin/buildit
71
72
73 # now install the binaries and libraries into smaller docker image
74 FROM ubuntu:16.04
75
76 ARG STAGE_DIR
77
78 COPY --from=project-build ${STAGE_DIR}/gs-lite/demo/queries /mc/gs-lite/demo/queries
79 COPY --from=project-build ${STAGE_DIR}/gs-lite/bin /mc/gs-lite/bin
80 COPY --from=project-build ${STAGE_DIR}/data_gen /mc/data_gen
81 COPY --from=project-build ${STAGE_DIR}/mc_deployment.json /mc/
82 COPY --from=project-build ${STAGE_DIR}/extract_params.py /mc/
83 COPY --from=project-build /usr/local/lib/libproto* /usr/local/lib/
84
85 RUN apt-get update && \
86     apt-get install -y curl python python-pip && \
87     apt-get clean
88
89 RUN ldconfig
90 RUN pip install protobuf
91
92 ENV XAPP_DESCRIPTOR_PATH /mc/mc_deployment.json
93 WORKDIR /mc/gs-lite/demo/queries
94 ENV GSLITE_ROOT /mc/gs-lite
95 CMD ["./runall"]