Alex Stancu | 9f34536 | 2019-11-14 12:32:19 +0200 | [diff] [blame] | 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 | ################################################################################ |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 17 | FROM ubuntu:18.04 |
| 18 | |
| 19 | MAINTAINER alexandru.stancu@highstreet-technologies.com |
| 20 | |
| 21 | LABEL maintainer="alexandru.stancu@highstreet-technologies.com" |
| 22 | |
| 23 | #ARG BUILD_DATE |
| 24 | |
| 25 | #LABEL build-date=$BUILD_DATE |
| 26 | |
| 27 | RUN \ |
| 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 |
| 57 | RUN \ |
| 58 | adduser --system netconf && \ |
| 59 | echo "netconf:netconf" | chpasswd |
| 60 | |
| 61 | # generate ssh keys for netconf user |
| 62 | RUN \ |
| 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 |
| 73 | RUN mkdir /opt/dev |
| 74 | WORKDIR /opt/dev |
| 75 | |
| 76 | # libcjson |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 77 | RUN \ |
Alex Stancu | 0f82040 | 2019-11-13 18:07:45 +0200 | [diff] [blame] | 78 | git clone https://github.com/Melacon/cJSON.git && \ |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 79 | 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 Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 86 | RUN \ |
Alex Stancu | 0f82040 | 2019-11-13 18:07:45 +0200 | [diff] [blame] | 87 | git clone https://github.com/Melacon/libyang.git && \ |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 88 | 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 Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 95 | RUN \ |
Alex Stancu | 0f82040 | 2019-11-13 18:07:45 +0200 | [diff] [blame] | 96 | git clone https://github.com/Melacon/sysrepo.git && \ |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 97 | 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 Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 105 | RUN \ |
Alex Stancu | 0f82040 | 2019-11-13 18:07:45 +0200 | [diff] [blame] | 106 | git clone https://github.com/Melacon/libnetconf2.git && \ |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 107 | 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 Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 114 | RUN \ |
Alex Stancu | 0f82040 | 2019-11-13 18:07:45 +0200 | [diff] [blame] | 115 | cd /opt/dev && \ |
| 116 | git clone https://github.com/Melacon/Netopeer2.git && \ |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 117 | 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 Stancu | e37e7a5 | 2019-11-15 19:04:55 +0200 | [diff] [blame^] | 125 | COPY ./scripts/stock_config.xml /opt/dev/Netopeer2/server/stock_config.xml |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 126 | # netopeer2 |
| 127 | RUN \ |
| 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 | |
| 138 | RUN pip install rstr && pip install exrex && pip install ipaddress |
Alex Stancu | 0f82040 | 2019-11-13 18:07:45 +0200 | [diff] [blame] | 139 | |
| 140 | # pyang |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 141 | RUN \ |
| 142 | cd /opt/dev && \ |
Alex Stancu | 0f82040 | 2019-11-13 18:07:45 +0200 | [diff] [blame] | 143 | git clone https://github.com/Melacon/pyang.git && \ |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 144 | cd pyang && python setup.py build && python setup.py install |
| 145 | |
| 146 | #NTSimulator Manager - notifications |
Alex Stancu | a349a45 | 2019-11-15 18:48:59 +0200 | [diff] [blame] | 147 | COPY . /opt/dev/ntsimulator |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 148 | RUN \ |
| 149 | cd /opt/dev && \ |
| 150 | cd ntsimulator && mkdir build && cd build && \ |
| 151 | cmake .. && \ |
| 152 | make -j2&& \ |
| 153 | make install |
| 154 | |
Alex Stancu | a349a45 | 2019-11-15 18:48:59 +0200 | [diff] [blame] | 155 | COPY deploy/supervisord.conf /etc/supervisord.conf |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 156 | |
Alex Stancu | a349a45 | 2019-11-15 18:48:59 +0200 | [diff] [blame] | 157 | COPY ./scripts/tls /home/netconf/.ssh |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 158 | |
Alex Stancu | a349a45 | 2019-11-15 18:48:59 +0200 | [diff] [blame] | 159 | COPY ./yang /opt/dev/yang |
Alex Stancu | 29ce368 | 2019-11-02 10:38:59 +0200 | [diff] [blame] | 160 | WORKDIR /opt/dev |
| 161 | RUN \ |
| 162 | cd yang && \ |
| 163 | ./auto-load-yangs.sh |
| 164 | |
| 165 | ENV EDITOR vim |
| 166 | EXPOSE 830 |
| 167 | EXPOSE 831 |
| 168 | EXPOSE 832 |
| 169 | EXPOSE 833 |
| 170 | EXPOSE 834 |
| 171 | EXPOSE 835 |
| 172 | EXPOSE 836 |
| 173 | EXPOSE 837 |
| 174 | EXPOSE 838 |
| 175 | EXPOSE 839 |
| 176 | |
| 177 | CMD ["sh", "-c", "/usr/bin/supervisord -c /etc/supervisord.conf"] |