Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 1 | # Copyright (c) 2019 AT&T Intellectual Property. |
| 2 | # Copyright (c) 2019 Nokia. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | #---------------------------------------------------------- |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 17 | |
Mohamed Abukar | 3bd90db | 2020-05-07 07:23:08 +0300 | [diff] [blame^] | 18 | FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:7-u18.04 AS appmgr-build |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 19 | |
Lott, Christopher (cl778h) | 229b02e | 2019-06-04 15:50:49 -0400 | [diff] [blame] | 20 | RUN apt-get update -y && apt-get install -y jq |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 21 | |
| 22 | ENV PATH="/usr/local/go/bin:${PATH}" |
Mohamed Abukar | b6e4135 | 2019-07-08 18:09:44 +0300 | [diff] [blame] | 23 | ARG HELMVERSION=v2.12.3 |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 24 | |
Lott, Christopher (cl778h) | 229b02e | 2019-06-04 15:50:49 -0400 | [diff] [blame] | 25 | # Install helm |
| 26 | RUN wget -nv https://storage.googleapis.com/kubernetes-helm/helm-${HELMVERSION}-linux-amd64.tar.gz \ |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 27 | && tar -zxvf helm-${HELMVERSION}-linux-amd64.tar.gz \ |
Lott, Christopher (cl778h) | 229b02e | 2019-06-04 15:50:49 -0400 | [diff] [blame] | 28 | && cp linux-amd64/helm /usr/local/bin/helm \ |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 29 | && rm -rf helm-${HELMVERSION}-linux-amd64.tar.gz \ |
| 30 | && rm -rf linux-amd64 |
| 31 | |
Lott, Christopher (cl778h) | 229b02e | 2019-06-04 15:50:49 -0400 | [diff] [blame] | 32 | # Install kubectl from Docker Hub |
Abukar Mohamed | f8b9966 | 2020-03-02 14:44:30 +0000 | [diff] [blame] | 33 | COPY --from=lachlanevenson/k8s-kubectl:v1.16.0 /usr/local/bin/kubectl /usr/local/bin/kubectl |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 34 | |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 35 | ENV GOPATH="/go" |
| 36 | |
Mohamed Abukar | 34e4383 | 2019-11-13 17:57:15 +0200 | [diff] [blame] | 37 | # Swagger |
| 38 | RUN mkdir -p /go/bin |
| 39 | RUN cd /go/bin \ |
| 40 | && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \ |
| 41 | && mv swagger_linux_amd64 swagger \ |
| 42 | && chmod +x swagger |
| 43 | |
| 44 | RUN mkdir -p /go/src/ws |
| 45 | WORKDIR "/go/src/ws" |
| 46 | |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 47 | # Module prepare (if go.mod/go.sum updated) |
Mohamed Abukar | 34e4383 | 2019-11-13 17:57:15 +0200 | [diff] [blame] | 48 | COPY go.mod /go/src/ws |
| 49 | COPY go.sum /go/src/ws |
Abukar Mohamed | 059775c | 2019-05-22 14:48:10 +0000 | [diff] [blame] | 50 | RUN GO111MODULE=on go mod download |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 51 | |
Juha Hyttinen | 4703b1a | 2019-11-14 09:35:22 +0200 | [diff] [blame] | 52 | # build and test |
Mohamed Abukar | 34e4383 | 2019-11-13 17:57:15 +0200 | [diff] [blame] | 53 | COPY . /go/src/ws |
Juha Hyttinen | 4703b1a | 2019-11-14 09:35:22 +0200 | [diff] [blame] | 54 | |
Mohamed Abukar | d976977 | 2019-11-20 20:39:06 +0200 | [diff] [blame] | 55 | # Generate Swagger code |
Mohamed Abukar | 34e4383 | 2019-11-13 17:57:15 +0200 | [diff] [blame] | 56 | RUN /go/bin/swagger generate server -f api/appmgr_rest_api.yaml --name AppManager -t pkg/ --exclude-main |
Juha Hyttinen | 4703b1a | 2019-11-14 09:35:22 +0200 | [diff] [blame] | 57 | |
Mohamed Abukar | 34e4383 | 2019-11-13 17:57:15 +0200 | [diff] [blame] | 58 | COPY . /go/src/ws |
Juha Hyttinen | 4703b1a | 2019-11-14 09:35:22 +0200 | [diff] [blame] | 59 | |
Mohamed Abukar | d976977 | 2019-11-20 20:39:06 +0200 | [diff] [blame] | 60 | # Build the code |
| 61 | RUN GO111MODULE=on GO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/src/ws/cache/go/cmd/appmgr cmd/appmgr.go |
Mohamed Abukar | 34e4383 | 2019-11-13 17:57:15 +0200 | [diff] [blame] | 62 | |
Mohamed Abukar | d976977 | 2019-11-20 20:39:06 +0200 | [diff] [blame] | 63 | # Run unit tests |
| 64 | RUN GO111MODULE=on GO_ENABLED=0 GOOS=linux go test -p 1 -cover ./pkg/cm/ ./pkg/helm/ ./pkg/resthooks/ |
| 65 | |
| 66 | RUN gofmt -l $(find cmd/ pkg/ -name '*.go' -not -name '*_test.go') |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 67 | |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 68 | CMD ["/bin/bash"] |
| 69 | |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 70 | #---------------------------------------------------------- |
Juha Hyttinen | 4703b1a | 2019-11-14 09:35:22 +0200 | [diff] [blame] | 71 | FROM ubuntu:18.04 as appmgr |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 72 | |
| 73 | RUN apt-get update -y \ |
| 74 | && apt-get install -y sudo openssl ca-certificates ca-cacert \ |
| 75 | && apt-get clean |
| 76 | |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 77 | # |
| 78 | # libraries and helm |
| 79 | # |
| 80 | COPY --from=appmgr-build /usr/local/include/ /usr/local/include/ |
| 81 | COPY --from=appmgr-build /usr/local/lib/ /usr/local/lib/ |
Lott, Christopher (cl778h) | 229b02e | 2019-06-04 15:50:49 -0400 | [diff] [blame] | 82 | COPY --from=appmgr-build /usr/local/bin/helm /usr/local/bin/helm |
| 83 | COPY --from=appmgr-build /usr/local/bin/kubectl /usr/local/bin/kubectl |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 84 | |
| 85 | RUN ldconfig |
| 86 | |
| 87 | # |
Mohamed Abukar | 34e4383 | 2019-11-13 17:57:15 +0200 | [diff] [blame] | 88 | # xApp Manager |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 89 | # |
| 90 | RUN mkdir -p /opt/xAppManager \ |
| 91 | && chmod -R 755 /opt/xAppManager |
| 92 | |
Mohamed Abukar | 34e4383 | 2019-11-13 17:57:15 +0200 | [diff] [blame] | 93 | COPY --from=appmgr-build /go/src/ws/cache/go/cmd/appmgr /opt/xAppManager/appmgr |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 94 | |
Abukar Mohamed | 97e8d9a | 2019-05-02 06:11:43 +0000 | [diff] [blame] | 95 | WORKDIR /opt/xAppManager |
| 96 | |
| 97 | COPY appmgr-entrypoint.sh /opt/xAppManager/ |
| 98 | ENTRYPOINT ["/opt/xAppManager/appmgr-entrypoint.sh"] |