blob: cb71b39a05ce8027dc1770fe059a89e22244bb4f [file] [log] [blame]
kalnagy303e57c2019-06-28 15:28:35 +02001#
2#==================================================================================
3# Copyright (c) 2019 AT&T Intellectual Property.
4# Copyright (c) 2019 Nokia
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#==================================================================================
18#
19#
20# Abstract: Builds a container to compile Subscription Manager's code
21# Date: 28 May 2019
22#
Juha Hyttinenf44377d2020-02-12 10:18:40 +020023###########################################################
24#
25###########################################################
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -050026FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:4-u18.04-nng as submgrcore
kalnagy303e57c2019-06-28 15:28:35 +020027
Juha Hyttinen01a4c492020-02-04 19:29:26 +020028RUN apt update && apt install -y iputils-ping net-tools curl tcpdump gdb valgrind
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020029
kalnagye0018682019-09-26 16:28:25 +020030WORKDIR /tmp
kalnagy303e57c2019-06-28 15:28:35 +020031
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020032ARG RMRVERSION=3.2.4
kalnagy303e57c2019-06-28 15:28:35 +020033# Install RMr shared library
Juha Hyttinene406a342020-01-13 13:02:26 +020034RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb && dpkg -i rmr_${RMRVERSION}_amd64.deb && rm -rf rmr_${RMRVERSION}_amd64.deb
kalnagy303e57c2019-06-28 15:28:35 +020035# Install RMr development header files
Juha Hyttinene406a342020-01-13 13:02:26 +020036RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb && dpkg -i rmr-dev_${RMRVERSION}_amd64.deb && rm -rf rmr-dev_${RMRVERSION}_amd64.deb
kalnagy303e57c2019-06-28 15:28:35 +020037
kalnagy93cc3e22019-09-19 11:29:29 +020038# "Installing Swagger"
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -050039RUN wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \
kalnagy93cc3e22019-09-19 11:29:29 +020040 && mv swagger_linux_amd64 swagger \
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -050041 && chmod +x swagger \
42 && mkdir -p /root/.go/bin \
43 && mv swagger /root/.go/bin
kalnagye0018682019-09-26 16:28:25 +020044
Juha Hyttinen01a4c492020-02-04 19:29:26 +020045ENV GOPATH=/root/.go
46ENV PATH=$PATH:/root/.go/bin
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -050047RUN go get -u github.com/go-delve/delve/cmd/dlv
Juha Hyttinen01a4c492020-02-04 19:29:26 +020048
kalnagye0018682019-09-26 16:28:25 +020049WORKDIR /opt/submgr
kalnagye0018682019-09-26 16:28:25 +020050
Juha Hyttinenf44377d2020-02-12 10:18:40 +020051###########################################################
52#
53###########################################################
54FROM submgrcore as submgre2apbuild
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020055
Juha Hyttinenf44377d2020-02-12 10:18:40 +020056
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020057ENV CFLAGS="-DASN_DISABLE_OER_SUPPORT"
58ENV CGO_CFLAGS="-DASN_DISABLE_OER_SUPPORT"
59
60COPY 3rdparty 3rdparty
Anssi Mannilad2ee0c72020-03-02 15:42:37 +020061RUN cd 3rdparty/E2AP-v01.00.00 && \
Juha Hyttinen01a4c492020-02-04 19:29:26 +020062 gcc -c ${CFLAGS} -I. -g -fPIC *.c && \
63 gcc *.o -g -shared -o libe2ap.so && \
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020064 cp libe2ap.so /usr/local/lib/ && \
65 cp *.h /usr/local/include/ && \
kalnagye0018682019-09-26 16:28:25 +020066 ldconfig
67
Anssi Mannila63ff9952020-03-17 09:57:46 +020068RUN cd 3rdparty/E2SM-gNB-NRT_V4.0.1 && \
69 gcc -c ${CFLAGS} -I. -g -fPIC *.c && \
70 gcc *.o -g -shared -o libgnbnrt.so && \
71 cp libgnbnrt.so /usr/local/lib/ && \
72 cp *.h /usr/local/include/ && \
73 ldconfig
74
75RUN cd 3rdparty/E2SM-gNB-X2-V4.0.1 && \
Anssi Mannilad2ee0c72020-03-02 15:42:37 +020076 gcc -c ${CFLAGS} -I. -g -fPIC *.c && \
77 gcc *.o -g -shared -o libgnbx2.so && \
78 cp libgnbx2.so /usr/local/lib/ && \
79 cp *.h /usr/local/include/ && \
80 ldconfig
81
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020082COPY e2ap e2ap
83RUN cd e2ap/libe2ap_wrapper && \
Juha Hyttinen01a4c492020-02-04 19:29:26 +020084 gcc -c ${CFLAGS} -g -fPIC *.c && \
85 gcc *.o -g -shared -o libe2ap_wrapper.so && \
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020086 cp libe2ap_wrapper.so /usr/local/lib/ && \
87 cp *.h /usr/local/include/ && \
88 ldconfig
89
90# unittest
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -050091RUN cd e2ap && go test -v ./pkg/conv
92RUN cd e2ap && go test -v ./pkg/e2ap_wrapper
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020093
94# test formating (not important)
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -050095RUN cd e2ap && test -z "$(gofmt -l pkg/conv/*.go)"
96RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap_wrapper/*.go)"
97RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/*.go)"
98RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/e2ap_tests/*.go)"
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020099
Juha Hyttinen55040222020-01-16 09:41:04 +0200100
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200101###########################################################
102#
103###########################################################
104FROM submgre2apbuild as submgrbuild
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200105#
106#
107#
108COPY go.mod go.mod
109COPY go.sum go.sum
110
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500111RUN go mod download
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200112RUN go mod tidy
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200113
114#
115#
116#
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200117RUN mkdir pkg
kalnagye0018682019-09-26 16:28:25 +0200118COPY api api
119
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200120
121ARG RTMGRVERSION=cd7867c8f527f46fd8702b0b8d6b380a8e134bea
122
kalnagye0018682019-09-26 16:28:25 +0200123RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" \
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200124 && git -C "rtmgr" checkout $RTMGRVERSION \
kalnagy93cc3e22019-09-19 11:29:29 +0200125 && cp rtmgr/api/routing_manager.yaml api/ \
126 && rm -rf rtmgr
127
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200128
kalnagye0018682019-09-26 16:28:25 +0200129RUN mkdir -p /root/go && \
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500130 swagger generate client -f api/routing_manager.yaml -t pkg/ -m rtmgr_models -c rtmgr_client
kalnagye0018682019-09-26 16:28:25 +0200131
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200132
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200133#
134#
135#
kalnagye0018682019-09-26 16:28:25 +0200136COPY pkg pkg
137COPY cmd cmd
138
kalnagye0018682019-09-26 16:28:25 +0200139RUN mkdir -p /opt/bin && \
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500140 go build -o /opt/bin/submgr cmd/submgr.go && \
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200141 mkdir -p /opt/build/container/usr/local
kalnagy303e57c2019-06-28 15:28:35 +0200142
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200143
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500144RUN go mod tidy
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200145
146# unittest
147COPY test/config-file.json test/config-file.json
148ENV CFG_FILE=/opt/submgr/test/config-file.json
Juha Hyttinene406a342020-01-13 13:02:26 +0200149
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500150RUN go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control
Juha Hyttinen01a4c492020-02-04 19:29:26 +0200151
152#-c -o submgr_test
153#RUN ./submgr_test -test.coverprofile /tmp/submgr_cover.out
Juha Hyttinene406a342020-01-13 13:02:26 +0200154
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500155RUN go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200156
157# test formating (not important)
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500158RUN test -z "$(gofmt -l pkg/control/*.go)"
159RUN test -z "$(gofmt -l pkg/teststub/*.go)"
160RUN test -z "$(gofmt -l pkg/teststubdummy/*.go)"
161RUN test -z "$(gofmt -l pkg/teststube2ap/*.go)"
162RUN test -z "$(gofmt -l pkg/xapptweaks/*.go)"
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200163
Juha Hyttinen01a4c492020-02-04 19:29:26 +0200164
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200165###########################################################
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200166#
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200167###########################################################
kalnagy303e57c2019-06-28 15:28:35 +0200168FROM ubuntu:18.04
169
Balint Uvegescd3881b2019-10-02 15:01:43 +0000170RUN apt update && apt install -y iputils-ping net-tools curl tcpdump
171
kalnagy303e57c2019-06-28 15:28:35 +0200172COPY run_submgr.sh /
Balint Uveges534c8822019-10-09 08:54:53 +0000173COPY --from=submgrbuild /opt/bin/submgr /
kalnagy303e57c2019-06-28 15:28:35 +0200174COPY --from=submgrbuild /usr/local/include /usr/local/include
175COPY --from=submgrbuild /usr/local/lib /usr/local/lib
176RUN ldconfig
177
kalnagy93cc3e22019-09-19 11:29:29 +0200178RUN chmod 755 /run_submgr.sh
kalnagye0018682019-09-26 16:28:25 +0200179CMD /run_submgr.sh