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