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 && \
140 ./build_ntsim-ng.sh && \
142 rm -f build_ntsim-ng.sh
144 # copy SSH related scripts and keys
145 COPY ./deploy/base/ca.key /home/netconf/.ssh/ca.key
146 COPY ./deploy/base/ca.pem /home/netconf/.ssh/ca.pem
147 COPY ./deploy/base/client.crt /home/netconf/.ssh/client.crt
148 COPY ./deploy/base/client.key /home/netconf/.ssh/client.key
149 COPY ./deploy/base/generate-ssh-keys.sh /home/netconf/.ssh/generate-ssh-keys.sh
151 #############################
152 #### Lightweight Base ####
153 #############################
157 LABEL maintainer="alexandru.stancu@highstreet-technologies.com / adrian.lita@highstreet-technologies.com"
162 ENV BUILD_WITH_DEBUG=${BUILD_WITH_DEBUG}
163 RUN if [ -n "${BUILD_WITH_DEBUG}" ]; then DEBIAN_FRONTEND="noninteractive" apt-get install -y gdb valgrind nano mc ; fi
165 RUN apt-get install -y --no-install-recommends \
172 && rm -rf /var/lib/apt/lists/* \
173 && unset BUILD_WITH_DEBUG
175 # add netconf user and configure access
178 echo "netconf:netconf!" | chpasswd && \
179 mkdir -p /home/netconf/.ssh
181 COPY --from=builder /usr/local/bin /usr/local/bin
182 COPY --from=builder /usr/local/lib /usr/local/lib
183 COPY --from=builder /usr/local/share /usr/local/share
185 COPY --from=builder /etc/sysrepo /etc/sysrepo
188 # use /opt/dev as working directory
192 # copy common NTS yang models
193 RUN mkdir /opt/dev/deploy
194 COPY ./deploy/base/yang /opt/dev/deploy/yang
196 # copy ntsim-ng and dependencies
197 COPY --from=builder /usr/bin/regxstring /usr/bin/regxstring
198 COPY --from=builder /opt/dev/ntsim-ng /opt/dev/ntsim-ng
200 # copy SSH related scripts and keys
201 COPY --from=builder /home/netconf/.ssh /home/netconf/.ssh
203 ### FTP and SFTP configuration
206 chown -R netconf:netconf /ftp && \
207 mkdir /var/run/vsftpd && \
208 mkdir /var/run/vsftpd/empty && \
210 echo "Match User netconf\n ChrootDirectory /\n X11Forwarding no\n AllowTcpForwarding no\n ForceCommand internal-sftp -d /ftp" >> /etc/ssh/sshd_config
212 COPY ./deploy/base/vsftpd.conf /etc/vsftpd.conf
213 COPY ./deploy/base/vsftpd.userlist /etc/vsftpd.userlist
214 COPY ./deploy/base/pm_files /ftp
216 WORKDIR /opt/dev/workspace
218 ENV SSH_CONNECTIONS=1
219 ENV TLS_CONNECTIONS=0
220 ENV IPv6_ENABLED=false
222 ARG NTS_BUILD_VERSION
223 ENV NTS_BUILD_VERSION=${NTS_BUILD_VERSION}
226 ENV NTS_BUILD_DATE=${NTS_BUILD_DATE}