Remove external dependencies. Add them into Dockerfile.
[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 RUN \
62           git clone https://github.com/Melacon/cJSON.git && \
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 RUN \
71           git clone https://github.com/Melacon/libyang.git && \
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 RUN \
80           git clone https://github.com/Melacon/sysrepo.git && \
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 RUN \
90           git clone https://github.com/Melacon/libnetconf2.git && \
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 RUN \
99           cd /opt/dev && \
100           git clone https://github.com/Melacon/Netopeer2.git && \
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 # pyang 
125 RUN \
126           cd /opt/dev && \
127           git clone https://github.com/Melacon/pyang.git && \
128           cd pyang && python setup.py build && python setup.py install
129           
130 #NTSimulator Manager - notifications
131 COPY ./ntsimulator /opt/dev/ntsimulator
132 RUN \
133       cd /opt/dev && \
134       cd ntsimulator && mkdir build  && cd build && \
135       cmake .. && \
136       make -j2&& \
137       make install
138
139 COPY ntsimulator/deploy/supervisord.conf /etc/supervisord.conf
140
141 COPY ./ntsimulator/scripts/tls /home/netconf/.ssh
142
143 COPY ./ntsimulator/yang /opt/dev/yang
144 WORKDIR /opt/dev
145 RUN \
146           cd yang && \
147           ./auto-load-yangs.sh
148           
149 ENV EDITOR vim
150 EXPOSE 830
151 EXPOSE 831
152 EXPOSE 832
153 EXPOSE 833
154 EXPOSE 834
155 EXPOSE 835
156 EXPOSE 836
157 EXPOSE 837
158 EXPOSE 838
159 EXPOSE 839
160
161 CMD ["sh", "-c", "/usr/bin/supervisord -c /etc/supervisord.conf"]