blob: 939e0a33d085666660a81fd067ac4a5f69ca0db8 [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
129#
130#
131#
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200132RUN mkdir pkg
kalnagye0018682019-09-26 16:28:25 +0200133COPY api api
134
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200135
136ARG RTMGRVERSION=cd7867c8f527f46fd8702b0b8d6b380a8e134bea
137
kalnagye0018682019-09-26 16:28:25 +0200138RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" \
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200139 && git -C "rtmgr" checkout $RTMGRVERSION \
kalnagy93cc3e22019-09-19 11:29:29 +0200140 && cp rtmgr/api/routing_manager.yaml api/ \
141 && rm -rf rtmgr
142
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200143
kalnagye0018682019-09-26 16:28:25 +0200144RUN mkdir -p /root/go && \
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500145 swagger generate client -f api/routing_manager.yaml -t pkg/ -m rtmgr_models -c rtmgr_client
kalnagye0018682019-09-26 16:28:25 +0200146
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200147
Juha Hyttinen429cfe62020-03-31 11:23:02 +0300148RUN echo "rtmgrapi ${RTMGRVERSION} https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" >> /manifests/versions.txt
149
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200150#
151#
152#
kalnagye0018682019-09-26 16:28:25 +0200153COPY pkg pkg
154COPY cmd cmd
155
kalnagye0018682019-09-26 16:28:25 +0200156RUN mkdir -p /opt/bin && \
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500157 go build -o /opt/bin/submgr cmd/submgr.go && \
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200158 mkdir -p /opt/build/container/usr/local
kalnagy303e57c2019-06-28 15:28:35 +0200159
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200160
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500161RUN go mod tidy
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200162
Juha Hyttinen04cd1302020-03-31 16:08:36 +0300163RUN cp go.mod go.sum /manifests/
164RUN grep gerrit /manifests/go.sum > /manifests/go_gerrit.sum
165
166
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200167# unittest
168COPY test/config-file.json test/config-file.json
169ENV CFG_FILE=/opt/submgr/test/config-file.json
Juha Hyttinenc2a6b3a2020-03-18 11:45:57 +0200170COPY test/uta_rtg.rt test/uta_rtg.rt
171ENV RMR_SEED_RT=/opt/submgr/test/uta_rtg.rt
Juha Hyttinene406a342020-01-13 13:02:26 +0200172
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500173RUN go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500174RUN go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200175
176# test formating (not important)
Lott, Christopher (cl778h)d32d4232020-02-12 17:37:26 -0500177RUN test -z "$(gofmt -l pkg/control/*.go)"
178RUN test -z "$(gofmt -l pkg/teststub/*.go)"
179RUN test -z "$(gofmt -l pkg/teststubdummy/*.go)"
180RUN test -z "$(gofmt -l pkg/teststube2ap/*.go)"
181RUN test -z "$(gofmt -l pkg/xapptweaks/*.go)"
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200182
Juha Hyttinen01a4c492020-02-04 19:29:26 +0200183
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200184###########################################################
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200185#
Juha Hyttinenf44377d2020-02-12 10:18:40 +0200186###########################################################
kalnagy303e57c2019-06-28 15:28:35 +0200187FROM ubuntu:18.04
188
Balint Uvegescd3881b2019-10-02 15:01:43 +0000189RUN apt update && apt install -y iputils-ping net-tools curl tcpdump
190
Juha Hyttinen429cfe62020-03-31 11:23:02 +0300191COPY --from=submgrbuild /manifests /manifests
192
kalnagy303e57c2019-06-28 15:28:35 +0200193COPY run_submgr.sh /
Balint Uveges534c8822019-10-09 08:54:53 +0000194COPY --from=submgrbuild /opt/bin/submgr /
kalnagy303e57c2019-06-28 15:28:35 +0200195COPY --from=submgrbuild /usr/local/include /usr/local/include
196COPY --from=submgrbuild /usr/local/lib /usr/local/lib
197RUN ldconfig
198
kalnagy93cc3e22019-09-19 11:29:29 +0200199RUN chmod 755 /run_submgr.sh
kalnagye0018682019-09-26 16:28:25 +0200200CMD /run_submgr.sh