Refactor folder structure.
[sim/o1-interface.git] / ntsimulator / deploy / o-ran / ru-fh / 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
32 RUN \
33       apt-get install -y \
34       python-setuptools \
35       python-pip
36
37 # pyang dependencies
38 RUN pip install rstr && \
39     pip install exrex && \
40     pip install ipaddress && \
41     pip install lxml
42
43 # add netconf user
44 RUN \
45       adduser --system netconf && \
46       echo "netconf:netconf" | chpasswd
47
48 # generate ssh keys for netconf user
49 RUN \
50       mkdir -p /home/netconf/.ssh && \
51       ssh-keygen -A && \
52       ssh-keygen -t dsa -P '' -f /home/netconf/.ssh/id_dsa && \
53       cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys && \
54 #echo "Host *\n    StrictHostKeyChecking accept-new" >> /home/netconf/.ssh/config
55       echo "    StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \
56       mkdir -p /root/.ssh && \
57       cat /home/netconf/.ssh/id_dsa.pub > /root/.ssh/authorized_keys
58        
59 # use /opt/dev as working directory
60 RUN mkdir /opt/dev
61 WORKDIR /opt/dev
62
63 # libcjson
64 RUN \
65       git clone https://github.com/Melacon/cJSON.git && \
66       cd cJSON && mkdir build && cd build && \
67       cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off -DCMAKE_INSTALL_PREFIX=/usr .. && \
68       make -j2 && \
69       make install && \
70       ldconfig
71
72 # libyang
73 RUN \
74       git clone https://github.com/Melacon/libyang.git && \
75       cd libyang && mkdir build && cd build && \
76       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
77       make -j2 && \
78       make install && \
79       ldconfig
80
81 # sysrepo
82 RUN \
83       git clone https://github.com/Melacon/sysrepo.git && \
84       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 && \
85       cd sysrepo && mkdir build && cd build && \
86       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_TESTS=OFF -DREPOSITORY_LOC:PATH=/etc/sysrepo -DREQUEST_TIMEOUT=60 -DOPER_DATA_PROVIDE_TIMEOUT=60 .. && \
87       make -j2 && \
88       make install && \
89       ldconfig
90
91 # libnetconf2
92 RUN \
93       git clone https://github.com/Melacon/libnetconf2.git && \
94       cd libnetconf2 && mkdir build && cd build && \
95       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
96       make -j2 && \
97       make install && \
98       ldconfig
99
100 # keystore
101 RUN \
102       git clone https://github.com/Melacon/Netopeer2.git && \
103       cd Netopeer2 && \
104       cd keystored && mkdir build && cd build && \
105       cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
106       make -j2 && \
107       make install && \
108       ldconfig
109
110 # overwrite number of endpoints exposed by the NETCONF server
111 COPY ./deploy/o-ran/ru-fh/stock_config.xml /opt/dev/Netopeer2/server/stock_config.xml
112 # netopeer2
113 RUN \
114       cd /opt/dev/Netopeer2/server && mkdir build && cd build && \
115       cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
116       make -j2 && \
117       make install && \
118       cd ../../cli && mkdir build && cd build && \
119       cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
120       make -j2 && \
121       make install
122
123 # pyang
124 RUN \
125       git clone https://github.com/Melacon/pyang.git && \
126         cd pyang && python setup.py build && python setup.py install
127
128 # NTSimulator device
129 COPY . /opt/dev/ntsimulator
130 COPY ./deploy/o-ran/ru-fh/CMakeLists.txt /opt/dev/ntsimulator/src/CMakeLists.txt
131 RUN \
132       cd /opt/dev/ntsimulator && mkdir build  && cd build && \
133       cmake .. && \
134       make -j2 && \
135       make install
136
137 # Second stage
138 FROM ubuntu:18.04  
139
140 LABEL maintainer="alexandru.stancu@highstreet-technologies.com"
141
142 RUN \
143       apt-get update && apt-get install -y supervisor
144
145 # add netconf user
146 RUN \
147       adduser --system netconf && \
148       echo "netconf:netconf" | chpasswd
149
150 # generate ssh keys for netconf user
151 RUN \
152       mkdir -p /home/netconf/.ssh
153
154 COPY --from=builder /home/netconf/.ssh /home/netconf/.ssh
155 COPY --from=builder /usr/local/lib /usr/local/lib
156 COPY --from=builder /usr/local/bin /usr/local/bin
157 COPY --from=builder /usr/local/include /usr/local/include
158 COPY --from=builder /usr/lib/libavl.so /usr/lib/libavl.so
159 COPY --from=builder /usr/lib/libavl.so.1 /usr/lib/libavl.so.1
160 COPY --from=builder /usr/lib/x86_64-linux-gnu/libev.so /usr/lib/x86_64-linux-gnu/libev.so
161 COPY --from=builder /usr/lib/x86_64-linux-gnu/libev.so.4 /usr/lib/x86_64-linux-gnu/libev.so.4
162 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcurl.so.4 /usr/lib/x86_64-linux-gnu/libcurl.so.4
163 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcurl.so /usr/lib/x86_64-linux-gnu/libcurl.so
164 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4
165 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson_utils.so.1 /usr/lib/x86_64-linux-gnu/libcjson_utils.so.1
166 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson_utils.so /usr/lib/x86_64-linux-gnu/libcjson_utils.so
167 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson.so.1 /usr/lib/x86_64-linux-gnu/libcjson.so.1 
168 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson.so /usr/lib/x86_64-linux-gnu/libcjson.so
169 COPY --from=builder /usr/lib/x86_64-linux-gnu/libprotobuf.so.10 /usr/lib/x86_64-linux-gnu/libprotobuf.so.10
170 COPY --from=builder /usr/lib/x86_64-linux-gnu/libprotobuf-c.so.1 /usr/lib/x86_64-linux-gnu/libprotobuf-c.so.1
171 COPY --from=builder /usr/lib/x86_64-linux-gnu/libprotobuf-c.so /usr/lib/x86_64-linux-gnu/libprotobuf-c.so
172 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh_threads.so.4 /usr/lib/x86_64-linux-gnu/libssh_threads.so.4
173 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh_threads.so /usr/lib/x86_64-linux-gnu/libssh_threads.so
174 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh.so.4 /usr/lib/x86_64-linux-gnu/libssh.so.4
175 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh.so /usr/lib/x86_64-linux-gnu/libssh.so
176 COPY --from=builder /usr/lib/x86_64-linux-gnu/libnghttp2.so.14 /usr/lib/x86_64-linux-gnu/libnghttp2.so.14
177 COPY --from=builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 /usr/lib/x86_64-linux-gnu/librtmp.so.1
178 COPY --from=builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 /usr/lib/x86_64-linux-gnu/libpsl.so.5
179 COPY --from=builder /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2
180 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
181 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
182 COPY --from=builder /usr/lib/x86_64-linux-gnu/libkrb5.so.3 /usr/lib/x86_64-linux-gnu/libkrb5.so.3
183 COPY --from=builder /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3
184 COPY --from=builder /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0
185 COPY --from=builder /usr/lib/x86_64-linux-gnu/libsasl2.so.2 /usr/lib/x86_64-linux-gnu/libsasl2.so.2
186 COPY --from=builder /usr/lib/x86_64-linux-gnu/libgssapi.so.3 /usr/lib/x86_64-linux-gnu/libgssapi.so.3
187 COPY --from=builder /usr/lib/x86_64-linux-gnu/libheimntlm.so.0 /usr/lib/x86_64-linux-gnu/libheimntlm.so.0
188 COPY --from=builder /usr/lib/x86_64-linux-gnu/libkrb5.so.26 /usr/lib/x86_64-linux-gnu/libkrb5.so.26
189 COPY --from=builder /usr/lib/x86_64-linux-gnu/libasn1.so.8 /usr/lib/x86_64-linux-gnu/libasn1.so.8
190 COPY --from=builder /usr/lib/x86_64-linux-gnu/libhcrypto.so.4 /usr/lib/x86_64-linux-gnu/libhcrypto.so.4
191 COPY --from=builder /usr/lib/x86_64-linux-gnu/libroken.so.18 /usr/lib/x86_64-linux-gnu/libroken.so.18
192 COPY --from=builder /usr/lib/x86_64-linux-gnu/libwind.so.0 /usr/lib/x86_64-linux-gnu/libwind.so.0
193 COPY --from=builder /usr/lib/x86_64-linux-gnu/libheimbase.so.1 /usr/lib/x86_64-linux-gnu/libheimbase.so.1
194 COPY --from=builder /usr/lib/x86_64-linux-gnu/libhx509.so.5 /usr/lib/x86_64-linux-gnu/libhx509.so.5
195
196 COPY --from=builder /lib/x86_64-linux-gnu/libkeyutils.so.1 /lib/x86_64-linux-gnu/libkeyutils.so.1
197 COPY --from=builder /etc/sysrepo /etc/sysrepo
198 COPY --from=builder /var/run /var/run
199
200 COPY --from=builder /usr/local/etc/keystored/keys/ssh_host_rsa_key.pem /usr/local/etc/keystored/keys/ssh_host_rsa_key.pem
201 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
202 COPY --from=builder /usr/local/share/libnetconf2 /usr/local/share/libnetconf2
203
204 RUN ldconfig
205
206 WORKDIR /tmp
207 RUN apt-get install -yqq wget \
208     openssh-client
209
210 RUN mkdir py_install && cd py_install && \
211     wget https://files.pythonhosted.org/packages/b9/9a/3e9da40ea28b8210dd6504d3fe9fe7e013b62bf45902b458d1cdc3c34ed9/ipaddress-1.0.23.tar.gz && \
212     tar -xvzf ipaddress-1.0.23.tar.gz && cd ipaddress-1.0.23 && \
213     python setup.py install
214
215 COPY --from=builder /etc/ssh /etc/ssh
216 COPY --from=builder /root/.ssh /root/.ssh
217
218 WORKDIR /opt/dev
219 # run only specific programs in this image
220 COPY ./deploy/o-ran/ru-fh/supervisord.conf /etc/supervisord.conf
221
222 # tls configuratoin
223 COPY ./deploy/tls /home/netconf/.ssh
224
225 COPY --from=builder /opt/dev/sysrepo/build/examples/application_example /opt/dev/sysrepo/build/examples/application_example
226
227 # YANG models and related scripts
228 COPY ./yang/o-ran/ru-fh /opt/dev/yang
229 COPY ./yang/auto-load-yangs.sh /opt/dev/yang
230 COPY ./yang/sysrepo-configuration-load.sh /opt/dev/yang
231
232 # scripts for Software Management RPCs
233 COPY ./deploy/o-ran/ru-fh/edit-config-after-activate.sh /opt/dev
234 COPY ./deploy/o-ran/ru-fh/edit-config-after-activate.xml /opt/dev
235 COPY ./deploy/o-ran/ru-fh/edit-config-after-download.sh /opt/dev
236 COPY ./deploy/o-ran/ru-fh/edit-config-after-download.xml /opt/dev
237 COPY ./deploy/o-ran/ru-fh/edit-config-demo-start.sh /opt/dev
238 COPY ./deploy/o-ran/ru-fh/edit-config-demo-start.xml /opt/dev
239
240 WORKDIR /opt/dev
241 RUN \
242           cd yang && \
243           ./auto-load-yangs.sh
244
245 ARG BUILD_DATE
246 LABEL build-date=$BUILD_DATE
247           
248 ENV EDITOR vim
249 EXPOSE 830-839
250
251 CMD ["sh", "-c", "/usr/bin/supervisord -c /etc/supervisord.conf"]