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