Enabling helm3 Support for appmgr.
[ric-plt/appmgr.git] / Dockerfile
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 #-----------------------------------------------------------
17
18 ARG HELMVERSION=v2.12.3
19 FROM nexus3.o-ran-sc.org:10004/o-ran-sc/bldr-ubuntu18-c-go:9-u18.04 AS appmgr-build
20
21 RUN apt-get update -y && apt-get install -y jq
22
23 ENV PATH="/usr/local/go/bin:${PATH}"
24
25 ARG HELMVERSION
26 # Install helm
27 RUN wget -nv https://get.helm.sh/helm-${HELMVERSION}-linux-amd64.tar.gz \
28     && tar -zxvf helm-${HELMVERSION}-linux-amd64.tar.gz \
29     && cp linux-amd64/helm /usr/local/bin/helm \
30     && rm -rf helm-${HELMVERSION}-linux-amd64.tar.gz \
31     && rm -rf linux-amd64
32
33 # Install kubectl from Docker Hub
34 COPY --from=lachlanevenson/k8s-kubectl:v1.16.0 /usr/local/bin/kubectl /usr/local/bin/kubectl
35
36 ENV GOPATH="/go"
37
38 # Swagger
39 RUN mkdir -p /go/bin
40 RUN 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
45 RUN mkdir -p /go/src/ws
46 WORKDIR "/go/src/ws"
47
48 # Module prepare (if go.mod/go.sum updated)
49 COPY go.mod /go/src/ws
50 COPY go.sum /go/src/ws
51 RUN GO111MODULE=on go mod download
52
53 # build and test
54 COPY . /go/src/ws
55
56 # Generate Swagger code
57 RUN /go/bin/swagger generate server -f api/appmgr_rest_api.yaml --name AppManager -t pkg/ --exclude-main
58
59 COPY . /go/src/ws
60
61 # Build the code
62 RUN GO111MODULE=on GO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/src/ws/cache/go/cmd/appmgr cmd/appmgr.go
63
64 # Run unit tests
65 RUN GO111MODULE=on GO_ENABLED=0 GOOS=linux go test -p 1 -cover ./pkg/cm/ ./pkg/helm/ ./pkg/resthooks/
66
67 RUN gofmt -l $(find cmd/ pkg/  -name '*.go' -not -name '*_test.go')
68
69 CMD ["/bin/bash"]
70
71 #----------------------------------------------------------
72 FROM ubuntu:18.04 as appmgr
73
74 RUN apt-get update -y \
75     && apt-get install -y sudo openssl ca-certificates ca-cacert \
76     && apt-get clean
77
78 #
79 # libraries and helm
80 #
81 COPY --from=appmgr-build /usr/local/include/ /usr/local/include/
82 COPY --from=appmgr-build /usr/local/lib/ /usr/local/lib/
83 COPY --from=appmgr-build /usr/local/bin/helm /usr/local/bin/helm
84 COPY --from=appmgr-build /usr/local/bin/kubectl /usr/local/bin/kubectl
85
86 RUN ldconfig
87
88 ARG HELMVERSION
89 ENV HELMVERSION=$HELMVERSION
90 #
91 # xApp Manager
92 #
93 RUN mkdir -p /opt/xAppManager \
94     && chmod -R 755 /opt/xAppManager
95
96 COPY --from=appmgr-build /go/src/ws/cache/go/cmd/appmgr /opt/xAppManager/appmgr
97
98 WORKDIR /opt/xAppManager
99
100 COPY appmgr-entrypoint.sh /opt/xAppManager/
101 ENTRYPOINT ["/opt/xAppManager/appmgr-entrypoint.sh"]