Build related cleanup. Entrypoint to read config from correct place.
[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-ubuntu18-c-go:2-u18.04-nng 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
25 # Install helm
26 RUN wget -nv https://storage.googleapis.com/kubernetes-helm/helm-${HELMVERSION}-linux-amd64.tar.gz \
27     && tar -zxvf helm-${HELMVERSION}-linux-amd64.tar.gz \
28     && cp linux-amd64/helm /usr/local/bin/helm \
29     && rm -rf helm-${HELMVERSION}-linux-amd64.tar.gz \
30     && rm -rf linux-amd64
31
32 # Install kubectl from Docker Hub
33 COPY --from=lachlanevenson/k8s-kubectl:v1.10.3 /usr/local/bin/kubectl /usr/local/bin/kubectl
34
35 RUN mkdir -p /ws
36 WORKDIR "/ws"
37 ENV GOPATH="/go"
38
39 # Module prepare (if go.mod/go.sum updated)
40 COPY go.mod /ws
41 COPY go.sum /ws
42 RUN GO111MODULE=on go mod download
43
44 # build and test
45 COPY . /ws
46
47 RUN make -C /ws go-build
48
49 RUN make -C /ws go-test-fmt
50
51 #RUN make -C /ws go-test
52
53 CMD ["/bin/bash"]
54
55 #----------------------------------------------------------
56 FROM ubuntu:18.04 as appmgr
57
58 RUN apt-get update -y \
59     && apt-get install -y sudo openssl ca-certificates ca-cacert \
60     && apt-get clean
61
62 #
63 # libraries and helm
64 #
65 COPY --from=appmgr-build /usr/local/include/ /usr/local/include/
66 COPY --from=appmgr-build /usr/local/lib/ /usr/local/lib/
67 COPY --from=appmgr-build /usr/local/bin/helm /usr/local/bin/helm
68 COPY --from=appmgr-build /usr/local/bin/kubectl /usr/local/bin/kubectl
69
70 RUN ldconfig
71
72 #
73 # xApp
74 #
75 RUN mkdir -p /opt/xAppManager \
76     && chmod -R 755 /opt/xAppManager
77
78 COPY --from=appmgr-build /ws/cache/go/cmd/appmgr /opt/xAppManager/appmgr
79
80 WORKDIR /opt/xAppManager
81
82 COPY appmgr-entrypoint.sh /opt/xAppManager/
83 ENTRYPOINT ["/opt/xAppManager/appmgr-entrypoint.sh"]