blob: db660b970ce49560b5354da57c8c70f302d7579d [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#----------------------------------------------------------
Abukar Mohamed059775c2019-05-22 14:48:10 +000019FROM ubuntu:16.04 as appmgr-xapp-base
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000020
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 && \
Abukar Mohamedd732b872019-06-13 12:48:35 +000031 apt-get upgrade -y && \
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000032 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
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000058COPY build/user_entrypoint.sh /
59
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000060RUN chmod +x /user_entrypoint.sh
61
62RUN mkdir -p /ws
63WORKDIR "/ws"
64ENTRYPOINT ["/user_entrypoint.sh"]
65CMD ["/bin/bash"]
66
67#----------------------------------------------------------
68#
69#----------------------------------------------------------
Abukar Mohamed059775c2019-05-22 14:48:10 +000070FROM appmgr-xapp-base as appmgr-build
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000071
Mohamed Abukar91357512019-06-20 06:37:13 +030072ARG HELMVERSION=v2.13.0-rc.1
73ARG PACKAGEURL=gerrit.o-ran-sc.org/r/c/ric-plt/appmgr/
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000074
75#
76# helm
77#
78RUN wget https://storage.googleapis.com/kubernetes-helm/helm-${HELMVERSION}-linux-amd64.tar.gz \
79 && tar -zxvf helm-${HELMVERSION}-linux-amd64.tar.gz \
80 && cp linux-amd64/helm /usr/bin/helm \
81 && rm -rf helm-${HELMVERSION}-linux-amd64.tar.gz \
82 && rm -rf linux-amd64
83
84# Install kubectl from Docker Hub.
85COPY --from=lachlanevenson/k8s-kubectl:v1.10.3 /usr/local/bin/kubectl /usr/local/bin/kubectl
86
87RUN mkdir -p /go/src/${PACKAGEURL}
88WORKDIR "/go/src/${PACKAGEURL}"
89ENV GOPATH="/go"
90
91# Module prepare (if go.mod/go.sum updated)
92COPY go.mod /go/src/${PACKAGEURL}
93COPY go.sum /go/src/${PACKAGEURL}
Abukar Mohamed059775c2019-05-22 14:48:10 +000094RUN GO111MODULE=on go mod download
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000095
96# build
97COPY . /go/src/${PACKAGEURL}
Abukar Mohamed059775c2019-05-22 14:48:10 +000098RUN make -C /go/src/${PACKAGEURL} build
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +000099
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +0000100CMD ["/bin/bash"]
101
102
103#----------------------------------------------------------
104#
105#----------------------------------------------------------
106FROM appmgr-build as appmgr-test_unit
Mohamed Abukar91357512019-06-20 06:37:13 +0300107ARG PACKAGEURL=gerrit.o-ran-sc.org/r/c/ric-plt/appmgr/
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +0000108WORKDIR "/go/src/${PACKAGEURL}"
109CMD ["make","go-test"]
110
111
112#----------------------------------------------------------
113#
114#----------------------------------------------------------
115FROM appmgr-build as appmgr-test_fmt
Mohamed Abukar91357512019-06-20 06:37:13 +0300116ARG PACKAGEURL=gerrit.o-ran-sc.org/r/c/ric-plt/appmgr/
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +0000117WORKDIR "/go/src/${PACKAGEURL}"
118CMD ["make","go-test-fmt"]
119
120#----------------------------------------------------------
121#
122#----------------------------------------------------------
123FROM appmgr-build as appmgr-test_sanity
Mohamed Abukar91357512019-06-20 06:37:13 +0300124ARG PACKAGEURL=gerrit.o-ran-sc.org/r/c/ric-plt/appmgr/
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +0000125WORKDIR "/go/src/${PACKAGEURL}"
126CMD ["jq","-s",".", "api/appmgr_rest_api.json"]
127
128
129#----------------------------------------------------------
130#
131#----------------------------------------------------------
132FROM ubuntu:16.04 as appmgr
Mohamed Abukar91357512019-06-20 06:37:13 +0300133ARG PACKAGEURL=gerrit.o-ran-sc.org/r/c/ric-plt/appmgr/
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +0000134
135RUN apt-get update -y \
136 && apt-get install -y sudo openssl ca-certificates ca-cacert \
137 && apt-get clean
138
139
140#
141# libraries and helm
142#
143COPY --from=appmgr-build /usr/local/include/ /usr/local/include/
144COPY --from=appmgr-build /usr/local/lib/ /usr/local/lib/
145COPY --from=appmgr-build /usr/bin/helm /usr/bin/helm
146COPY --from=appmgr-build /usr/local/bin/kubectl /usr/bin/kubectl
147
148RUN ldconfig
149
150#
151# xApp
152#
153RUN mkdir -p /opt/xAppManager \
154 && chmod -R 755 /opt/xAppManager
155
Abukar Mohamed059775c2019-05-22 14:48:10 +0000156COPY --from=appmgr-build /go/src/${PACKAGEURL}/cache/go/cmd/appmgr /opt/xAppManager/appmgr
Abukar Mohamed97e8d9a2019-05-02 06:11:43 +0000157#COPY --from=appmgr-build /go/src/${PACKAGEURL}/config/appmgr.yaml /opt/etc/xAppManager/config-file.yaml
158
159
160WORKDIR /opt/xAppManager
161
162COPY appmgr-entrypoint.sh /opt/xAppManager/
163ENTRYPOINT ["/opt/xAppManager/appmgr-entrypoint.sh"]