blob: b2b314b60887718a597bf763f67d46485f981413 [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#----------------------------------------------------------
17#
18#----------------------------------------------------------
19FROM ubuntu:16.04 as xapp-base
20
21RUN apt-get update -y && \
22 apt-get install -y wget
23
24RUN sed -i -e "s,http://archive.ubuntu.com/ubuntu,$(wget -qO - mirrors.ubuntu.com/mirrors.txt | head -1)," /etc/apt/sources.list
25RUN sed -i -e "s,http://security.ubuntu.com/ubuntu,$(wget -qO - mirrors.ubuntu.com/mirrors.txt | head -1)," /etc/apt/sources.list
26
27#
28# packages
29#
30RUN apt-get update -y && \
31 apt-get upgrade -y && \
32 apt-get install -y \
33 build-essential \
34 apt-utils \
35 cmake \
36 make \
37 autoconf \
38 autoconf-archive \
39 gawk \
40 libtool \
41 automake \
42 pkg-config \
43 sudo \
44 wget \
45 nano \
46 git \
47 jq
48
49
50#
51# go
52#
53RUN wget https://dl.google.com/go/go1.12.linux-amd64.tar.gz && \
54 tar -C /usr/local -xvf ./go1.12.linux-amd64.tar.gz
55
56ENV PATH="/usr/local/go/bin:${PATH}"
57
58#
59# rancodev libs
60#
61RUN mkdir -p /opt/build \
62 && cd /opt/build && git clone https://gerrit.oran-osc.org/r/com/log \
63 && cd log/ ; ./autogen.sh ; ./configure ; make ; make install \
64 && ldconfig
65
66COPY build/build_entrypoint.sh /
67COPY build/user_entrypoint.sh /
68
69RUN chmod +x /build_entrypoint.sh
70RUN chmod +x /user_entrypoint.sh
71
72RUN mkdir -p /ws
73WORKDIR "/ws"
74ENTRYPOINT ["/user_entrypoint.sh"]
75CMD ["/bin/bash"]
76
77#----------------------------------------------------------
78#
79#----------------------------------------------------------
80FROM xapp-base as appmgr-build
81
82ARG PACKAGEURL
83ARG PACKAGEREPO
84ARG SSH_PRIVATE_KEY
85ARG NETRC_CONFIG
86ARG HELMVERSION
87
88
89#
90# helm
91#
92RUN wget https://storage.googleapis.com/kubernetes-helm/helm-${HELMVERSION}-linux-amd64.tar.gz \
93 && tar -zxvf helm-${HELMVERSION}-linux-amd64.tar.gz \
94 && cp linux-amd64/helm /usr/bin/helm \
95 && rm -rf helm-${HELMVERSION}-linux-amd64.tar.gz \
96 && rm -rf linux-amd64
97
98# Install kubectl from Docker Hub.
99COPY --from=lachlanevenson/k8s-kubectl:v1.10.3 /usr/local/bin/kubectl /usr/local/bin/kubectl
100
101RUN mkdir -p /go/src/${PACKAGEURL}
102WORKDIR "/go/src/${PACKAGEURL}"
103ENV GOPATH="/go"
104
105# Module prepare (if go.mod/go.sum updated)
106COPY go.mod /go/src/${PACKAGEURL}
107COPY go.sum /go/src/${PACKAGEURL}
108RUN GO111MODULE=on /build_entrypoint.sh go mod download
109
110# build
111COPY . /go/src/${PACKAGEURL}
112RUN /build_entrypoint.sh make -C /go/src/${PACKAGEURL} build
113
114ENTRYPOINT ["/build_entrypoint.sh"]
115CMD ["/bin/bash"]
116
117
118#----------------------------------------------------------
119#
120#----------------------------------------------------------
121FROM appmgr-build as appmgr-test_unit
122ARG PACKAGEURL
123WORKDIR "/go/src/${PACKAGEURL}"
124CMD ["make","go-test"]
125
126
127#----------------------------------------------------------
128#
129#----------------------------------------------------------
130FROM appmgr-build as appmgr-test_fmt
131ARG PACKAGEURL
132WORKDIR "/go/src/${PACKAGEURL}"
133CMD ["make","go-test-fmt"]
134
135#----------------------------------------------------------
136#
137#----------------------------------------------------------
138FROM appmgr-build as appmgr-test_sanity
139ARG PACKAGEURL
140WORKDIR "/go/src/${PACKAGEURL}"
141CMD ["jq","-s",".", "api/appmgr_rest_api.json"]
142
143
144#----------------------------------------------------------
145#
146#----------------------------------------------------------
147FROM ubuntu:16.04 as appmgr
148ARG PACKAGEURL
149
150RUN apt-get update -y \
151 && apt-get install -y sudo openssl ca-certificates ca-cacert \
152 && apt-get clean
153
154
155#
156# libraries and helm
157#
158COPY --from=appmgr-build /usr/local/include/ /usr/local/include/
159COPY --from=appmgr-build /usr/local/lib/ /usr/local/lib/
160COPY --from=appmgr-build /usr/bin/helm /usr/bin/helm
161COPY --from=appmgr-build /usr/local/bin/kubectl /usr/bin/kubectl
162
163RUN ldconfig
164
165#
166# xApp
167#
168RUN mkdir -p /opt/xAppManager \
169 && chmod -R 755 /opt/xAppManager
170
171COPY --from=appmgr-build /go/src/${PACKAGEURL}/build/cache/cmd/appmgr /opt/xAppManager/appmgr
172#COPY --from=appmgr-build /go/src/${PACKAGEURL}/config/appmgr.yaml /opt/etc/xAppManager/config-file.yaml
173
174
175WORKDIR /opt/xAppManager
176
177COPY appmgr-entrypoint.sh /opt/xAppManager/
178ENTRYPOINT ["/opt/xAppManager/appmgr-entrypoint.sh"]