blob: 7f313d8e58b0d5a285012fe13ad6f14366b4fe93 [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
Mohamed Abukar2771ea22020-10-14 11:45:20 +030018FROM 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 +000019
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040020RUN apt-get update -y && apt-get install -y jq
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000021
22ENV PATH="/usr/local/go/bin:${PATH}"
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000023
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040024# Install helm
wahidwd8726302020-12-13 17:34:29 +000025#RUN wget -nv https://storage.googleapis.com/kubernetes-helm/helm-${HELMVERSION}-linux-amd64.tar.gz \
26# && tar -zxvf helm-${HELMVERSION}-linux-amd64.tar.gz \
27# && cp linux-amd64/helm /usr/local/bin/helm \
28# && rm -rf helm-${HELMVERSION}-linux-amd64.tar.gz \
29# && rm -rf linux-amd64
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000030
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040031# Install kubectl from Docker Hub
wahidwd8726302020-12-13 17:34:29 +000032#COPY --from=lachlanevenson/k8s-kubectl:v1.16.0 /usr/local/bin/kubectl /usr/local/bin/kubectl
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000033
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000034ENV GOPATH="/go"
35
Mohamed Abukar34e43832019-11-13 17:57:15 +020036# Swagger
37RUN mkdir -p /go/bin
38RUN cd /go/bin \
39 && wget --quiet https://github.com/go-swagger/go-swagger/releases/download/v0.19.0/swagger_linux_amd64 \
40 && mv swagger_linux_amd64 swagger \
41 && chmod +x swagger
42
43RUN mkdir -p /go/src/ws
44WORKDIR "/go/src/ws"
45
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000046# Module prepare (if go.mod/go.sum updated)
Mohamed Abukar34e43832019-11-13 17:57:15 +020047COPY go.mod /go/src/ws
48COPY go.sum /go/src/ws
Abukar Mohamed059775c2019-05-22 14:48:10 +000049RUN GO111MODULE=on go mod download
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000050
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020051# build and test
Mohamed Abukar34e43832019-11-13 17:57:15 +020052COPY . /go/src/ws
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020053
Mohamed Abukard9769772019-11-20 20:39:06 +020054# Generate Swagger code
Mohamed Abukar34e43832019-11-13 17:57:15 +020055RUN /go/bin/swagger generate server -f api/appmgr_rest_api.yaml --name AppManager -t pkg/ --exclude-main
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020056
Mohamed Abukar34e43832019-11-13 17:57:15 +020057COPY . /go/src/ws
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020058
Mohamed Abukard9769772019-11-20 20:39:06 +020059# Build the code
60RUN 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 +020061
Mohamed Abukard9769772019-11-20 20:39:06 +020062# Run unit tests
wahidwd8726302020-12-13 17:34:29 +000063RUN GO111MODULE=on GO_ENABLED=0 GOOS=linux go test -p 1 -cover ./pkg/resthooks/
Mohamed Abukard9769772019-11-20 20:39:06 +020064
65RUN gofmt -l $(find cmd/ pkg/ -name '*.go' -not -name '*_test.go')
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000066
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000067CMD ["/bin/bash"]
68
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000069#----------------------------------------------------------
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020070FROM ubuntu:18.04 as appmgr
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000071
72RUN apt-get update -y \
73 && apt-get install -y sudo openssl ca-certificates ca-cacert \
74 && apt-get clean
75
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000076#
77# libraries and helm
78#
79COPY --from=appmgr-build /usr/local/include/ /usr/local/include/
80COPY --from=appmgr-build /usr/local/lib/ /usr/local/lib/
wahidwd8726302020-12-13 17:34:29 +000081#COPY --from=appmgr-build /usr/local/bin/helm /usr/local/bin/helm
82#COPY --from=appmgr-build /usr/local/bin/kubectl /usr/local/bin/kubectl
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000083
84RUN ldconfig
85
86#
Mohamed Abukar34e43832019-11-13 17:57:15 +020087# xApp Manager
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000088#
89RUN mkdir -p /opt/xAppManager \
90 && chmod -R 755 /opt/xAppManager
91
Mohamed Abukar34e43832019-11-13 17:57:15 +020092COPY --from=appmgr-build /go/src/ws/cache/go/cmd/appmgr /opt/xAppManager/appmgr
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000093
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000094WORKDIR /opt/xAppManager
95
96COPY appmgr-entrypoint.sh /opt/xAppManager/
97ENTRYPOINT ["/opt/xAppManager/appmgr-entrypoint.sh"]