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