327703712abac84a34c0b9c0c3d3218639495928
[ric-plt/appmgr.git] / docker / 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 ubuntubase
20
21 RUN apt-get update -y && \
22     apt-get install -y wget
23
24
25 RUN sed -i -e "s,http://archive.ubuntu.com/ubuntu,$(wget -qO - mirrors.ubuntu.com/mirrors.txt | head -1)," /etc/apt/sources.list
26 RUN sed -i -e "s,http://security.ubuntu.com/ubuntu,$(wget -qO - mirrors.ubuntu.com/mirrors.txt | head -1)," /etc/apt/sources.list
27
28 #
29 # packages
30 #
31 RUN apt-get update -y && \
32     apt-get upgrade -y && \
33     apt-get install -y \
34     build-essential \
35     apt-utils \
36     cmake \
37     make \
38     autoconf \
39     autoconf-archive \
40     gawk \
41     libtool \
42     automake \
43     pkg-config \
44     sudo \
45     wget \
46     nano \
47     git \
48     jq
49  
50
51 #
52 # go
53 #
54 RUN wget https://dl.google.com/go/go1.12.linux-amd64.tar.gz && \
55         tar -C /usr/local -xvf ./go1.12.linux-amd64.tar.gz
56
57 ENV PATH="/usr/local/go/bin:${PATH}"
58
59 #
60 # rancodev libs
61 #
62 RUN mkdir -p /opt/build \
63     && cd /opt/build && git clone https://gerrit.oran-osc.org/r/com/log \
64     && cd log/ ; ./autogen.sh ; ./configure ; make ; make install \
65     && ldconfig
66
67 #----------------------------------------------------------
68 #
69 #----------------------------------------------------------
70 FROM ubuntubase as builder
71
72 ARG PACKAGEURL=gerrit.oran-osc.org/r/ric-plt/appmgr
73 ARG HELMVERSION=v2.13.0-rc.1
74
75 #
76 # helm
77 #
78 RUN 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
85 #
86 # appmgr codes
87 #
88 RUN mkdir -p /go/src/${PACKAGEURL}
89 ENV GOPATH="/go"
90
91 #
92 # Speed up things by generating layer with needed go packages
93 #
94 RUN go get github.com/gorilla/mux \
95     && go get github.com/spf13/viper \
96     && go get github.com/gorilla/mux \
97     && go get github.com/orcaman/concurrent-map \
98     && go get github.com/segmentio/ksuid \
99     && go get gopkg.in/yaml.v2
100
101
102 COPY . /go/src/${PACKAGEURL}
103
104
105 #
106 # build
107 #
108 RUN make -C /go/src/${PACKAGEURL} build
109
110
111 #----------------------------------------------------------
112 #
113 #----------------------------------------------------------
114 FROM builder as test_unit
115 ARG PACKAGEURL=gerrit.oran-osc.org/r/ric-plt/appmgr
116 WORKDIR "/go/src/${PACKAGEURL}"
117 CMD ["make","test"]
118
119
120 #----------------------------------------------------------
121 #
122 #----------------------------------------------------------
123 FROM builder as test_fmt
124 ARG PACKAGEURL=gerrit.oran-osc.org/r/ric-plt/appmgr
125 WORKDIR "/go/src/${PACKAGEURL}"
126 CMD ["make","test-fmt"]
127
128 #----------------------------------------------------------
129 #
130 #----------------------------------------------------------
131 FROM builder as test_sanity
132 ARG PACKAGEURL=gerrit.oran-osc.org/r/ric-plt/appmgr
133 WORKDIR "/go/src/${PACKAGEURL}"
134 CMD ["jq","-s",".", "api/appmgr_rest_api.json"]
135
136
137 #----------------------------------------------------------
138 #
139 #----------------------------------------------------------
140 FROM ubuntu:16.04 as release
141 ARG PACKAGEURL=gerrit.oran-osc.org/r/ric-plt/appmgr
142
143 RUN apt-get update -y \
144     && apt-get install -y sudo openssl ca-certificates ca-cacert \
145     && apt-get clean
146
147
148 #
149 # libraries and helm
150 #
151 COPY --from=builder /usr/local/include/ /usr/local/include/
152 COPY --from=builder /usr/local/lib/ /usr/local/lib/
153 COPY --from=builder /usr/bin/helm /usr/bin/helm
154
155 RUN ldconfig
156
157 #
158 # xApp
159 #
160 RUN mkdir -p /opt/xAppManager \
161     && chmod -R 755 /opt/xAppManager
162
163 COPY --from=builder /go/src/${PACKAGEURL}/build/appmgr /opt/xAppManager/appmgr
164 #COPY --from=builder /go/src/${PACKAGEURL}/config/appmgr.yaml /opt/etc/xAppManager/config-file.yaml
165
166
167 COPY docker/docker-entrypoint.sh /opt/xAppManager/
168
169 WORKDIR /opt/xAppManager
170
171 ENTRYPOINT ["/opt/xAppManager/docker-entrypoint.sh"]