b5457b55e87ce63a051a3e230554e893d34ed9d9
[sim/o1-interface.git] / ntsimulator / deploy / Dockerfile
1 FROM ubuntu:18.04
2
3 MAINTAINER alexandru.stancu@highstreet-technologies.com
4
5 LABEL maintainer="alexandru.stancu@highstreet-technologies.com"
6
7 #ARG BUILD_DATE
8
9 #LABEL build-date=$BUILD_DATE
10
11 RUN \
12       apt-get update && apt-get install -y \
13       # general tools
14       git \
15       cmake \
16       build-essential \
17       vim \
18       supervisor \
19       # libyang
20       libpcre3-dev \
21       pkg-config \
22       # sysrepo
23       libavl-dev \
24       libev-dev \
25       libprotobuf-c-dev \
26       protobuf-c-compiler \
27       # netopeer2 \
28       libssh-dev \
29       libssl-dev \
30       # bindings
31       swig \
32       python-dev \
33       libcurl4 \
34       libcurl4-openssl-dev \
35       curl \
36       bc \
37       python-setuptools \
38       python-pip
39
40 # add netconf user
41 RUN \
42       adduser --system netconf && \
43       echo "netconf:netconf" | chpasswd
44
45 # generate ssh keys for netconf user
46 RUN \
47       mkdir -p /home/netconf/.ssh && \
48       ssh-keygen -A && \
49       ssh-keygen -t dsa -P '' -f /home/netconf/.ssh/id_dsa && \
50       cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys && \
51 #echo "Host *\n    StrictHostKeyChecking accept-new" >> /home/netconf/.ssh/config
52       echo "    StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \
53       mkdir -p /root/.ssh && \
54       cat /home/netconf/.ssh/id_dsa.pub > /root/.ssh/authorized_keys
55        
56 # use /opt/dev as working directory
57 RUN mkdir /opt/dev
58 WORKDIR /opt/dev
59
60 # libcjson
61 COPY ./cJSON /opt/dev/cJSON
62 RUN \
63       cd cJSON && mkdir build && cd build && \
64       cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off -DCMAKE_INSTALL_PREFIX=/usr .. && \
65       make -j2 && \
66       make install && \
67       ldconfig
68
69 # libyang
70 COPY ./libyang /opt/dev/libyang
71 RUN \
72       cd libyang && mkdir build && cd build && \
73       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
74       make -j2 && \
75       make install && \
76       ldconfig
77
78 # sysrepo
79 COPY ./sysrepo /opt/dev/sysrepo
80 RUN \
81       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 && \
82       cd sysrepo && mkdir build && cd build && \
83       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_TESTS=OFF -DREPOSITORY_LOC:PATH=/etc/sysrepo -DREQUEST_TIMEOUT=60 -DOPER_DATA_PROVIDE_TIMEOUT=60 .. && \
84       make -j2 && \
85       make install && \
86       ldconfig
87
88 # libnetconf2
89 COPY ./libnetconf2 /opt/dev/libnetconf2
90 RUN \
91       cd libnetconf2 && mkdir build && cd build && \
92       cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
93       make -j2 && \
94       make install && \
95       ldconfig
96
97 # keystore
98 COPY ./Netopeer2 /opt/dev/Netopeer2
99 RUN \
100       cd /opt/dev && \
101       cd Netopeer2 && \
102       cd keystored && mkdir build && cd build && \
103       cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
104       make -j2 && \
105       make install && \
106       ldconfig
107
108 # overwrite number of endpoints exposed by the NETCONF server
109 COPY ./ntsimulator/scripts/stock_config.xml /opt/dev/Netopeer2/server/stock_config.xml
110 # netopeer2
111 RUN \
112       cd /opt/dev && \
113       cd Netopeer2/server && mkdir build && cd build && \
114       cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
115       make -j2 && \
116       make install && \
117       cd ../../cli && mkdir build && cd build && \
118       cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
119       make -j2 && \
120       make install
121
122 RUN pip install rstr && pip install exrex && pip install ipaddress
123           
124 COPY ./pyang /opt/dev/pyang
125 RUN \
126           cd /opt/dev && \
127           cd pyang && python setup.py build && python setup.py install
128           
129 #NTSimulator Manager - notifications
130 COPY ./ntsimulator /opt/dev/ntsimulator
131 RUN \
132       cd /opt/dev && \
133       cd ntsimulator && mkdir build  && cd build && \
134       cmake .. && \
135       make -j2&& \
136       make install
137
138 COPY ntsimulator/deploy/supervisord.conf /etc/supervisord.conf
139
140 COPY ./ntsimulator/scripts/tls /home/netconf/.ssh
141
142 COPY ./ntsimulator/yang /opt/dev/yang
143 WORKDIR /opt/dev
144 RUN \
145           cd yang && \
146           ./auto-load-yangs.sh
147           
148 ENV EDITOR vim
149 EXPOSE 830
150 EXPOSE 831
151 EXPOSE 832
152 EXPOSE 833
153 EXPOSE 834
154 EXPOSE 835
155 EXPOSE 836
156 EXPOSE 837
157 EXPOSE 838
158 EXPOSE 839
159
160 CMD ["sh", "-c", "/usr/bin/supervisord -c /etc/supervisord.conf"]