blob: 89811c81f2a86c9a0b66ed6896fd7aacaf99b905 [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#
26###########################################################
27FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:3-u18.04-nng as submgrcore
kalnagy303e57c2019-06-28 15:28:35 +020028
Juha Hyttinen01a4c492020-02-04 19:29:26 +020029RUN apt update && apt install -y iputils-ping net-tools curl tcpdump gdb valgrind
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020030
kalnagye0018682019-09-26 16:28:25 +020031WORKDIR /tmp
kalnagy303e57c2019-06-28 15:28:35 +020032
Juha Hyttinene406a342020-01-13 13:02:26 +020033ARG RMRVERSION=1.13.1
kalnagy303e57c2019-06-28 15:28:35 +020034# Install RMr shared library
Juha Hyttinene406a342020-01-13 13:02:26 +020035RUN 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 +020036# Install RMr development header files
Juha Hyttinene406a342020-01-13 13:02:26 +020037RUN 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 +020038
kalnagy93cc3e22019-09-19 11:29:29 +020039# "Installing Swagger"
40RUN cd /usr/local/go/bin \
41 && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \
42 && mv swagger_linux_amd64 swagger \
43 && chmod +x swagger
44
kalnagye0018682019-09-26 16:28:25 +020045
Juha Hyttinen01a4c492020-02-04 19:29:26 +020046ENV GOPATH=/root/.go
47ENV PATH=$PATH:/root/.go/bin
48RUN /usr/local/go/bin/go get -u github.com/go-delve/delve/cmd/dlv
49
kalnagye0018682019-09-26 16:28:25 +020050WORKDIR /opt/submgr
kalnagye0018682019-09-26 16:28:25 +020051
Juha Hyttinenf44377d2020-02-12 10:18:40 +020052###########################################################
53#
54###########################################################
55FROM submgrcore as submgre2apbuild
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020056
Juha Hyttinenf44377d2020-02-12 10:18:40 +020057
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020058ENV CFLAGS="-DASN_DISABLE_OER_SUPPORT"
59ENV CGO_CFLAGS="-DASN_DISABLE_OER_SUPPORT"
60
61COPY 3rdparty 3rdparty
62RUN cd 3rdparty/libe2ap && \
Juha Hyttinen01a4c492020-02-04 19:29:26 +020063 gcc -c ${CFLAGS} -I. -g -fPIC *.c && \
64 gcc *.o -g -shared -o libe2ap.so && \
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020065 cp libe2ap.so /usr/local/lib/ && \
66 cp *.h /usr/local/include/ && \
kalnagye0018682019-09-26 16:28:25 +020067 ldconfig
68
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020069COPY e2ap e2ap
70RUN cd e2ap/libe2ap_wrapper && \
Juha Hyttinen01a4c492020-02-04 19:29:26 +020071 gcc -c ${CFLAGS} -g -fPIC *.c && \
72 gcc *.o -g -shared -o libe2ap_wrapper.so && \
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020073 cp libe2ap_wrapper.so /usr/local/lib/ && \
74 cp *.h /usr/local/include/ && \
75 ldconfig
76
77# unittest
78RUN cd e2ap && /usr/local/go/bin/go test -v ./pkg/conv
79RUN cd e2ap && /usr/local/go/bin/go test -v ./pkg/e2ap_wrapper
80
81# test formating (not important)
82RUN cd e2ap && test -z "$(/usr/local/go/bin/gofmt -l pkg/conv/*.go)"
83RUN cd e2ap && test -z "$(/usr/local/go/bin/gofmt -l pkg/e2ap_wrapper/*.go)"
84RUN cd e2ap && test -z "$(/usr/local/go/bin/gofmt -l pkg/e2ap/*.go)"
85RUN cd e2ap && test -z "$(/usr/local/go/bin/gofmt -l pkg/e2ap/e2ap_tests/*.go)"
86
Juha Hyttinen55040222020-01-16 09:41:04 +020087
Juha Hyttinenf44377d2020-02-12 10:18:40 +020088###########################################################
89#
90###########################################################
91FROM submgre2apbuild as submgrbuild
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020092#
93#
94#
95COPY go.mod go.mod
96COPY go.sum go.sum
97
98RUN /usr/local/go/bin/go mod download
99
100#
101#
102#
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200103RUN mkdir pkg
kalnagye0018682019-09-26 16:28:25 +0200104COPY api api
105
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200106
107ARG RTMGRVERSION=cd7867c8f527f46fd8702b0b8d6b380a8e134bea
108
kalnagye0018682019-09-26 16:28:25 +0200109RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" \
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200110 && git -C "rtmgr" checkout $RTMGRVERSION \
kalnagy93cc3e22019-09-19 11:29:29 +0200111 && cp rtmgr/api/routing_manager.yaml api/ \
112 && rm -rf rtmgr
113
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200114
kalnagye0018682019-09-26 16:28:25 +0200115RUN mkdir -p /root/go && \
116 /usr/local/go/bin/swagger generate client -f api/routing_manager.yaml -t pkg/ -m rtmgr_models -c rtmgr_client
117
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200118#
119#
120#
kalnagye0018682019-09-26 16:28:25 +0200121COPY pkg pkg
122COPY cmd cmd
123
kalnagye0018682019-09-26 16:28:25 +0200124RUN mkdir -p /opt/bin && \
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200125 /usr/local/go/bin/go build -o /opt/bin/submgr cmd/submgr.go && \
126 mkdir -p /opt/build/container/usr/local
kalnagy303e57c2019-06-28 15:28:35 +0200127
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200128
129RUN /usr/local/go/bin/go mod tidy
130
131# unittest
132COPY test/config-file.json test/config-file.json
133ENV CFG_FILE=/opt/submgr/test/config-file.json
Juha Hyttinene406a342020-01-13 13:02:26 +0200134
Juha Hyttinen01a4c492020-02-04 19:29:26 +0200135RUN /usr/local/go/bin/go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control
136
137#-c -o submgr_test
138#RUN ./submgr_test -test.coverprofile /tmp/submgr_cover.out
Juha Hyttinene406a342020-01-13 13:02:26 +0200139
140RUN /usr/local/go/bin/go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200141
142# test formating (not important)
143RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/control/*.go)"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200144RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/teststub/*.go)"
145RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/teststubdummy/*.go)"
146RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/teststube2ap/*.go)"
147RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/xapptweaks/*.go)"
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200148
Juha Hyttinen01a4c492020-02-04 19:29:26 +0200149
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200150###########################################################
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200151#
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200152###########################################################
kalnagy303e57c2019-06-28 15:28:35 +0200153FROM ubuntu:18.04
154
Balint Uvegescd3881b2019-10-02 15:01:43 +0000155RUN apt update && apt install -y iputils-ping net-tools curl tcpdump
156
kalnagy303e57c2019-06-28 15:28:35 +0200157COPY run_submgr.sh /
Balint Uveges534c8822019-10-09 08:54:53 +0000158COPY --from=submgrbuild /opt/bin/submgr /
kalnagy303e57c2019-06-28 15:28:35 +0200159COPY --from=submgrbuild /usr/local/include /usr/local/include
160COPY --from=submgrbuild /usr/local/lib /usr/local/lib
161RUN ldconfig
162
kalnagy93cc3e22019-09-19 11:29:29 +0200163RUN chmod 755 /run_submgr.sh
kalnagye0018682019-09-26 16:28:25 +0200164CMD /run_submgr.sh