Updating to newer xapp-frame 0.0.30 version. Prepared also for 4.* version
[ric-plt/submgr.git] / Dockerfile
1 #
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 #
23 ###########################################################
24 #
25 ###########################################################
26 FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:4-u18.04-nng as submgrcore
27
28 RUN apt update && apt install -y iputils-ping net-tools curl tcpdump gdb valgrind
29
30 WORKDIR /tmp
31
32 #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
39 #
40 # Swagger
41 #
42 ARG SWAGGERVERSION=v0.19.0
43 ARG SWAGGERURL=https://github.com/go-swagger/go-swagger/releases/download/${SWAGGERVERSION}/swagger_linux_amd64
44 RUN wget --quiet ${SWAGGERURL} \
45     && mv swagger_linux_amd64 swagger \
46     && chmod +x swagger \
47     && mv swagger /usr/local/bin/
48
49 #
50 # GO DELVE
51 #
52 RUN 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
57 ARG RMRVERSION=3.5.0
58 # Install RMr shared library
59 RUN 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
60 # Install RMr development header files
61 RUN 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
62
63
64 WORKDIR /opt/submgr
65
66 ###########################################################
67 #
68 ###########################################################
69 FROM submgrcore as submgre2apbuild
70
71
72 ENV CFLAGS="-DASN_DISABLE_OER_SUPPORT"
73 ENV CGO_CFLAGS="-DASN_DISABLE_OER_SUPPORT"
74
75 COPY 3rdparty 3rdparty
76 RUN cd 3rdparty/libe2ap && \
77     gcc -c ${CFLAGS} -I. -g -fPIC *.c  && \
78     gcc *.o -g -shared -o libe2ap.so && \
79     cp libe2ap.so /usr/local/lib/ && \
80     cp *.h /usr/local/include/ && \
81     ldconfig
82
83 COPY e2ap e2ap
84 RUN cd e2ap/libe2ap_wrapper && \
85     gcc -c ${CFLAGS} -g -fPIC *.c  && \
86     gcc *.o -g -shared -o libe2ap_wrapper.so && \
87     cp libe2ap_wrapper.so /usr/local/lib/ && \
88     cp *.h /usr/local/include/ && \
89     ldconfig
90
91 # unittest
92 RUN cd e2ap && go test -v ./pkg/conv
93 RUN cd e2ap && go test -v ./pkg/e2ap_wrapper
94
95 # test formating (not important)
96 RUN cd e2ap && test -z "$(gofmt -l pkg/conv/*.go)"
97 RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap_wrapper/*.go)"
98 RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/*.go)"
99 RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/e2ap_tests/*.go)"
100
101
102 ###########################################################
103 #
104 ###########################################################
105 FROM submgre2apbuild as submgrbuild
106 #
107 #
108 #
109 COPY go.mod go.mod
110 COPY go.sum go.sum
111
112 RUN go mod download
113 RUN go mod tidy
114
115 #
116 #
117 #
118 RUN mkdir pkg
119 COPY api api
120
121
122 ARG RTMGRVERSION=cd7867c8f527f46fd8702b0b8d6b380a8e134bea
123
124 RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" \
125     && git -C "rtmgr" checkout $RTMGRVERSION \
126     && cp rtmgr/api/routing_manager.yaml api/ \
127     && rm -rf rtmgr
128
129
130 RUN mkdir -p /root/go && \
131     swagger generate client -f api/routing_manager.yaml -t pkg/ -m rtmgr_models -c rtmgr_client
132
133
134 #
135 #
136 #
137 COPY pkg pkg
138 COPY cmd cmd
139
140 RUN mkdir -p /opt/bin && \
141     go build -o /opt/bin/submgr cmd/submgr.go && \
142     mkdir -p /opt/build/container/usr/local
143
144
145 RUN go mod tidy
146
147 # unittest
148 COPY test/config-file.json test/config-file.json
149 ENV CFG_FILE=/opt/submgr/test/config-file.json
150 COPY test/uta_rtg.rt test/uta_rtg.rt
151 ENV RMR_SEED_RT=/opt/submgr/test/uta_rtg.rt 
152
153 RUN go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control 
154
155 #-c -o submgr_test
156 #RUN ./submgr_test -test.coverprofile /tmp/submgr_cover.out
157
158 RUN go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html
159
160 # test formating (not important)
161 RUN test -z "$(gofmt -l pkg/control/*.go)"
162 RUN test -z "$(gofmt -l pkg/teststub/*.go)"
163 RUN test -z "$(gofmt -l pkg/teststubdummy/*.go)"
164 RUN test -z "$(gofmt -l pkg/teststube2ap/*.go)"
165 RUN test -z "$(gofmt -l pkg/xapptweaks/*.go)"
166
167
168 ###########################################################
169 #
170 ###########################################################
171 FROM ubuntu:18.04
172
173 RUN apt update && apt install -y iputils-ping net-tools curl tcpdump
174
175 COPY run_submgr.sh /
176 COPY --from=submgrbuild /opt/bin/submgr /
177 COPY --from=submgrbuild /usr/local/include /usr/local/include
178 COPY --from=submgrbuild /usr/local/lib /usr/local/lib
179 RUN ldconfig
180
181 RUN chmod 755 /run_submgr.sh
182 CMD /run_submgr.sh