Merge "Revise Docker-based CI to build 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 FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu16-c-go:1-u16.04-nng1.1.1 AS appmgr-build
19
20 RUN apt-get update -y && apt-get install -y jq
21
22 ENV PATH="/usr/local/go/bin:${PATH}"
23 ARG HELMVERSION=v2.12.3
24 ARG PACKAGEURL=gerrit.o-ran-sc.org/r/ric-plt/appmgr
25
26 # Install helm
27 RUN wget -nv https://storage.googleapis.com/kubernetes-helm/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.10.3 /usr/local/bin/kubectl /usr/local/bin/kubectl
35
36 RUN mkdir -p /go/src/${PACKAGEURL}
37 WORKDIR "/go/src/${PACKAGEURL}"
38 ENV GOPATH="/go"
39
40 # Module prepare (if go.mod/go.sum updated)
41 COPY go.mod /go/src/${PACKAGEURL}
42 COPY go.sum /go/src/${PACKAGEURL}
43 RUN GO111MODULE=on go mod download
44
45 # build
46 COPY . /go/src/${PACKAGEURL}
47 RUN make -C /go/src/${PACKAGEURL} build
48
49 CMD ["/bin/bash"]
50
51 #----------------------------------------------------------
52 FROM ubuntu:16.04 as appmgr
53 ARG PACKAGEURL=gerrit.o-ran-sc.org/r/ric-plt/appmgr
54
55 RUN apt-get update -y \
56     && apt-get install -y sudo openssl ca-certificates ca-cacert \
57     && apt-get clean
58
59 #
60 # libraries and helm
61 #
62 COPY --from=appmgr-build /usr/local/include/ /usr/local/include/
63 COPY --from=appmgr-build /usr/local/lib/ /usr/local/lib/
64 COPY --from=appmgr-build /usr/local/bin/helm /usr/local/bin/helm
65 COPY --from=appmgr-build /usr/local/bin/kubectl /usr/local/bin/kubectl
66
67 RUN ldconfig
68
69 #
70 # xApp
71 #
72 RUN mkdir -p /opt/xAppManager \
73     && chmod -R 755 /opt/xAppManager
74
75 COPY --from=appmgr-build /go/src/${PACKAGEURL}/cache/go/cmd/appmgr /opt/xAppManager/appmgr
76 #COPY --from=appmgr-build /go/src/${PACKAGEURL}/config/appmgr.yaml /opt/etc/xAppManager/config-file.yaml
77
78 WORKDIR /opt/xAppManager
79
80 COPY appmgr-entrypoint.sh /opt/xAppManager/
81 ENTRYPOINT ["/opt/xAppManager/appmgr-entrypoint.sh"]