kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 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 | # |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 23 | ########################################################### |
| 24 | # |
| 25 | ########################################################### |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 26 | FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:4-u18.04-nng as submgrcore |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 27 | |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame] | 28 | RUN apt update && apt install -y iputils-ping net-tools curl tcpdump gdb valgrind |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 29 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 30 | WORKDIR /tmp |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 31 | |
Juha Hyttinen | d708a43 | 2020-03-09 09:37:06 +0200 | [diff] [blame] | 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 | |
Juha Hyttinen | c2a6b3a | 2020-03-18 11:45:57 +0200 | [diff] [blame] | 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/ |
Juha Hyttinen | d708a43 | 2020-03-09 09:37:06 +0200 | [diff] [blame] | 48 | |
Juha Hyttinen | c2a6b3a | 2020-03-18 11:45:57 +0200 | [diff] [blame] | 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 | |
Juha Hyttinen | 429cfe6 | 2020-03-31 11:23:02 +0300 | [diff] [blame] | 57 | # |
| 58 | # RMR |
| 59 | # |
| 60 | ARG RMRVERSION=3.6.2 |
| 61 | ARG RMRLIBURL=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb |
| 62 | ARG RMRDEVURL=https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb |
| 63 | RUN wget --content-disposition ${RMRLIBURL} && dpkg -i rmr_${RMRVERSION}_amd64.deb |
| 64 | RUN wget --content-disposition ${RMRDEVURL} && dpkg -i rmr-dev_${RMRVERSION}_amd64.deb |
| 65 | RUN rm -f rmr_${RMRVERSION}_amd64.deb rmr-dev_${RMRVERSION}_amd64.deb |
| 66 | |
| 67 | |
| 68 | RUN mkdir /manifests/ |
| 69 | RUN echo "rmrlib ${RMRVERSION} ${RMRLIBURL}" >> /manifests/versions.txt |
| 70 | RUN echo "rmrdev ${RMRVERSION} ${RMRDEVURL}" >> /manifests/versions.txt |
| 71 | RUN echo "swagger ${SWAGGERVERSION} ${SWAGGERURL}" >> /manifests/versions.txt |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 72 | |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame] | 73 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 74 | WORKDIR /opt/submgr |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 75 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 76 | ########################################################### |
| 77 | # |
| 78 | ########################################################### |
| 79 | FROM submgrcore as submgre2apbuild |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 80 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 81 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 82 | ENV CFLAGS="-DASN_DISABLE_OER_SUPPORT" |
| 83 | ENV CGO_CFLAGS="-DASN_DISABLE_OER_SUPPORT" |
| 84 | |
| 85 | COPY 3rdparty 3rdparty |
| 86 | RUN cd 3rdparty/libe2ap && \ |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame] | 87 | gcc -c ${CFLAGS} -I. -g -fPIC *.c && \ |
| 88 | gcc *.o -g -shared -o libe2ap.so && \ |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 89 | cp libe2ap.so /usr/local/lib/ && \ |
| 90 | cp *.h /usr/local/include/ && \ |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 91 | ldconfig |
| 92 | |
Juha Hyttinen | 429cfe6 | 2020-03-31 11:23:02 +0300 | [diff] [blame] | 93 | RUN echo "E2AP ?" >> /manifests/versions.txt |
| 94 | RUN echo "E2SM-gNB-NRT ?" >> /manifests/versions.txt |
| 95 | RUN echo "E2SM-gNB-X2 ?" >> /manifests/versions.txt |
| 96 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 97 | COPY e2ap e2ap |
| 98 | RUN cd e2ap/libe2ap_wrapper && \ |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame] | 99 | gcc -c ${CFLAGS} -g -fPIC *.c && \ |
| 100 | gcc *.o -g -shared -o libe2ap_wrapper.so && \ |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 101 | cp libe2ap_wrapper.so /usr/local/lib/ && \ |
| 102 | cp *.h /usr/local/include/ && \ |
| 103 | ldconfig |
| 104 | |
| 105 | # unittest |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 106 | RUN cd e2ap && go test -v ./pkg/conv |
| 107 | RUN cd e2ap && go test -v ./pkg/e2ap_wrapper |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 108 | |
| 109 | # test formating (not important) |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 110 | RUN cd e2ap && test -z "$(gofmt -l pkg/conv/*.go)" |
| 111 | RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap_wrapper/*.go)" |
| 112 | RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/*.go)" |
| 113 | RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/e2ap_tests/*.go)" |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 114 | |
Juha Hyttinen | 5504022 | 2020-01-16 09:41:04 +0200 | [diff] [blame] | 115 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 116 | ########################################################### |
| 117 | # |
| 118 | ########################################################### |
| 119 | FROM submgre2apbuild as submgrbuild |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 120 | # |
| 121 | # |
| 122 | # |
| 123 | COPY go.mod go.mod |
| 124 | COPY go.sum go.sum |
| 125 | |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 126 | RUN go mod download |
Juha Hyttinen | 896c3ac | 2020-02-24 12:49:20 +0200 | [diff] [blame] | 127 | RUN go mod tidy |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 128 | |
Juha Hyttinen | 429cfe6 | 2020-03-31 11:23:02 +0300 | [diff] [blame] | 129 | RUN cp go.mod go.sum /manifests/ |
| 130 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 131 | # |
| 132 | # |
| 133 | # |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 134 | RUN mkdir pkg |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 135 | COPY api api |
| 136 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 137 | |
| 138 | ARG RTMGRVERSION=cd7867c8f527f46fd8702b0b8d6b380a8e134bea |
| 139 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 140 | RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" \ |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 141 | && git -C "rtmgr" checkout $RTMGRVERSION \ |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 142 | && cp rtmgr/api/routing_manager.yaml api/ \ |
| 143 | && rm -rf rtmgr |
| 144 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 145 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 146 | RUN mkdir -p /root/go && \ |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 147 | swagger generate client -f api/routing_manager.yaml -t pkg/ -m rtmgr_models -c rtmgr_client |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 148 | |
Juha Hyttinen | 896c3ac | 2020-02-24 12:49:20 +0200 | [diff] [blame] | 149 | |
Juha Hyttinen | 429cfe6 | 2020-03-31 11:23:02 +0300 | [diff] [blame] | 150 | RUN echo "rtmgrapi ${RTMGRVERSION} https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" >> /manifests/versions.txt |
| 151 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 152 | # |
| 153 | # |
| 154 | # |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 155 | COPY pkg pkg |
| 156 | COPY cmd cmd |
| 157 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 158 | RUN mkdir -p /opt/bin && \ |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 159 | go build -o /opt/bin/submgr cmd/submgr.go && \ |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 160 | mkdir -p /opt/build/container/usr/local |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 161 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 162 | |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 163 | RUN go mod tidy |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 164 | |
| 165 | # unittest |
| 166 | COPY test/config-file.json test/config-file.json |
| 167 | ENV CFG_FILE=/opt/submgr/test/config-file.json |
Juha Hyttinen | c2a6b3a | 2020-03-18 11:45:57 +0200 | [diff] [blame] | 168 | COPY test/uta_rtg.rt test/uta_rtg.rt |
| 169 | ENV RMR_SEED_RT=/opt/submgr/test/uta_rtg.rt |
Juha Hyttinen | e406a34 | 2020-01-13 13:02:26 +0200 | [diff] [blame] | 170 | |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 171 | RUN go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame] | 172 | |
| 173 | #-c -o submgr_test |
| 174 | #RUN ./submgr_test -test.coverprofile /tmp/submgr_cover.out |
Juha Hyttinen | e406a34 | 2020-01-13 13:02:26 +0200 | [diff] [blame] | 175 | |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 176 | RUN go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 177 | |
| 178 | # test formating (not important) |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 179 | RUN test -z "$(gofmt -l pkg/control/*.go)" |
| 180 | RUN test -z "$(gofmt -l pkg/teststub/*.go)" |
| 181 | RUN test -z "$(gofmt -l pkg/teststubdummy/*.go)" |
| 182 | RUN test -z "$(gofmt -l pkg/teststube2ap/*.go)" |
| 183 | RUN test -z "$(gofmt -l pkg/xapptweaks/*.go)" |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 184 | |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame] | 185 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 186 | ########################################################### |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 187 | # |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 188 | ########################################################### |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 189 | FROM ubuntu:18.04 |
| 190 | |
Balint Uveges | cd3881b | 2019-10-02 15:01:43 +0000 | [diff] [blame] | 191 | RUN apt update && apt install -y iputils-ping net-tools curl tcpdump |
| 192 | |
Juha Hyttinen | 429cfe6 | 2020-03-31 11:23:02 +0300 | [diff] [blame] | 193 | COPY --from=submgrbuild /manifests /manifests |
| 194 | |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 195 | COPY run_submgr.sh / |
Balint Uveges | 534c882 | 2019-10-09 08:54:53 +0000 | [diff] [blame] | 196 | COPY --from=submgrbuild /opt/bin/submgr / |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 197 | COPY --from=submgrbuild /usr/local/include /usr/local/include |
| 198 | COPY --from=submgrbuild /usr/local/lib /usr/local/lib |
| 199 | RUN ldconfig |
| 200 | |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 201 | RUN chmod 755 /run_submgr.sh |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 202 | CMD /run_submgr.sh |