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