Bug fix.
[sim/o1-interface.git] / ntsimulator / deploy / nts-manager / Dockerfile
1 FROM ubuntu:18.04 AS builder
2
3 LABEL maintainer="alexandru.stancu@highstreet-technologies.com"
4
5 RUN \
6       apt-get update && apt-get install -y \
7       # general tools
8       git \
9       cmake \
10       build-essential \
11       vim \
12       supervisor \
13       # libyang
14       libpcre3-dev \
15       pkg-config \
16       # sysrepo
17       libavl-dev \
18       libev-dev \
19       libprotobuf-c-dev \
20       protobuf-c-compiler \
21       # netopeer2 \
22       libssh-dev \
23       libssl-dev \
24       # bindings
25       swig \
26       python-dev \
27       libcurl4 \
28       libcurl4-openssl-dev \
29       curl \
30       bc \
31       python-setuptools \
32       python-pip
33
34 # add netconf user
35 RUN \
36       adduser --system netconf && \
37       echo "netconf:netconf" | chpasswd
38
39 # generate ssh keys for netconf user
40 USER netconf
41 RUN \
42       mkdir -p /home/netconf/.ssh && \
43       ssh-keygen -A && \
44       ssh-keygen -t rsa -P '' -f /home/netconf/.ssh/id_dsa && \
45       cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys
46 #echo "Host *\n    StrictHostKeyChecking accept-new" >> /home/netconf/.ssh/config
47 USER root
48 RUN \
49       echo "    StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \
50       mkdir -p /root/.ssh && \
51       cat /home/netconf/.ssh/id_dsa.pub > /root/.ssh/authorized_keys
52        
53 # use /opt/dev as working directory
54 RUN mkdir /opt/dev
55 WORKDIR /opt/dev
56
57 # libcjson
58 RUN \
59       git clone https://github.com/Melacon/cJSON.git && \
60       cd cJSON && mkdir build && cd build && \
61       cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off -DCMAKE_INSTALL_PREFIX=/usr .. && \
62       make -j2 && \
63       make install && \
64       ldconfig
65
66 # libyang
67 RUN \
68       git clone https://github.com/Melacon/libyang.git && \
69       cd libyang && mkdir build && cd build && \
70       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
71       make -j2 && \
72       make install && \
73       ldconfig
74
75 # sysrepo
76 RUN \
77       git clone https://github.com/Melacon/sysrepo.git && \
78       sed -i 's/#define MAX_BLOCKS_AVAIL_FOR_ALLOC    3/#define MAX_BLOCKS_AVAIL_FOR_ALLOC    6/g' ./sysrepo/src/common/sr_mem_mgmt.h && \
79       cd sysrepo && mkdir build && cd build && \
80       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_TESTS=OFF -DREPOSITORY_LOC:PATH=/etc/sysrepo -DREQUEST_TIMEOUT=60 -DOPER_DATA_PROVIDE_TIMEOUT=60 .. && \
81       make -j2 && \
82       make install && \
83       ldconfig
84
85 # libnetconf2
86 RUN \
87       git clone https://github.com/Melacon/libnetconf2.git && \
88       cd libnetconf2 && mkdir build && cd build && \
89       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
90       make -j2 && \
91       make install && \
92       ldconfig
93
94 # keystore
95 RUN \
96       git clone https://github.com/Melacon/Netopeer2.git && \
97       cd Netopeer2 && \
98       cd keystored && mkdir build && cd build && \
99       cmake -DCMAKE_BUILD_TYPE:String="Release" -DKEYSTORED_KEYS_DIR=/home/netconf/.ssh .. && \
100       make -j2 && \
101       make install && \
102       ldconfig
103
104 # netopeer2
105 RUN \
106       cd /opt/dev/Netopeer2/server && mkdir build && cd build && \
107       cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
108       make -j2 && \
109       make install && \
110       cd ../../cli && mkdir build && cd build && \
111       cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
112       make -j2 && \
113       make install
114
115 # NTSimulator Manager
116 COPY . /opt/dev/ntsimulator
117 COPY ./deploy/nts-manager/CMakeLists.txt /opt/dev/ntsimulator/CMakeLists.txt
118 RUN \
119       cd /opt/dev && \
120       cd ntsimulator && mkdir build  && cd build && \
121       cmake .. && \
122       make -j2 && \
123       make install
124
125
126 # Second stage
127 FROM ubuntu:18.04  
128
129 LABEL maintainer="alexandru.stancu@highstreet-technologies.com"
130
131 ENV NETCONF_BASE=40000
132 ENV NTS_IP="127.0.0.1"
133 # ENV EXTERNAL_NTS_IP="172.17.0.1" - this can be given in the docker-compose.yml file to
134 # overwrite the IP that is exposed via pnfRegistration or via mount HTTP REST; if not specified, NTS_IP will be used
135 ENV SCRIPTS_DIR=/opt/dev/scripts
136 ENV DOCKER_ENGINE_VERSION="1.40"
137 ENV MODELS_IMAGE="ntsim_oran"
138 ENV VesHeartbeatPeriod=0
139 ENV IsVesAvailable=true
140 ENV IsNetconfAvailable=true
141 ENV VesRegistration=false
142 ENV VesEndpointPort=8080
143 ENV VesEndpointIp="172.17.0.1"
144 ENV VesEndpointAuthMethod="no-auth"
145 ENV VesEndpointUsername="admin"
146 ENV VesEndpointPassword="admin"
147 ENV SshConnections=1
148 ENV TlsConnections=0
149 ENV K8S_DEPLOYMENT=false
150 ENV CONTAINER_NAME="ntsim"
151 ENV ControllerIp="172.17.0.1"
152 ENV ControllerPort=8181
153 ENV NetconfCallHomePort=6666
154 ENV ControllerUsername="admin"
155 ENV ControllerPassword="admin"
156 ENV NetconfCallHome=false
157 ENV Ipv6Enabled=false
158
159 RUN \
160       apt-get update && apt-get install -y supervisor bc
161
162 # add netconf user
163 RUN \
164       adduser --system netconf && \
165       echo "netconf:netconf" | chpasswd
166
167 USER netconf
168 # generate ssh keys for netconf user
169 RUN \
170       mkdir -p /home/netconf/.ssh
171
172 COPY --from=builder /home/netconf/.ssh /home/netconf/.ssh
173
174 USER root
175 COPY --from=builder /etc/ssh /etc/ssh
176 COPY --from=builder /root/.ssh /root/.ssh
177 COPY --from=builder /usr/local/lib /usr/local/lib
178 COPY --from=builder /usr/local/bin /usr/local/bin
179 COPY --from=builder /usr/local/include /usr/local/include
180 COPY --from=builder /usr/lib/libavl.so /usr/lib/libavl.so
181 COPY --from=builder /usr/lib/libavl.so.1 /usr/lib/libavl.so.1
182 COPY --from=builder /usr/lib/x86_64-linux-gnu/libev.so /usr/lib/x86_64-linux-gnu/libev.so
183 COPY --from=builder /usr/lib/x86_64-linux-gnu/libev.so.4 /usr/lib/x86_64-linux-gnu/libev.so.4
184 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcurl.so.4 /usr/lib/x86_64-linux-gnu/libcurl.so.4
185 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcurl.so /usr/lib/x86_64-linux-gnu/libcurl.so
186 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4
187 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson_utils.so.1 /usr/lib/x86_64-linux-gnu/libcjson_utils.so.1
188 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson_utils.so /usr/lib/x86_64-linux-gnu/libcjson_utils.so
189 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson.so.1 /usr/lib/x86_64-linux-gnu/libcjson.so.1 
190 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson.so /usr/lib/x86_64-linux-gnu/libcjson.so
191 COPY --from=builder /usr/lib/x86_64-linux-gnu/libprotobuf.so.10 /usr/lib/x86_64-linux-gnu/libprotobuf.so.10
192 COPY --from=builder /usr/lib/x86_64-linux-gnu/libprotobuf-c.so.1 /usr/lib/x86_64-linux-gnu/libprotobuf-c.so.1
193 COPY --from=builder /usr/lib/x86_64-linux-gnu/libprotobuf-c.so /usr/lib/x86_64-linux-gnu/libprotobuf-c.so
194 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh_threads.so.4 /usr/lib/x86_64-linux-gnu/libssh_threads.so.4
195 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh_threads.so /usr/lib/x86_64-linux-gnu/libssh_threads.so
196 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh.so.4 /usr/lib/x86_64-linux-gnu/libssh.so.4
197 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh.so /usr/lib/x86_64-linux-gnu/libssh.so
198 COPY --from=builder /usr/lib/x86_64-linux-gnu/libnghttp2.so.14 /usr/lib/x86_64-linux-gnu/libnghttp2.so.14
199 COPY --from=builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 /usr/lib/x86_64-linux-gnu/librtmp.so.1
200 COPY --from=builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 /usr/lib/x86_64-linux-gnu/libpsl.so.5
201 COPY --from=builder /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2
202 COPY --from=builder /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2
203 COPY --from=builder /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2
204 COPY --from=builder /usr/lib/x86_64-linux-gnu/libkrb5.so.3 /usr/lib/x86_64-linux-gnu/libkrb5.so.3
205 COPY --from=builder /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3
206 COPY --from=builder /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0
207 COPY --from=builder /usr/lib/x86_64-linux-gnu/libsasl2.so.2 /usr/lib/x86_64-linux-gnu/libsasl2.so.2
208 COPY --from=builder /usr/lib/x86_64-linux-gnu/libgssapi.so.3 /usr/lib/x86_64-linux-gnu/libgssapi.so.3
209 COPY --from=builder /usr/lib/x86_64-linux-gnu/libheimntlm.so.0 /usr/lib/x86_64-linux-gnu/libheimntlm.so.0
210 COPY --from=builder /usr/lib/x86_64-linux-gnu/libkrb5.so.26 /usr/lib/x86_64-linux-gnu/libkrb5.so.26
211 COPY --from=builder /usr/lib/x86_64-linux-gnu/libasn1.so.8 /usr/lib/x86_64-linux-gnu/libasn1.so.8
212 COPY --from=builder /usr/lib/x86_64-linux-gnu/libhcrypto.so.4 /usr/lib/x86_64-linux-gnu/libhcrypto.so.4
213 COPY --from=builder /usr/lib/x86_64-linux-gnu/libroken.so.18 /usr/lib/x86_64-linux-gnu/libroken.so.18
214 COPY --from=builder /usr/lib/x86_64-linux-gnu/libwind.so.0 /usr/lib/x86_64-linux-gnu/libwind.so.0
215 COPY --from=builder /usr/lib/x86_64-linux-gnu/libheimbase.so.1 /usr/lib/x86_64-linux-gnu/libheimbase.so.1
216 COPY --from=builder /usr/lib/x86_64-linux-gnu/libhx509.so.5 /usr/lib/x86_64-linux-gnu/libhx509.so.5
217
218 COPY --from=builder /lib/x86_64-linux-gnu/libkeyutils.so.1 /lib/x86_64-linux-gnu/libkeyutils.so.1
219 COPY --from=builder /etc/sysrepo /etc/sysrepo
220 COPY --from=builder /var/run /var/run
221
222 #COPY --from=builder /usr/local/etc/keystored/keys/ssh_host_rsa_key.pem /usr/local/etc/keystored/keys/ssh_host_rsa_key.pem
223 #COPY --from=builder /usr/local/etc/keystored/keys/ssh_host_rsa_key.pem.pub /usr/local/etc/keystored/keys/ssh_host_rsa_key.pem.pub
224 COPY --from=builder /usr/local/share/libnetconf2 /usr/local/share/libnetconf2
225
226 RUN ldconfig
227
228 COPY ./deploy/nts-manager/supervisord.conf /etc/supervisord.conf
229
230 COPY ./deploy/nts-manager/docker_stats.sh /opt/dev/docker_stats.sh
231 # Fix for the NETCONF notifications
232 RUN \
233     echo "Fixing the NETCONF notifications..." && \
234     mkdir -p /var/run/sysrepo-subscriptions/ietf-crypto-types
235           
236 ARG BUILD_DATE
237 LABEL build-date=$BUILD_DATE
238
239 ENV EDITOR vim
240 EXPOSE 830
241
242 CMD ["sh", "-c", "/usr/bin/supervisord -c /etc/supervisord.conf"]