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 | 5504022 | 2020-01-16 09:41:04 +0200 | [diff] [blame] | 23 | FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:3-u18.04-nng as submgrprebuild |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 24 | |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame^] | 25 | 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] | 26 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 27 | WORKDIR /tmp |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 28 | |
Juha Hyttinen | e406a34 | 2020-01-13 13:02:26 +0200 | [diff] [blame] | 29 | ARG RMRVERSION=1.13.1 |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 30 | # Install RMr shared library |
Juha Hyttinen | e406a34 | 2020-01-13 13:02:26 +0200 | [diff] [blame] | 31 | 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] | 32 | # Install RMr development header files |
Juha Hyttinen | e406a34 | 2020-01-13 13:02:26 +0200 | [diff] [blame] | 33 | 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] | 34 | |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 35 | # "Installing Swagger" |
| 36 | RUN cd /usr/local/go/bin \ |
| 37 | && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \ |
| 38 | && mv swagger_linux_amd64 swagger \ |
| 39 | && chmod +x swagger |
| 40 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 41 | |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame^] | 42 | ENV GOPATH=/root/.go |
| 43 | ENV PATH=$PATH:/root/.go/bin |
| 44 | RUN /usr/local/go/bin/go get -u github.com/go-delve/delve/cmd/dlv |
| 45 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 46 | WORKDIR /opt/submgr |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 47 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 48 | RUN mkdir pkg |
| 49 | |
| 50 | # |
| 51 | # |
| 52 | # |
| 53 | ENV CFLAGS="-DASN_DISABLE_OER_SUPPORT" |
| 54 | ENV CGO_CFLAGS="-DASN_DISABLE_OER_SUPPORT" |
| 55 | |
| 56 | COPY 3rdparty 3rdparty |
| 57 | RUN cd 3rdparty/libe2ap && \ |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame^] | 58 | gcc -c ${CFLAGS} -I. -g -fPIC *.c && \ |
| 59 | gcc *.o -g -shared -o libe2ap.so && \ |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 60 | cp libe2ap.so /usr/local/lib/ && \ |
| 61 | cp *.h /usr/local/include/ && \ |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 62 | ldconfig |
| 63 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 64 | COPY e2ap e2ap |
| 65 | RUN cd e2ap/libe2ap_wrapper && \ |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame^] | 66 | gcc -c ${CFLAGS} -g -fPIC *.c && \ |
| 67 | gcc *.o -g -shared -o libe2ap_wrapper.so && \ |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 68 | cp libe2ap_wrapper.so /usr/local/lib/ && \ |
| 69 | cp *.h /usr/local/include/ && \ |
| 70 | ldconfig |
| 71 | |
| 72 | # unittest |
| 73 | RUN cd e2ap && /usr/local/go/bin/go test -v ./pkg/conv |
| 74 | RUN cd e2ap && /usr/local/go/bin/go test -v ./pkg/e2ap_wrapper |
| 75 | |
| 76 | # test formating (not important) |
| 77 | RUN cd e2ap && test -z "$(/usr/local/go/bin/gofmt -l pkg/conv/*.go)" |
| 78 | RUN cd e2ap && test -z "$(/usr/local/go/bin/gofmt -l pkg/e2ap_wrapper/*.go)" |
| 79 | RUN cd e2ap && test -z "$(/usr/local/go/bin/gofmt -l pkg/e2ap/*.go)" |
| 80 | RUN cd e2ap && test -z "$(/usr/local/go/bin/gofmt -l pkg/e2ap/e2ap_tests/*.go)" |
| 81 | |
Juha Hyttinen | 5504022 | 2020-01-16 09:41:04 +0200 | [diff] [blame] | 82 | |
| 83 | FROM submgrprebuild as submgrbuild |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 84 | # |
| 85 | # |
| 86 | # |
| 87 | COPY go.mod go.mod |
| 88 | COPY go.sum go.sum |
| 89 | |
| 90 | RUN /usr/local/go/bin/go mod download |
| 91 | |
| 92 | # |
| 93 | # |
| 94 | # |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 95 | COPY api api |
| 96 | |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 97 | # "Getting and generating routing managers api client" |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 98 | RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/rtmgr" \ |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 99 | && cp rtmgr/api/routing_manager.yaml api/ \ |
| 100 | && rm -rf rtmgr |
| 101 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 102 | RUN mkdir -p /root/go && \ |
| 103 | /usr/local/go/bin/swagger generate client -f api/routing_manager.yaml -t pkg/ -m rtmgr_models -c rtmgr_client |
| 104 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 105 | # |
| 106 | # |
| 107 | # |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 108 | COPY pkg pkg |
| 109 | COPY cmd cmd |
| 110 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 111 | RUN mkdir -p /opt/bin && \ |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 112 | /usr/local/go/bin/go build -o /opt/bin/submgr cmd/submgr.go && \ |
| 113 | mkdir -p /opt/build/container/usr/local |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 114 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 115 | |
| 116 | RUN /usr/local/go/bin/go mod tidy |
| 117 | |
| 118 | # unittest |
| 119 | COPY test/config-file.json test/config-file.json |
| 120 | ENV CFG_FILE=/opt/submgr/test/config-file.json |
Juha Hyttinen | e406a34 | 2020-01-13 13:02:26 +0200 | [diff] [blame] | 121 | |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame^] | 122 | RUN /usr/local/go/bin/go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control |
| 123 | |
| 124 | #-c -o submgr_test |
| 125 | #RUN ./submgr_test -test.coverprofile /tmp/submgr_cover.out |
Juha Hyttinen | e406a34 | 2020-01-13 13:02:26 +0200 | [diff] [blame] | 126 | |
| 127 | RUN /usr/local/go/bin/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] | 128 | |
| 129 | # test formating (not important) |
| 130 | RUN test -z "$(/usr/local/go/bin/gofmt -l pkg/control/*.go)" |
| 131 | |
Juha Hyttinen | 01a4c49 | 2020-02-04 19:29:26 +0200 | [diff] [blame^] | 132 | |
Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame] | 133 | # |
| 134 | # |
| 135 | # |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 136 | FROM ubuntu:18.04 |
| 137 | |
Balint Uveges | cd3881b | 2019-10-02 15:01:43 +0000 | [diff] [blame] | 138 | RUN apt update && apt install -y iputils-ping net-tools curl tcpdump |
| 139 | |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 140 | COPY run_submgr.sh / |
Balint Uveges | 534c882 | 2019-10-09 08:54:53 +0000 | [diff] [blame] | 141 | COPY --from=submgrbuild /opt/bin/submgr / |
kalnagy | 303e57c | 2019-06-28 15:28:35 +0200 | [diff] [blame] | 142 | COPY --from=submgrbuild /usr/local/include /usr/local/include |
| 143 | COPY --from=submgrbuild /usr/local/lib /usr/local/lib |
| 144 | RUN ldconfig |
| 145 | |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 146 | RUN chmod 755 /run_submgr.sh |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 147 | CMD /run_submgr.sh |