ff4c0082c2f352daa6f017d74063d0cc6c749f9b
[sim/o1-interface.git] / ntsimulator / deploy / o-ran-sc / o-ran-ru / 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 # netopeer2
111 RUN \
112       cd /opt/dev/Netopeer2/server && mkdir build && cd build && \
113       cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
114       make -j2 && \
115       make install && \
116       cd ../../cli && mkdir build && cd build && \
117       cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
118       make -j2 && \
119       make install
120
121 # pyang
122 RUN \
123       git clone https://github.com/Melacon/pyang.git && \
124         cd pyang && python setup.py build && python setup.py install
125
126 # NTSimulator device
127 COPY . /opt/dev/ntsimulator
128 COPY ./deploy/o-ran-sc/o-ran-ru/CMakeLists.txt /opt/dev/ntsimulator/src/CMakeLists.txt
129 RUN \
130       cd /opt/dev/ntsimulator && mkdir build  && cd build && \
131       cmake .. && \
132       make -j2 && \
133       make install
134
135 # Second stage
136 FROM ubuntu:18.04  
137
138 LABEL maintainer="alexandru.stancu@highstreet-technologies.com"
139
140 RUN \
141       apt-get update && apt-get install -y supervisor
142
143 # add netconf user
144 RUN \
145       adduser --system netconf && \
146       echo "netconf:netconf" | chpasswd
147
148 # generate ssh keys for netconf user
149 RUN \
150       mkdir -p /home/netconf/.ssh
151
152 COPY --from=builder /home/netconf/.ssh /home/netconf/.ssh
153 COPY --from=builder /usr/local/lib /usr/local/lib
154 COPY --from=builder /usr/local/bin /usr/local/bin
155 COPY --from=builder /usr/local/include /usr/local/include
156 COPY --from=builder /usr/lib/libavl.so /usr/lib/libavl.so
157 COPY --from=builder /usr/lib/libavl.so.1 /usr/lib/libavl.so.1
158 COPY --from=builder /usr/lib/x86_64-linux-gnu/libev.so /usr/lib/x86_64-linux-gnu/libev.so
159 COPY --from=builder /usr/lib/x86_64-linux-gnu/libev.so.4 /usr/lib/x86_64-linux-gnu/libev.so.4
160 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcurl.so.4 /usr/lib/x86_64-linux-gnu/libcurl.so.4
161 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcurl.so /usr/lib/x86_64-linux-gnu/libcurl.so
162 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4
163 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson_utils.so.1 /usr/lib/x86_64-linux-gnu/libcjson_utils.so.1
164 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson_utils.so /usr/lib/x86_64-linux-gnu/libcjson_utils.so
165 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson.so.1 /usr/lib/x86_64-linux-gnu/libcjson.so.1 
166 COPY --from=builder /usr/lib/x86_64-linux-gnu/libcjson.so /usr/lib/x86_64-linux-gnu/libcjson.so
167 COPY --from=builder /usr/lib/x86_64-linux-gnu/libprotobuf.so.10 /usr/lib/x86_64-linux-gnu/libprotobuf.so.10
168 COPY --from=builder /usr/lib/x86_64-linux-gnu/libprotobuf-c.so.1 /usr/lib/x86_64-linux-gnu/libprotobuf-c.so.1
169 COPY --from=builder /usr/lib/x86_64-linux-gnu/libprotobuf-c.so /usr/lib/x86_64-linux-gnu/libprotobuf-c.so
170 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh_threads.so.4 /usr/lib/x86_64-linux-gnu/libssh_threads.so.4
171 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh_threads.so /usr/lib/x86_64-linux-gnu/libssh_threads.so
172 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh.so.4 /usr/lib/x86_64-linux-gnu/libssh.so.4
173 COPY --from=builder /usr/lib/x86_64-linux-gnu/libssh.so /usr/lib/x86_64-linux-gnu/libssh.so
174 COPY --from=builder /usr/lib/x86_64-linux-gnu/libnghttp2.so.14 /usr/lib/x86_64-linux-gnu/libnghttp2.so.14
175 COPY --from=builder /usr/lib/x86_64-linux-gnu/librtmp.so.1 /usr/lib/x86_64-linux-gnu/librtmp.so.1
176 COPY --from=builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 /usr/lib/x86_64-linux-gnu/libpsl.so.5
177 COPY --from=builder /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2
178 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
179 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
180 COPY --from=builder /usr/lib/x86_64-linux-gnu/libkrb5.so.3 /usr/lib/x86_64-linux-gnu/libkrb5.so.3
181 COPY --from=builder /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3
182 COPY --from=builder /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0
183 COPY --from=builder /usr/lib/x86_64-linux-gnu/libsasl2.so.2 /usr/lib/x86_64-linux-gnu/libsasl2.so.2
184 COPY --from=builder /usr/lib/x86_64-linux-gnu/libgssapi.so.3 /usr/lib/x86_64-linux-gnu/libgssapi.so.3
185 COPY --from=builder /usr/lib/x86_64-linux-gnu/libheimntlm.so.0 /usr/lib/x86_64-linux-gnu/libheimntlm.so.0
186 COPY --from=builder /usr/lib/x86_64-linux-gnu/libkrb5.so.26 /usr/lib/x86_64-linux-gnu/libkrb5.so.26
187 COPY --from=builder /usr/lib/x86_64-linux-gnu/libasn1.so.8 /usr/lib/x86_64-linux-gnu/libasn1.so.8
188 COPY --from=builder /usr/lib/x86_64-linux-gnu/libhcrypto.so.4 /usr/lib/x86_64-linux-gnu/libhcrypto.so.4
189 COPY --from=builder /usr/lib/x86_64-linux-gnu/libroken.so.18 /usr/lib/x86_64-linux-gnu/libroken.so.18
190 COPY --from=builder /usr/lib/x86_64-linux-gnu/libwind.so.0 /usr/lib/x86_64-linux-gnu/libwind.so.0
191 COPY --from=builder /usr/lib/x86_64-linux-gnu/libheimbase.so.1 /usr/lib/x86_64-linux-gnu/libheimbase.so.1
192 COPY --from=builder /usr/lib/x86_64-linux-gnu/libhx509.so.5 /usr/lib/x86_64-linux-gnu/libhx509.so.5
193
194 COPY --from=builder /lib/x86_64-linux-gnu/libkeyutils.so.1 /lib/x86_64-linux-gnu/libkeyutils.so.1
195 COPY --from=builder /etc/sysrepo /etc/sysrepo
196 COPY --from=builder /var/run /var/run
197
198 COPY --from=builder /usr/local/etc/keystored/keys/ssh_host_rsa_key.pem /usr/local/etc/keystored/keys/ssh_host_rsa_key.pem
199 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
200 COPY --from=builder /usr/local/share/libnetconf2 /usr/local/share/libnetconf2
201
202 RUN ldconfig
203
204 WORKDIR /tmp
205 RUN apt-get install -yqq wget \
206     openssh-client \
207     jq
208
209 RUN mkdir py_install && cd py_install && \
210     wget https://files.pythonhosted.org/packages/b9/9a/3e9da40ea28b8210dd6504d3fe9fe7e013b62bf45902b458d1cdc3c34ed9/ipaddress-1.0.23.tar.gz && \
211     tar -xvzf ipaddress-1.0.23.tar.gz && cd ipaddress-1.0.23 && \
212     python setup.py install
213
214 COPY --from=builder /etc/ssh /etc/ssh
215 COPY --from=builder /root/.ssh /root/.ssh
216
217 WORKDIR /opt/dev
218 # run only specific programs in this image
219 COPY ./deploy/o-ran-sc/o-ran-ru/supervisord.conf /etc/supervisord.conf
220
221 # tls configuratoin
222 COPY ./deploy/tls /home/netconf/.ssh
223
224 COPY --from=builder /opt/dev/sysrepo/build/examples/application_example /opt/dev/sysrepo/build/examples/application_example
225
226 # YANG models and related scripts
227 COPY ./yang/o-ran-sc/o-ran-ru /opt/dev/yang
228 COPY ./yang/auto-load-yangs.sh /opt/dev/yang
229 COPY ./deploy/o-ran-sc/o-ran-ru/sysrepo-configuration-load.sh /opt/dev/yang
230 WORKDIR /opt/dev
231 RUN \
232           cd yang && \
233           ./auto-load-yangs.sh
234
235 ARG BUILD_DATE
236 LABEL build-date=$BUILD_DATE
237           
238 ENV EDITOR vim
239 EXPOSE 830-929
240
241 CMD ["sh", "-c", "/usr/bin/supervisord -c /etc/supervisord.conf"]