Support for handling unordered IEs in RIC Sub Del Resp/Failure messgae
[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:10002/o-ran-sc/bldr-ubuntu20-c-go:1.0.0 as submgrcore
27
28 ARG GOVERSION="1.18.5"
29 RUN wget -nv https://dl.google.com/go/go${GOVERSION}.linux-amd64.tar.gz \
30      && tar -xf go${GOVERSION}.linux-amd64.tar.gz \
31      && mv go /opt/go/${GOVERSION} \
32      && rm -f go*.gz
33
34
35 ENV DEFAULTPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
36 ENV PATH=$DEFAULTPATH:/usr/local/go/bin:/opt/go/${GOVERSION}/bin:/root/go/bin
37
38 RUN apt update && apt install -y iputils-ping net-tools curl tcpdump gdb valgrind
39
40 WORKDIR /tmp
41
42 #RUN git clone https://github.com/nokia/asn1c.git
43 #RUN cd asn1c && test -f configure || autoreconf -iv
44 #RUN cd asn1c &&  ./configure
45 #RUN cd asn1c && make
46 ##RUN cd asn1c && make check
47 #RUN cd asn1c && make install
48
49 #
50 # Swagger
51 #
52 ARG SWAGGERVERSION=v0.23.0
53 ARG SWAGGERURL=https://github.com/go-swagger/go-swagger/releases/download/${SWAGGERVERSION}/swagger_linux_amd64
54 RUN wget --quiet ${SWAGGERURL} \
55     && mv swagger_linux_amd64 swagger \
56     && chmod +x swagger \
57     && mv swagger /usr/local/bin/
58
59 #
60 # GO DELVE
61 #
62 RUN export GOBIN=/usr/local/bin/ ; \
63   go install github.com/go-delve/delve/cmd/dlv@latest
64
65 #
66 # RMR
67 #
68 ARG RMRVERSION=4.9.4
69 ARG RMRLIBURL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb
70 ARG RMRDEVURL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb
71 RUN wget --content-disposition ${RMRLIBURL} && dpkg -i rmr_${RMRVERSION}_amd64.deb
72 RUN wget --content-disposition ${RMRDEVURL} && dpkg -i rmr-dev_${RMRVERSION}_amd64.deb
73 RUN rm -f rmr_${RMRVERSION}_amd64.deb rmr-dev_${RMRVERSION}_amd64.deb
74
75
76 RUN mkdir -p /manifests/
77 RUN echo "rmrlib ${RMRVERSION} ${RMRLIBURL}" >> /manifests/versions.txt
78 RUN echo "rmrdev ${RMRVERSION} ${RMRDEVURL}" >> /manifests/versions.txt
79 RUN echo "swagger ${SWAGGERVERSION} ${SWAGGERURL}" >> /manifests/versions.txt
80
81
82 WORKDIR /opt/submgr
83
84 ###########################################################
85 #
86 ###########################################################
87 FROM submgrcore as submgre2apbuild
88
89
90 ENV CFLAGS="-DASN_DISABLE_OER_SUPPORT"
91 ENV CGO_CFLAGS="-DASN_DISABLE_OER_SUPPORT"
92
93 COPY 3rdparty 3rdparty
94 RUN cd 3rdparty/E2AP-v02.00.00 && \
95     gcc -c ${CFLAGS} -I. -g -fPIC *.c  && \
96     gcc *.o -g -shared -o libe2ap.so && \
97     cp libe2ap.so /usr/local/lib/ && \
98     cp *.h /usr/local/include/ && \
99     ldconfig
100
101
102 RUN echo "E2AP         E2AP-v02.00.00" >> /manifests/versions.txt
103
104
105 COPY e2ap e2ap
106 RUN cd e2ap/libe2ap_wrapper && \
107     gcc -c ${CFLAGS} -g -fPIC *.c  && \
108     gcc *.o -g -shared -o libe2ap_wrapper.so && \
109     cp libe2ap_wrapper.so /usr/local/lib/ && \
110     cp *.h /usr/local/include/ && \
111     ldconfig
112
113 # unittest
114 RUN cd e2ap && go test -v ./pkg/conv
115 RUN cd e2ap && go test -v ./pkg/e2ap_wrapper
116
117 # test formating (not important)
118 RUN cd e2ap && test -z "$(gofmt -l pkg/conv/*.go)"
119 RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap_wrapper/*.go)"
120 RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/*.go)"
121 RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/e2ap_tests/*.go)"
122
123
124 ###########################################################
125 #
126 ###########################################################
127 FROM submgre2apbuild as submgrbuild
128 #
129 #
130 #
131 COPY go.mod go.mod
132 RUN go mod download
133
134 #
135 #
136 #
137 RUN mkdir pkg
138 COPY api api
139
140 ARG RTMGRVERSION=8becf0c4e06bc89b13d217a102eb7a50470cddc5
141 RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" \
142     && git -C "rtmgr" checkout $RTMGRVERSION \
143     && cp rtmgr/api/routing_manager.yaml api/ \
144     && rm -rf rtmgr
145
146 RUN mkdir -p /root/go && \
147     swagger generate client -f api/routing_manager.yaml -t pkg/ -m rtmgr_models -c rtmgr_client
148
149
150 RUN echo "rtmgrapi ${RTMGRVERSION} https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" >> /manifests/versions.txt
151
152 #
153 #
154 #
155 COPY pkg pkg
156 COPY cmd cmd
157
158 COPY go.sum go.sum
159 RUN go mod tidy
160
161 RUN mkdir -p /opt/bin && \
162     go build -o /opt/bin/submgr cmd/submgr.go && \
163     mkdir -p /opt/build/container/usr/local
164
165 RUN cp go.mod go.sum /manifests/
166 RUN grep gerrit /manifests/go.sum > /manifests/go_gerrit.sum
167
168
169 # unittest
170 COPY test/config-file.json test/config-file.json
171 ENV CFG_FILE=/opt/submgr/test/config-file.json
172 COPY test/uta_rtg.rt test/uta_rtg.rt
173 ENV RMR_SEED_RT=/opt/submgr/test/uta_rtg.rt 
174
175 #ENV CGO_LDFLAGS="-fsanitize=address"
176 #ENV CGO_CFLAGS="-fsanitize=address"
177
178 #
179 # To get debug from rmr
180 #
181 #RUN echo 5 >  /opt/submgr/level
182 #RUN RMR_VCTL_FILE=/opt/submgr/level go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control 
183
184 #
185 # go tests. comment out ipv6 localhost if exist when tests are executed.
186 #
187 RUN sed -r  "s/^(::1.*)/#\1/" /etc/hosts  > /etc/hosts.new \
188     && cat /etc/hosts.new > /etc/hosts \
189     && cat /etc/hosts  \
190     && go test -failfast -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control \
191     && go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html    
192
193 # test formating (not important)
194 RUN test -z "$(gofmt -l pkg/control/*.go)"
195 RUN test -z "$(gofmt -l pkg/teststub/*.go)"
196 RUN test -z "$(gofmt -l pkg/teststubdummy/*.go)"
197 RUN test -z "$(gofmt -l pkg/teststube2ap/*.go)"
198
199
200 ###########################################################
201 #
202 ###########################################################
203 FROM ubuntu:20.04
204
205 RUN apt update && apt install -y iputils-ping net-tools curl tcpdump
206
207 COPY --from=submgrbuild /manifests /manifests
208 COPY --from=submgrbuild /opt/bin/submgr /
209 COPY --from=submgrbuild /usr/local/include/rmr /usr/local/include/
210 COPY --from=submgrbuild /usr/local/lib/librmr* /usr/local/lib/
211 COPY --from=submgrbuild /usr/local/lib/libe2ap* /usr/local/lib/
212 RUN ldconfig
213
214 COPY run_submgr.sh /
215 RUN chmod 755 /run_submgr.sh
216
217 #default config
218 COPY config /opt/config
219 ENV CFG_FILE=/opt/config/submgr-config.yaml
220 ENV RMR_SEED_RT=/opt/config/submgr-uta-rtg.rt
221
222 ENTRYPOINT ["/submgr"]