blob: f1234f291381da34e282fd13d8169682c3e10b1f [file] [log] [blame]
Alex Stancu29ce3682019-11-02 10:38:59 +02001FROM ubuntu:18.04
2
3MAINTAINER alexandru.stancu@highstreet-technologies.com
4
5LABEL maintainer="alexandru.stancu@highstreet-technologies.com"
6
7#ARG BUILD_DATE
8
9#LABEL build-date=$BUILD_DATE
10
11RUN \
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
41RUN \
42 adduser --system netconf && \
43 echo "netconf:netconf" | chpasswd
44
45# generate ssh keys for netconf user
46RUN \
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
57RUN mkdir /opt/dev
58WORKDIR /opt/dev
59
60# libcjson
Alex Stancu29ce3682019-11-02 10:38:59 +020061RUN \
Alex Stancu0f820402019-11-13 18:07:45 +020062 git clone https://github.com/Melacon/cJSON.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +020063 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
Alex Stancu29ce3682019-11-02 10:38:59 +020070RUN \
Alex Stancu0f820402019-11-13 18:07:45 +020071 git clone https://github.com/Melacon/libyang.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +020072 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
Alex Stancu29ce3682019-11-02 10:38:59 +020079RUN \
Alex Stancu0f820402019-11-13 18:07:45 +020080 git clone https://github.com/Melacon/sysrepo.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +020081 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
Alex Stancu29ce3682019-11-02 10:38:59 +020089RUN \
Alex Stancu0f820402019-11-13 18:07:45 +020090 git clone https://github.com/Melacon/libnetconf2.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +020091 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
Alex Stancu29ce3682019-11-02 10:38:59 +020098RUN \
Alex Stancu0f820402019-11-13 18:07:45 +020099 cd /opt/dev && \
100 git clone https://github.com/Melacon/Netopeer2.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +0200101 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
109COPY ./ntsimulator/scripts/stock_config.xml /opt/dev/Netopeer2/server/stock_config.xml
110# netopeer2
111RUN \
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
122RUN pip install rstr && pip install exrex && pip install ipaddress
Alex Stancu0f820402019-11-13 18:07:45 +0200123
124# pyang
Alex Stancu29ce3682019-11-02 10:38:59 +0200125RUN \
126 cd /opt/dev && \
Alex Stancu0f820402019-11-13 18:07:45 +0200127 git clone https://github.com/Melacon/pyang.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +0200128 cd pyang && python setup.py build && python setup.py install
129
130#NTSimulator Manager - notifications
131COPY ./ntsimulator /opt/dev/ntsimulator
132RUN \
133 cd /opt/dev && \
134 cd ntsimulator && mkdir build && cd build && \
135 cmake .. && \
136 make -j2&& \
137 make install
138
139COPY ntsimulator/deploy/supervisord.conf /etc/supervisord.conf
140
141COPY ./ntsimulator/scripts/tls /home/netconf/.ssh
142
143COPY ./ntsimulator/yang /opt/dev/yang
144WORKDIR /opt/dev
145RUN \
146 cd yang && \
147 ./auto-load-yangs.sh
148
149ENV EDITOR vim
150EXPOSE 830
151EXPOSE 831
152EXPOSE 832
153EXPOSE 833
154EXPOSE 834
155EXPOSE 835
156EXPOSE 836
157EXPOSE 837
158EXPOSE 838
159EXPOSE 839
160
161CMD ["sh", "-c", "/usr/bin/supervisord -c /etc/supervisord.conf"]