blob: bace8a89773987e3fe77a2778f806098536262b2 [file] [log] [blame]
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +00001# 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
Alok Bhatt6ff31e22020-11-11 06:52:26 +000016#-----------------------------------------------------------
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000017
Alok Bhatt6ff31e22020-11-11 06:52:26 +000018ARG HELMVERSION=v2.12.3
Mohamed Abukar2771ea22020-10-14 11:45:20 +030019FROM nexus3.o-ran-sc.org:10004/o-ran-sc/bldr-ubuntu18-c-go:9-u18.04 AS appmgr-build
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000020
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040021RUN apt-get update -y && apt-get install -y jq
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000022
23ENV PATH="/usr/local/go/bin:${PATH}"
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000024
Alok Bhatt6ff31e22020-11-11 06:52:26 +000025ARG HELMVERSION
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040026# Install helm
Alok Bhatt6ff31e22020-11-11 06:52:26 +000027RUN wget -nv https://get.helm.sh/helm-${HELMVERSION}-linux-amd64.tar.gz \
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000028 && tar -zxvf helm-${HELMVERSION}-linux-amd64.tar.gz \
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040029 && cp linux-amd64/helm /usr/local/bin/helm \
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000030 && rm -rf helm-${HELMVERSION}-linux-amd64.tar.gz \
31 && rm -rf linux-amd64
32
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040033# Install kubectl from Docker Hub
Abukar Mohamedf8b99662020-03-02 14:44:30 +000034COPY --from=lachlanevenson/k8s-kubectl:v1.16.0 /usr/local/bin/kubectl /usr/local/bin/kubectl
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000035
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000036ENV GOPATH="/go"
37
Mohamed Abukar34e43832019-11-13 17:57:15 +020038# Swagger
39RUN mkdir -p /go/bin
40RUN cd /go/bin \
41 && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \
42 && mv swagger_linux_amd64 swagger \
43 && chmod +x swagger
44
45RUN mkdir -p /go/src/ws
46WORKDIR "/go/src/ws"
47
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000048# Module prepare (if go.mod/go.sum updated)
Mohamed Abukar34e43832019-11-13 17:57:15 +020049COPY go.mod /go/src/ws
50COPY go.sum /go/src/ws
Abukar Mohamed059775c2019-05-22 14:48:10 +000051RUN GO111MODULE=on go mod download
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000052
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020053# build and test
Mohamed Abukar34e43832019-11-13 17:57:15 +020054COPY . /go/src/ws
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020055
Mohamed Abukard9769772019-11-20 20:39:06 +020056# Generate Swagger code
Mohamed Abukar34e43832019-11-13 17:57:15 +020057RUN /go/bin/swagger generate server -f api/appmgr_rest_api.yaml --name AppManager -t pkg/ --exclude-main
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020058
Mohamed Abukar34e43832019-11-13 17:57:15 +020059COPY . /go/src/ws
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020060
Mohamed Abukard9769772019-11-20 20:39:06 +020061# Build the code
62RUN GO111MODULE=on GO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/src/ws/cache/go/cmd/appmgr cmd/appmgr.go
Mohamed Abukar34e43832019-11-13 17:57:15 +020063
Mohamed Abukard9769772019-11-20 20:39:06 +020064# Run unit tests
65RUN GO111MODULE=on GO_ENABLED=0 GOOS=linux go test -p 1 -cover ./pkg/cm/ ./pkg/helm/ ./pkg/resthooks/
66
67RUN gofmt -l $(find cmd/ pkg/ -name '*.go' -not -name '*_test.go')
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000068
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000069CMD ["/bin/bash"]
70
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000071#----------------------------------------------------------
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020072FROM ubuntu:18.04 as appmgr
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000073
74RUN apt-get update -y \
75 && apt-get install -y sudo openssl ca-certificates ca-cacert \
76 && apt-get clean
77
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000078#
79# libraries and helm
80#
81COPY --from=appmgr-build /usr/local/include/ /usr/local/include/
82COPY --from=appmgr-build /usr/local/lib/ /usr/local/lib/
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040083COPY --from=appmgr-build /usr/local/bin/helm /usr/local/bin/helm
84COPY --from=appmgr-build /usr/local/bin/kubectl /usr/local/bin/kubectl
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000085
86RUN ldconfig
87
Alok Bhatt6ff31e22020-11-11 06:52:26 +000088ARG HELMVERSION
89ENV HELMVERSION=$HELMVERSION
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000090#
Mohamed Abukar34e43832019-11-13 17:57:15 +020091# xApp Manager
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000092#
93RUN mkdir -p /opt/xAppManager \
94 && chmod -R 755 /opt/xAppManager
95
Mohamed Abukar34e43832019-11-13 17:57:15 +020096COPY --from=appmgr-build /go/src/ws/cache/go/cmd/appmgr /opt/xAppManager/appmgr
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000097
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000098WORKDIR /opt/xAppManager
99
100COPY appmgr-entrypoint.sh /opt/xAppManager/
101ENTRYPOINT ["/opt/xAppManager/appmgr-entrypoint.sh"]