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 | 896c3ac | 2020-02-24 12:49:20 +0200 | [diff] [blame] | 32 | ARG RMRVERSION=3.2.4 |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 33 | # Install RMr shared library |
Juha Hyttinen | e406a34 | 2020-01-13 13:02:26 +0200 | [diff] [blame] | 34 | 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 |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 35 | # Install RMr development header files |
Juha Hyttinen | e406a34 | 2020-01-13 13:02:26 +0200 | [diff] [blame] | 36 | 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 |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 37 | |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 38 | # "Installing Swagger" |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 39 | RUN wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \ |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 40 | && mv swagger_linux_amd64 swagger \ |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 41 | && chmod +x swagger \ |
| 42 | && mkdir -p /root/.go/bin \ |
| 43 | && mv swagger /root/.go/bin |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 44 | |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame] | 45 | ENV GOPATH=/root/.go |
| 46 | ENV PATH=$PATH:/root/.go/bin |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 47 | RUN go get -u github.com/go-delve/delve/cmd/dlv |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame] | 48 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 49 | WORKDIR /opt/submgr |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 50 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 51 | ########################################################### |
| 52 | # |
| 53 | ########################################################### |
| 54 | FROM submgrcore as submgre2apbuild |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 55 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 56 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 57 | ENV CFLAGS="-DASN_DISABLE_OER_SUPPORT" |
| 58 | ENV CGO_CFLAGS="-DASN_DISABLE_OER_SUPPORT" |
| 59 | |
| 60 | COPY 3rdparty 3rdparty |
Anssi Mannila | d2ee0c7 | 2020-03-02 15:42:37 +0200 | [diff] [blame] | 61 | RUN cd 3rdparty/E2AP-v01.00.00 && \ |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame] | 62 | gcc -c ${CFLAGS} -I. -g -fPIC *.c && \ |
| 63 | gcc *.o -g -shared -o libe2ap.so && \ |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 64 | cp libe2ap.so /usr/local/lib/ && \ |
| 65 | cp *.h /usr/local/include/ && \ |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 66 | ldconfig |
| 67 | |
Anssi Mannila | 63ff995 | 2020-03-17 09:57:46 +0200 | [diff] [blame] | 68 | RUN cd 3rdparty/E2SM-gNB-NRT_V4.0.1 && \ |
| 69 | gcc -c ${CFLAGS} -I. -g -fPIC *.c && \ |
| 70 | gcc *.o -g -shared -o libgnbnrt.so && \ |
| 71 | cp libgnbnrt.so /usr/local/lib/ && \ |
| 72 | cp *.h /usr/local/include/ && \ |
| 73 | ldconfig |
| 74 | |
| 75 | RUN cd 3rdparty/E2SM-gNB-X2-V4.0.1 && \ |
Anssi Mannila | d2ee0c7 | 2020-03-02 15:42:37 +0200 | [diff] [blame] | 76 | gcc -c ${CFLAGS} -I. -g -fPIC *.c && \ |
| 77 | gcc *.o -g -shared -o libgnbx2.so && \ |
| 78 | cp libgnbx2.so /usr/local/lib/ && \ |
| 79 | cp *.h /usr/local/include/ && \ |
| 80 | ldconfig |
| 81 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 82 | COPY e2ap e2ap |
| 83 | RUN cd e2ap/libe2ap_wrapper && \ |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame] | 84 | gcc -c ${CFLAGS} -g -fPIC *.c && \ |
| 85 | gcc *.o -g -shared -o libe2ap_wrapper.so && \ |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 86 | cp libe2ap_wrapper.so /usr/local/lib/ && \ |
| 87 | cp *.h /usr/local/include/ && \ |
| 88 | ldconfig |
| 89 | |
| 90 | # unittest |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 91 | RUN cd e2ap && go test -v ./pkg/conv |
| 92 | RUN cd e2ap && go test -v ./pkg/e2ap_wrapper |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 93 | |
| 94 | # test formating (not important) |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 95 | RUN cd e2ap && test -z "$(gofmt -l pkg/conv/*.go)" |
| 96 | RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap_wrapper/*.go)" |
| 97 | RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/*.go)" |
| 98 | RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/e2ap_tests/*.go)" |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 99 | |
Juha Hyttinen | 5504022 | 2020-01-16 09:41:04 +0200 | [diff] [blame] | 100 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 101 | ########################################################### |
| 102 | # |
| 103 | ########################################################### |
| 104 | FROM submgre2apbuild as submgrbuild |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 105 | # |
| 106 | # |
| 107 | # |
| 108 | COPY go.mod go.mod |
| 109 | COPY go.sum go.sum |
| 110 | |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 111 | RUN go mod download |
Juha Hyttinen | 896c3ac | 2020-02-24 12:49:20 +0200 | [diff] [blame] | 112 | RUN go mod tidy |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 113 | |
| 114 | # |
| 115 | # |
| 116 | # |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 117 | RUN mkdir pkg |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 118 | COPY api api |
| 119 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 120 | |
| 121 | ARG RTMGRVERSION=cd7867c8f527f46fd8702b0b8d6b380a8e134bea |
| 122 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 123 | 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] | 124 | && git -C "rtmgr" checkout $RTMGRVERSION \ |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 125 | && cp rtmgr/api/routing_manager.yaml api/ \ |
| 126 | && rm -rf rtmgr |
| 127 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 128 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 129 | RUN mkdir -p /root/go && \ |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 130 | 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] | 131 | |
Juha Hyttinen | 896c3ac | 2020-02-24 12:49:20 +0200 | [diff] [blame] | 132 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 133 | # |
| 134 | # |
| 135 | # |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 136 | COPY pkg pkg |
| 137 | COPY cmd cmd |
| 138 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 139 | RUN mkdir -p /opt/bin && \ |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 140 | go build -o /opt/bin/submgr cmd/submgr.go && \ |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 141 | mkdir -p /opt/build/container/usr/local |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 142 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 143 | |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 144 | RUN go mod tidy |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 145 | |
| 146 | # unittest |
| 147 | COPY test/config-file.json test/config-file.json |
| 148 | ENV CFG_FILE=/opt/submgr/test/config-file.json |
Juha Hyttinen | e406a34 | 2020-01-13 13:02:26 +0200 | [diff] [blame] | 149 | |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 150 | 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] | 151 | |
| 152 | #-c -o submgr_test |
| 153 | #RUN ./submgr_test -test.coverprofile /tmp/submgr_cover.out |
Juha Hyttinen | e406a34 | 2020-01-13 13:02:26 +0200 | [diff] [blame] | 154 | |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 155 | 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] | 156 | |
| 157 | # test formating (not important) |
Lott, Christopher (cl778h) | d32d423 | 2020-02-12 17:37:26 -0500 | [diff] [blame] | 158 | RUN test -z "$(gofmt -l pkg/control/*.go)" |
| 159 | RUN test -z "$(gofmt -l pkg/teststub/*.go)" |
| 160 | RUN test -z "$(gofmt -l pkg/teststubdummy/*.go)" |
| 161 | RUN test -z "$(gofmt -l pkg/teststube2ap/*.go)" |
| 162 | RUN test -z "$(gofmt -l pkg/xapptweaks/*.go)" |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 163 | |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame] | 164 | |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 165 | ########################################################### |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 166 | # |
Juha Hyttinen | f44377d | 2020-02-12 10:18:40 +0200 | [diff] [blame] | 167 | ########################################################### |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 168 | FROM ubuntu:18.04 |
| 169 | |
Balint Uveges | cd3881b | 2019-10-02 15:01:43 +0000 | [diff] [blame] | 170 | RUN apt update && apt install -y iputils-ping net-tools curl tcpdump |
| 171 | |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 172 | COPY run_submgr.sh / |
Balint Uveges | 534c882 | 2019-10-09 08:54:53 +0000 | [diff] [blame] | 173 | COPY --from=submgrbuild /opt/bin/submgr / |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 174 | COPY --from=submgrbuild /usr/local/include /usr/local/include |
| 175 | COPY --from=submgrbuild /usr/local/lib /usr/local/lib |
| 176 | RUN ldconfig |
| 177 | |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 178 | RUN chmod 755 /run_submgr.sh |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 179 | CMD /run_submgr.sh |