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