blob: 77bed413bfe00c87b252aa31588e418e2998c993 [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
16#----------------------------------------------------------
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000017
Mohamed Abukar3bd90db2020-05-07 07:23:08 +030018FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:7-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}"
Mohamed Abukarb6e41352019-07-08 18:09:44 +030023ARG HELMVERSION=v2.12.3
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000024
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040025# Install helm
26RUN wget -nv https://storage.googleapis.com/kubernetes-helm/helm-${HELMVERSION}-linux-amd64.tar.gz \
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000027 && tar -zxvf helm-${HELMVERSION}-linux-amd64.tar.gz \
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040028 && cp linux-amd64/helm /usr/local/bin/helm \
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000029 && rm -rf helm-${HELMVERSION}-linux-amd64.tar.gz \
30 && rm -rf linux-amd64
31
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040032# Install kubectl from Docker Hub
Abukar Mohamedf8b99662020-03-02 14:44:30 +000033COPY --from=lachlanevenson/k8s-kubectl:v1.16.0 /usr/local/bin/kubectl /usr/local/bin/kubectl
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000034
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000035ENV GOPATH="/go"
36
Mohamed Abukar34e43832019-11-13 17:57:15 +020037# Swagger
38RUN mkdir -p /go/bin
39RUN 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
44RUN mkdir -p /go/src/ws
45WORKDIR "/go/src/ws"
46
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000047# Module prepare (if go.mod/go.sum updated)
Mohamed Abukar34e43832019-11-13 17:57:15 +020048COPY go.mod /go/src/ws
49COPY go.sum /go/src/ws
Abukar Mohamed059775c2019-05-22 14:48:10 +000050RUN GO111MODULE=on go mod download
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000051
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020052# build and test
Mohamed Abukar34e43832019-11-13 17:57:15 +020053COPY . /go/src/ws
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020054
Mohamed Abukard9769772019-11-20 20:39:06 +020055# Generate Swagger code
Mohamed Abukar34e43832019-11-13 17:57:15 +020056RUN /go/bin/swagger generate server -f api/appmgr_rest_api.yaml --name AppManager -t pkg/ --exclude-main
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020057
Mohamed Abukar34e43832019-11-13 17:57:15 +020058COPY . /go/src/ws
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020059
Mohamed Abukard9769772019-11-20 20:39:06 +020060# Build the code
61RUN 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 +020062
Mohamed Abukard9769772019-11-20 20:39:06 +020063# Run unit tests
64RUN GO111MODULE=on GO_ENABLED=0 GOOS=linux go test -p 1 -cover ./pkg/cm/ ./pkg/helm/ ./pkg/resthooks/
65
66RUN gofmt -l $(find cmd/ pkg/ -name '*.go' -not -name '*_test.go')
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000067
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000068CMD ["/bin/bash"]
69
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000070#----------------------------------------------------------
Juha Hyttinen4703b1a2019-11-14 09:35:22 +020071FROM ubuntu:18.04 as appmgr
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000072
73RUN apt-get update -y \
74 && apt-get install -y sudo openssl ca-certificates ca-cacert \
75 && apt-get clean
76
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000077#
78# libraries and helm
79#
80COPY --from=appmgr-build /usr/local/include/ /usr/local/include/
81COPY --from=appmgr-build /usr/local/lib/ /usr/local/lib/
Lott, Christopher (cl778h)229b02e2019-06-04 15:50:49 -040082COPY --from=appmgr-build /usr/local/bin/helm /usr/local/bin/helm
83COPY --from=appmgr-build /usr/local/bin/kubectl /usr/local/bin/kubectl
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000084
85RUN ldconfig
86
87#
Mohamed Abukar34e43832019-11-13 17:57:15 +020088# xApp Manager
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000089#
90RUN mkdir -p /opt/xAppManager \
91 && chmod -R 755 /opt/xAppManager
92
Mohamed Abukar34e43832019-11-13 17:57:15 +020093COPY --from=appmgr-build /go/src/ws/cache/go/cmd/appmgr /opt/xAppManager/appmgr
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000094
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000095WORKDIR /opt/xAppManager
96
97COPY appmgr-entrypoint.sh /opt/xAppManager/
98ENTRYPOINT ["/opt/xAppManager/appmgr-entrypoint.sh"]