2 # Copyright 2020 highstreet technologies GmbH and others
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
20 FROM ubuntu:20.04 as builder
21 LABEL maintainer="alexandru.stancu@highstreet-technologies.com / adrian.lita@highstreet-technologies.com"
23 RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y \
25 tzdata build-essential git cmake pkg-config supervisor \
26 # libyang dependencies
31 # add netconf user and configure access
33 adduser --system netconf && \
34 echo "netconf:netconf" | chpasswd
36 # use /opt/dev as working directory
40 # get required build libs from git
42 git config --global advice.detachedHead false && \
43 git clone --single-branch --branch v1.7.13 https://github.com/DaveGamble/cJSON.git && \
44 git clone --single-branch --branch v1.0.184 https://github.com/CESNET/libyang.git && \
45 git clone --single-branch --branch v1.4.70 https://github.com/sysrepo/sysrepo.git && \
46 git clone --single-branch --branch libssh-0.9.2 https://git.libssh.org/projects/libssh.git && \
47 git clone --single-branch --branch v1.1.26 https://github.com/CESNET/libnetconf2.git && \
48 git clone --single-branch --branch v1.1.39 https://github.com/CESNET/netopeer2.git && \
49 git clone --single-branch --branch curl-7_72_0 https://github.com/curl/curl.git
51 # build and install cJSON
54 mkdir build && cd build && \
55 cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off && \
60 # build and install libyang
63 mkdir build && cd build && \
64 cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
69 # build and install sysrepo
72 mkdir build && cd build && \
73 cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_TESTS=OFF -DREPOSITORY_LOC:PATH=/etc/sysrepo -DREQUEST_TIMEOUT=60 -DOPER_DATA_PROVIDE_TIMEOUT=60 .. && \
78 # build and install libssh-dev
81 mkdir build && cd build && \
82 cmake -DWITH_EXAMPLES=OFF .. && \
88 # build and install libnetconf2
91 mkdir build && cd build && \
92 cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
97 # build and install netopeer2
100 mkdir build && cd build && \
101 cmake -DCMAKE_BUILD_TYPE:String="Release" -DGENERATE_HOSTKEY=OFF -DMERGE_LISTEN_CONFIG=OFF .. && \
105 # build and install cURL
108 mkdir build && cd build && \
109 cmake -DBUILD_TESTING=OFF .. && \
114 # regxstring copy, build and install
115 RUN mkdir /opt/dev/regxstring
116 COPY ./regxstring /opt/dev/regxstring
117 COPY ./deploy/base/build_regxstring.sh /opt/dev/regxstring/build_regxstring.sh
119 cd /opt/dev/regxstring && \
120 ./build_regxstring.sh && \
121 cp regxstring /usr/bin && \
124 # ntsim-ng copy and build
126 mkdir /opt/dev/ntsim-ng && \
127 mkdir /opt/dev/ntsim-ng/config && \
128 mkdir /opt/dev/ntsim-ng/source
129 COPY ./ntsim-ng /opt/dev/ntsim-ng/source
130 COPY ./deploy/base/build_ntsim-ng.sh /opt/dev/ntsim-ng/build_ntsim-ng.sh
132 cd /opt/dev/ntsim-ng && \
133 sed -i '/argp/d' build_ntsim-ng.sh && \
136 # copy SSH related scripts and keys
137 COPY ./deploy/base/ca.key /home/netconf/.ssh/ca.key
138 COPY ./deploy/base/ca.pem /home/netconf/.ssh/ca.pem
139 COPY ./deploy/base/client.crt /home/netconf/.ssh/client.crt
140 COPY ./deploy/base/generate-ssh-keys.sh /home/netconf/.ssh/generate-ssh-keys.sh
142 #############################
143 #### Lightweight Base ####
144 #############################
147 LABEL maintainer="alexandru.stancu@highstreet-technologies.com / adrian.lita@highstreet-technologies.com"
149 RUN apt-get install -y \
156 # add netconf user and configure access
159 echo "netconf:netconf" | chpasswd && \
160 mkdir -p /home/netconf/.ssh
162 COPY --from=builder /usr/local/bin /usr/local/bin
163 COPY --from=builder /usr/local/lib /usr/local/lib
164 COPY --from=builder /usr/local/share /usr/local/share
166 COPY --from=builder /etc/sysrepo /etc/sysrepo
169 # use /opt/dev as working directory
173 # copy common NTS yang models
174 RUN mkdir /opt/dev/deploy
175 COPY ./deploy/base/yang /opt/dev/deploy/yang
177 # copy ntsim-ng and dependencies
178 COPY --from=builder /usr/bin/regxstring /usr/bin/regxstring
179 COPY --from=builder /opt/dev/ntsim-ng /opt/dev/ntsim-ng
181 # copy SSH related scripts and keys
182 COPY --from=builder /home/netconf/.ssh /home/netconf/.ssh
184 ### FTP configuration
187 mkdir /var/run/vsftpd && \
188 mkdir /var/run/vsftpd/empty && \
190 echo "Match User netconf\n ChrootDirectory /ftp\n X11Forwarding no\n AllowTcpForwarding no\n ForceCommand internal-sftp" >> /etc/ssh/sshd_config
192 COPY ./deploy/base/vsftpd.conf /etc/vsftpd.conf
193 COPY ./deploy/base/vsftpd.userlist /etc/vsftpd.userlist
194 COPY ./deploy/base/pm_files /ftp
196 WORKDIR /opt/dev/workspace
198 ENV SSH_CONNECTIONS=1
199 ENV TLS_CONNECTIONS=0
200 ENV IPv6_ENABLED=false