blob: 5fa04e8d3013c8d5d0975e1a43c28616c6567329 [file] [log] [blame]
Alex Stancu9f345362019-11-14 12:32:19 +02001################################################################################
2#
3# Copyright 2019 highstreet technologies GmbH and others
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16################################################################################
Alex Stancu29ce3682019-11-02 10:38:59 +020017FROM ubuntu:18.04
18
19MAINTAINER alexandru.stancu@highstreet-technologies.com
20
21LABEL maintainer="alexandru.stancu@highstreet-technologies.com"
22
23#ARG BUILD_DATE
24
25#LABEL build-date=$BUILD_DATE
26
27RUN \
28 apt-get update && apt-get install -y \
29 # general tools
30 git \
31 cmake \
32 build-essential \
33 vim \
34 supervisor \
35 # libyang
36 libpcre3-dev \
37 pkg-config \
38 # sysrepo
39 libavl-dev \
40 libev-dev \
41 libprotobuf-c-dev \
42 protobuf-c-compiler \
43 # netopeer2 \
44 libssh-dev \
45 libssl-dev \
46 # bindings
47 swig \
48 python-dev \
49 libcurl4 \
50 libcurl4-openssl-dev \
51 curl \
52 bc \
53 python-setuptools \
54 python-pip
55
56# add netconf user
57RUN \
58 adduser --system netconf && \
59 echo "netconf:netconf" | chpasswd
60
61# generate ssh keys for netconf user
62RUN \
63 mkdir -p /home/netconf/.ssh && \
64 ssh-keygen -A && \
65 ssh-keygen -t dsa -P '' -f /home/netconf/.ssh/id_dsa && \
66 cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys && \
67#echo "Host *\n StrictHostKeyChecking accept-new" >> /home/netconf/.ssh/config
68 echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \
69 mkdir -p /root/.ssh && \
70 cat /home/netconf/.ssh/id_dsa.pub > /root/.ssh/authorized_keys
71
72# use /opt/dev as working directory
73RUN mkdir /opt/dev
74WORKDIR /opt/dev
75
76# libcjson
Alex Stancu29ce3682019-11-02 10:38:59 +020077RUN \
Alex Stancu0f820402019-11-13 18:07:45 +020078 git clone https://github.com/Melacon/cJSON.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +020079 cd cJSON && mkdir build && cd build && \
80 cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off -DCMAKE_INSTALL_PREFIX=/usr .. && \
81 make -j2 && \
82 make install && \
83 ldconfig
84
85# libyang
Alex Stancu29ce3682019-11-02 10:38:59 +020086RUN \
Alex Stancu0f820402019-11-13 18:07:45 +020087 git clone https://github.com/Melacon/libyang.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +020088 cd libyang && mkdir build && cd build && \
89 cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
90 make -j2 && \
91 make install && \
92 ldconfig
93
94# sysrepo
Alex Stancu29ce3682019-11-02 10:38:59 +020095RUN \
Alex Stancu0f820402019-11-13 18:07:45 +020096 git clone https://github.com/Melacon/sysrepo.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +020097 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 && \
98 cd sysrepo && mkdir build && cd build && \
99 cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_TESTS=OFF -DREPOSITORY_LOC:PATH=/etc/sysrepo -DREQUEST_TIMEOUT=60 -DOPER_DATA_PROVIDE_TIMEOUT=60 .. && \
100 make -j2 && \
101 make install && \
102 ldconfig
103
104# libnetconf2
Alex Stancu29ce3682019-11-02 10:38:59 +0200105RUN \
Alex Stancu0f820402019-11-13 18:07:45 +0200106 git clone https://github.com/Melacon/libnetconf2.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +0200107 cd libnetconf2 && mkdir build && cd build && \
108 cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
109 make -j2 && \
110 make install && \
111 ldconfig
112
113# keystore
Alex Stancu29ce3682019-11-02 10:38:59 +0200114RUN \
Alex Stancu0f820402019-11-13 18:07:45 +0200115 cd /opt/dev && \
116 git clone https://github.com/Melacon/Netopeer2.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +0200117 cd Netopeer2 && \
118 cd keystored && mkdir build && cd build && \
119 cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
120 make -j2 && \
121 make install && \
122 ldconfig
123
124# overwrite number of endpoints exposed by the NETCONF server
Alex Stancue37e7a52019-11-15 19:04:55 +0200125COPY ./scripts/stock_config.xml /opt/dev/Netopeer2/server/stock_config.xml
Alex Stancu29ce3682019-11-02 10:38:59 +0200126# netopeer2
127RUN \
128 cd /opt/dev && \
129 cd Netopeer2/server && mkdir build && cd build && \
130 cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
131 make -j2 && \
132 make install && \
133 cd ../../cli && mkdir build && cd build && \
134 cmake -DCMAKE_BUILD_TYPE:String="Release" .. && \
135 make -j2 && \
136 make install
137
138RUN pip install rstr && pip install exrex && pip install ipaddress
Alex Stancu0f820402019-11-13 18:07:45 +0200139
140# pyang
Alex Stancu29ce3682019-11-02 10:38:59 +0200141RUN \
142 cd /opt/dev && \
Alex Stancu0f820402019-11-13 18:07:45 +0200143 git clone https://github.com/Melacon/pyang.git && \
Alex Stancu29ce3682019-11-02 10:38:59 +0200144 cd pyang && python setup.py build && python setup.py install
145
146#NTSimulator Manager - notifications
Alex Stancua349a452019-11-15 18:48:59 +0200147COPY . /opt/dev/ntsimulator
Alex Stancu29ce3682019-11-02 10:38:59 +0200148RUN \
149 cd /opt/dev && \
150 cd ntsimulator && mkdir build && cd build && \
151 cmake .. && \
152 make -j2&& \
153 make install
154
Alex Stancua349a452019-11-15 18:48:59 +0200155COPY deploy/supervisord.conf /etc/supervisord.conf
Alex Stancu29ce3682019-11-02 10:38:59 +0200156
Alex Stancua349a452019-11-15 18:48:59 +0200157COPY ./scripts/tls /home/netconf/.ssh
Alex Stancu29ce3682019-11-02 10:38:59 +0200158
Alex Stancua349a452019-11-15 18:48:59 +0200159COPY ./yang /opt/dev/yang
Alex Stancu29ce3682019-11-02 10:38:59 +0200160WORKDIR /opt/dev
161RUN \
162 cd yang && \
163 ./auto-load-yangs.sh
164
165ENV EDITOR vim
166EXPOSE 830
167EXPOSE 831
168EXPOSE 832
169EXPOSE 833
170EXPOSE 834
171EXPOSE 835
172EXPOSE 836
173EXPOSE 837
174EXPOSE 838
175EXPOSE 839
176
177CMD ["sh", "-c", "/usr/bin/supervisord -c /etc/supervisord.conf"]