blob: b49723c01e02623ed9737310d607cf3d88323b25 [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 Hyttinend708a432020-03-09 09:37:06 +020032#RUN git clone https://github.com/nokia/asn1c.git
33#RUN cd asn1c && test -f configure || autoreconf -iv
34#RUN cd asn1c && ./configure
35#RUN cd asn1c && make
36##RUN cd asn1c && make check
37#RUN cd asn1c && make install
38
Juha Hyttinenc2a6b3a2020-03-18 11:45:57 +020039#
40# Swagger
41#
42ARG SWAGGERVERSION=v0.19.0
43ARG SWAGGERURL=https://github.com/go-swagger/go-swagger/releases/download/${SWAGGERVERSION}/swagger_linux_amd64
44RUN wget --quiet ${SWAGGERURL} \
45 && mv swagger_linux_amd64 swagger \
46 && chmod +x swagger \
47 && mv swagger /usr/local/bin/
Juha Hyttinend708a432020-03-09 09:37:06 +020048
Juha Hyttinenc2a6b3a2020-03-18 11:45:57 +020049#
50# GO DELVE
51#
52RUN export GOBIN=/usr/local/bin/ ; \
53 go get -u github.com/go-delve/delve/cmd/dlv \
54 && go install github.com/go-delve/delve/cmd/dlv
55
56
Juha Hyttinen429cfe62020-03-31 11:23:02 +030057#
58# RMR
59#
60ARG RMRVERSION=3.6.2
61ARG RMRLIBURL=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb
62ARG RMRDEVURL=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb
63RUN wget --content-disposition ${RMRLIBURL} && dpkg -i rmr_${RMRVERSION}_amd64.deb
64RUN wget --content-disposition ${RMRDEVURL} && dpkg -i rmr-dev_${RMRVERSION}_amd64.deb
65RUN rm -f rmr_${RMRVERSION}_amd64.deb rmr-dev_${RMRVERSION}_amd64.deb
66
67
68RUN mkdir /manifests/
69RUN echo "rmrlib ${RMRVERSION} ${RMRLIBURL}" >> /manifests/versions.txt
70RUN echo "rmrdev ${RMRVERSION} ${RMRDEVURL}" >> /manifests/versions.txt
71RUN echo "swagger ${SWAGGERVERSION} ${SWAGGERURL}" >> /manifests/versions.txt
kalnagy303e57c2019-06-28 15:28:35 +020072
Juha Hyttinen01a4c492020-02-04 19:29:26 +020073
kalnagye0018682019-09-26 16:28:25 +020074WORKDIR /opt/submgr
kalnagye0018682019-09-26 16:28:25 +020075
Juha Hyttinenf44377d2020-02-12 10:18:40 +020076###########################################################
77#
78###########################################################
79FROM submgrcore as submgre2apbuild
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020080
Juha Hyttinenf44377d2020-02-12 10:18:40 +020081
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020082ENV CFLAGS="-DASN_DISABLE_OER_SUPPORT"
83ENV CGO_CFLAGS="-DASN_DISABLE_OER_SUPPORT"
84
85COPY 3rdparty 3rdparty
86RUN cd 3rdparty/libe2ap && \
Juha Hyttinen01a4c492020-02-04 19:29:26 +020087 gcc -c ${CFLAGS} -I. -g -fPIC *.c && \
88 gcc *.o -g -shared -o libe2ap.so && \
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020089 cp libe2ap.so /usr/local/lib/ && \
90 cp *.h /usr/local/include/ && \
kalnagye0018682019-09-26 16:28:25 +020091 ldconfig
92
Juha Hyttinen429cfe62020-03-31 11:23:02 +030093RUN echo "E2AP ?" >> /manifests/versions.txt
94RUN echo "E2SM-gNB-NRT ?" >> /manifests/versions.txt
95RUN echo "E2SM-gNB-X2 ?" >> /manifests/versions.txt
96
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020097COPY e2ap e2ap
98RUN cd e2ap/libe2ap_wrapper && \
Juha Hyttinen01a4c492020-02-04 19:29:26 +020099 gcc -c ${CFLAGS} -g -fPIC *.c && \
100 gcc *.o -g -shared -o libe2ap_wrapper.so && \
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200101 cp libe2ap_wrapper.so /usr/local/lib/ && \
102 cp *.h /usr/local/include/ && \
103 ldconfig
104
105# unittest
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500106RUN cd e2ap && go test -v ./pkg/conv
107RUN cd e2ap && go test -v ./pkg/e2ap_wrapper
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200108
109# test formating (not important)
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500110RUN cd e2ap && test -z "$(gofmt -l pkg/conv/*.go)"
111RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap_wrapper/*.go)"
112RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/*.go)"
113RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/e2ap_tests/*.go)"
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200114
Juha Hyttinen55040222020-01-16 09:41:04 +0200115
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200116###########################################################
117#
118###########################################################
119FROM submgre2apbuild as submgrbuild
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200120#
121#
122#
123COPY go.mod go.mod
124COPY go.sum go.sum
125
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500126RUN go mod download
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200127RUN go mod tidy
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200128
Juha Hyttinen429cfe62020-03-31 11:23:02 +0300129RUN cp go.mod go.sum /manifests/
130
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200131#
132#
133#
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200134RUN mkdir pkg
kalnagye0018682019-09-26 16:28:25 +0200135COPY api api
136
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200137
138ARG RTMGRVERSION=cd7867c8f527f46fd8702b0b8d6b380a8e134bea
139
kalnagye0018682019-09-26 16:28:25 +0200140RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" \
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200141 && git -C "rtmgr" checkout $RTMGRVERSION \
kalnagy93cc3e22019-09-19 11:29:29 +0200142 && cp rtmgr/api/routing_manager.yaml api/ \
143 && rm -rf rtmgr
144
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200145
kalnagye0018682019-09-26 16:28:25 +0200146RUN mkdir -p /root/go && \
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500147 swagger generate client -f api/routing_manager.yaml -t pkg/ -m rtmgr_models -c rtmgr_client
kalnagye0018682019-09-26 16:28:25 +0200148
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200149
Juha Hyttinen429cfe62020-03-31 11:23:02 +0300150RUN echo "rtmgrapi ${RTMGRVERSION} https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" >> /manifests/versions.txt
151
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200152#
153#
154#
kalnagye0018682019-09-26 16:28:25 +0200155COPY pkg pkg
156COPY cmd cmd
157
kalnagye0018682019-09-26 16:28:25 +0200158RUN mkdir -p /opt/bin && \
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500159 go build -o /opt/bin/submgr cmd/submgr.go && \
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200160 mkdir -p /opt/build/container/usr/local
kalnagy303e57c2019-06-28 15:28:35 +0200161
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200162
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500163RUN go mod tidy
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200164
165# unittest
166COPY test/config-file.json test/config-file.json
167ENV CFG_FILE=/opt/submgr/test/config-file.json
Juha Hyttinenc2a6b3a2020-03-18 11:45:57 +0200168COPY test/uta_rtg.rt test/uta_rtg.rt
169ENV RMR_SEED_RT=/opt/submgr/test/uta_rtg.rt
Juha Hyttinene406a342020-01-13 13:02:26 +0200170
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500171RUN go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control
Juha Hyttinen01a4c492020-02-04 19:29:26 +0200172
173#-c -o submgr_test
174#RUN ./submgr_test -test.coverprofile /tmp/submgr_cover.out
Juha Hyttinene406a342020-01-13 13:02:26 +0200175
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500176RUN go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200177
178# test formating (not important)
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500179RUN test -z "$(gofmt -l pkg/control/*.go)"
180RUN test -z "$(gofmt -l pkg/teststub/*.go)"
181RUN test -z "$(gofmt -l pkg/teststubdummy/*.go)"
182RUN test -z "$(gofmt -l pkg/teststube2ap/*.go)"
183RUN test -z "$(gofmt -l pkg/xapptweaks/*.go)"
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200184
Juha Hyttinen01a4c492020-02-04 19:29:26 +0200185
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200186###########################################################
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200187#
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200188###########################################################
kalnagy303e57c2019-06-28 15:28:35 +0200189FROM ubuntu:18.04
190
Balint Uvegescd3881b2019-10-02 15:01:43 +0000191RUN apt update && apt install -y iputils-ping net-tools curl tcpdump
192
Juha Hyttinen429cfe62020-03-31 11:23:02 +0300193COPY --from=submgrbuild /manifests /manifests
194
kalnagy303e57c2019-06-28 15:28:35 +0200195COPY run_submgr.sh /
Balint Uveges534c8822019-10-09 08:54:53 +0000196COPY --from=submgrbuild /opt/bin/submgr /
kalnagy303e57c2019-06-28 15:28:35 +0200197COPY --from=submgrbuild /usr/local/include /usr/local/include
198COPY --from=submgrbuild /usr/local/lib /usr/local/lib
199RUN ldconfig
200
kalnagy93cc3e22019-09-19 11:29:29 +0200201RUN chmod 755 /run_submgr.sh
kalnagye0018682019-09-26 16:28:25 +0200202CMD /run_submgr.sh