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"
25 RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y \
27 tzdata build-essential git cmake pkg-config \
28 # libyang dependencies
31 zlib1g-dev libssl-dev \
32 && rm -rf /var/lib/apt/lists/*
34 # add netconf user and configure access
36 adduser --system netconf && \
37 echo "netconf:netconf!" | chpasswd
39 # use /opt/dev as working directory
43 # get required build libs from git
45 git config --global advice.detachedHead false && \
46 git clone --single-branch --branch v1.7.14 https://github.com/DaveGamble/cJSON.git && \
47 git clone --single-branch --branch v1.0.225 https://github.com/CESNET/libyang.git && \
48 git clone --single-branch --branch v1.4.122 https://github.com/sysrepo/sysrepo.git && \
49 git clone --single-branch --branch libssh-0.9.2 https://git.libssh.org/projects/libssh.git && \
50 git clone --single-branch --branch v1.1.43 https://github.com/CESNET/libnetconf2.git && \
51 git clone --single-branch --branch v1.1.70 https://github.com/CESNET/netopeer2.git && \
52 git clone --single-branch --branch curl-7_72_0 https://github.com/curl/curl.git
54 # build and install cJSON
57 mkdir build && cd build && \
58 cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off && \
63 # build and install libyang
66 mkdir build && cd build && \
67 cmake -DCMAKE_BUILD_TYPE:String="Release" -DGEN_LANGUAGE_BINDINGS=ON -DGEN_CPP_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF -DENABLE_BUILD_TESTS=OFF .. && \
72 # build and install sysrepo
73 COPY ./deploy/base/common.h.in /opt/dev/sysrepo/src/common.h.in
76 mkdir build && cd build && \
77 cmake -DCMAKE_BUILD_TYPE:String="Release" -DGEN_LANGUAGE_BINDINGS=ON -DGEN_CPP_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF -DENABLE_TESTS=OFF -DREPOSITORY_LOC:PATH=/etc/sysrepo -DREQUEST_TIMEOUT=60 -DOPER_DATA_PROVIDE_TIMEOUT=60 .. && \
82 # build and install libssh-dev
85 mkdir build && cd build && \
86 cmake -DWITH_EXAMPLES=OFF .. && \
91 # build and install libnetconf2
94 mkdir build && cd build && \
95 cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
100 # build and install netopeer2
103 mkdir build && cd build && \
104 cmake -DCMAKE_BUILD_TYPE:String="Release" -DGENERATE_HOSTKEY=OFF -DMERGE_LISTEN_CONFIG=OFF .. && \
108 # build and install cURL
111 mkdir build && cd build && \
112 cmake -DBUILD_TESTING=OFF .. && \
117 # regxstring copy, build and install
118 RUN mkdir /opt/dev/regxstring
119 COPY ./regxstring /opt/dev/regxstring
120 COPY ./deploy/base/build_regxstring.sh /opt/dev/regxstring/build_regxstring.sh
122 cd /opt/dev/regxstring && \
123 ./build_regxstring.sh && \
124 cp regxstring /usr/bin && \
127 # ntsim-ng copy and build
129 ENV BUILD_WITH_DEBUG=${BUILD_WITH_DEBUG}
132 mkdir /opt/dev/ntsim-ng && \
133 mkdir /opt/dev/ntsim-ng/config && \
134 mkdir /opt/dev/ntsim-ng/source
135 COPY ./ntsim-ng /opt/dev/ntsim-ng/source
136 COPY ./deploy/base/build_ntsim-ng.sh /opt/dev/ntsim-ng/build_ntsim-ng.sh
138 cd /opt/dev/ntsim-ng && \
139 sed -i '/argp/d' build_ntsim-ng.sh && \
142 # copy SSH related scripts and keys
143 COPY ./deploy/base/ca.key /home/netconf/.ssh/ca.key
144 COPY ./deploy/base/ca.pem /home/netconf/.ssh/ca.pem
145 COPY ./deploy/base/client.crt /home/netconf/.ssh/client.crt
146 COPY ./deploy/base/client.key /home/netconf/.ssh/client.key
147 COPY ./deploy/base/generate-ssh-keys.sh /home/netconf/.ssh/generate-ssh-keys.sh
149 #############################
150 #### Lightweight Base ####
151 #############################
155 LABEL maintainer="alexandru.stancu@highstreet-technologies.com / adrian.lita@highstreet-technologies.com"
160 ENV BUILD_WITH_DEBUG=${BUILD_WITH_DEBUG}
161 RUN if [ -n "${BUILD_WITH_DEBUG}" ]; then DEBIAN_FRONTEND="noninteractive" apt-get install -y gdb valgrind ; fi
163 RUN apt-get install -y --no-install-recommends \
169 && rm -rf /var/lib/apt/lists/* \
170 && unset BUILD_WITH_DEBUG
172 # add netconf user and configure access
175 echo "netconf:netconf!" | chpasswd && \
176 mkdir -p /home/netconf/.ssh
178 COPY --from=builder /usr/local/bin /usr/local/bin
179 COPY --from=builder /usr/local/lib /usr/local/lib
180 COPY --from=builder /usr/local/share /usr/local/share
182 COPY --from=builder /etc/sysrepo /etc/sysrepo
185 # use /opt/dev as working directory
189 # copy common NTS yang models
190 RUN mkdir /opt/dev/deploy
191 COPY ./deploy/base/yang /opt/dev/deploy/yang
193 # copy ntsim-ng and dependencies
194 COPY --from=builder /usr/bin/regxstring /usr/bin/regxstring
195 COPY --from=builder /opt/dev/ntsim-ng /opt/dev/ntsim-ng
197 # copy SSH related scripts and keys
198 COPY --from=builder /home/netconf/.ssh /home/netconf/.ssh
200 ### FTP configuration
203 mkdir /var/run/vsftpd && \
204 mkdir /var/run/vsftpd/empty && \
206 echo "Match User netconf\n ChrootDirectory /ftp\n X11Forwarding no\n AllowTcpForwarding no\n ForceCommand internal-sftp" >> /etc/ssh/sshd_config
208 COPY ./deploy/base/vsftpd.conf /etc/vsftpd.conf
209 COPY ./deploy/base/vsftpd.userlist /etc/vsftpd.userlist
210 COPY ./deploy/base/pm_files /ftp
212 WORKDIR /opt/dev/workspace
214 ENV SSH_CONNECTIONS=1
215 ENV TLS_CONNECTIONS=0
216 ENV IPv6_ENABLED=false
218 ARG NTS_BUILD_VERSION
219 ENV NTS_BUILD_VERSION=${NTS_BUILD_VERSION}
222 ENV NTS_BUILD_DATE=${NTS_BUILD_DATE}