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 apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y \
25 tzdata build-essential git cmake pkg-config \
26 # libyang dependencies
29 zlib1g-dev libssl-dev \
30 && rm -rf /var/lib/apt/lists/*
32 # add netconf user and configure access
34 adduser --system netconf && \
35 echo "netconf:netconf!" | chpasswd
37 # use /opt/dev as working directory
41 # get required build libs from git
43 git config --global advice.detachedHead false && \
44 git clone --single-branch --branch v1.7.14 https://github.com/DaveGamble/cJSON.git && \
45 git clone --single-branch --branch v1.0.240 https://github.com/CESNET/libyang.git && \
46 git clone --single-branch --branch v1.4.140 https://github.com/sysrepo/sysrepo.git && \
47 git clone --single-branch --branch libssh-0.9.2 https://git.libssh.org/projects/libssh.git && \
48 git clone --single-branch --branch v1.1.46 https://github.com/CESNET/libnetconf2.git && \
49 git clone --single-branch --branch v1.1.76 https://github.com/CESNET/netopeer2.git && \
50 git clone --single-branch --branch curl-7_72_0 https://github.com/curl/curl.git
52 # build and install cJSON
55 mkdir build && cd build && \
56 cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off && \
61 # build and install libyang
64 mkdir build && cd build && \
65 cmake -DCMAKE_BUILD_TYPE:String="Release" -DGEN_LANGUAGE_BINDINGS=ON -DGEN_CPP_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF -DENABLE_BUILD_TESTS=OFF .. && \
70 # build and install sysrepo
71 COPY ./deploy/base/common.h.in /opt/dev/sysrepo/src/common.h.in
74 mkdir build && cd build && \
75 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 .. && \
80 # build and install libssh-dev
83 mkdir build && cd build && \
84 cmake -DWITH_EXAMPLES=OFF .. && \
89 # build and install libnetconf2
92 mkdir build && cd build && \
93 cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF .. && \
98 # build and install netopeer2
101 mkdir build && cd build && \
102 cmake -DCMAKE_BUILD_TYPE:String="Release" -DGENERATE_HOSTKEY=OFF -DMERGE_LISTEN_CONFIG=OFF .. && \
106 # build and install cURL
109 mkdir build && cd build && \
110 cmake -DBUILD_TESTING=OFF .. && \
115 # regxstring copy, build and install
116 RUN mkdir /opt/dev/regxstring
117 COPY ./regxstring /opt/dev/regxstring
118 COPY ./deploy/base/build_regxstring.sh /opt/dev/regxstring/build_regxstring.sh
120 cd /opt/dev/regxstring && \
121 ./build_regxstring.sh && \
122 cp regxstring /usr/bin && \
125 # ntsim-ng copy and build
127 ENV BUILD_WITH_DEBUG=${BUILD_WITH_DEBUG}
130 mkdir /opt/dev/ntsim-ng && \
131 mkdir /opt/dev/ntsim-ng/config && \
132 mkdir /opt/dev/ntsim-ng/source
133 COPY ./ntsim-ng /opt/dev/ntsim-ng/source
134 COPY ./deploy/base/build_ntsim-ng.sh /opt/dev/ntsim-ng/build_ntsim-ng.sh
136 cd /opt/dev/ntsim-ng && \
137 sed -i '/argp/d' build_ntsim-ng.sh && \
138 ./build_ntsim-ng.sh && \
140 rm -f 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"
157 RUN apt-get update && apt-get install -y --no-install-recommends \
165 && rm -rf /var/lib/apt/lists/*
168 ENV BUILD_WITH_DEBUG=${BUILD_WITH_DEBUG}
169 RUN if [ -n "${BUILD_WITH_DEBUG}" ]; then DEBIAN_FRONTEND="noninteractive" apt-get install -y gdb valgrind nano mc && unset BUILD_WITH_DEBUG; fi
171 # add netconf user and configure access
174 echo "netconf:netconf!" | chpasswd && \
175 mkdir -p /home/netconf/.ssh
177 COPY --from=builder /usr/local/bin /usr/local/bin
178 COPY --from=builder /usr/local/lib /usr/local/lib
179 COPY --from=builder /usr/local/share /usr/local/share
181 COPY --from=builder /etc/sysrepo /etc/sysrepo
184 # use /opt/dev as working directory
188 # copy common NTS yang models
189 RUN mkdir /opt/dev/deploy
190 COPY ./deploy/base/yang /opt/dev/deploy/yang
192 # copy ntsim-ng and dependencies
193 COPY --from=builder /usr/bin/regxstring /usr/bin/regxstring
194 COPY --from=builder /opt/dev/ntsim-ng /opt/dev/ntsim-ng
196 # copy SSH related scripts and keys
197 COPY --from=builder /home/netconf/.ssh /home/netconf/.ssh
199 ### FTP and SFTP configuration
202 chown -R netconf:netconf /ftp && \
203 mkdir /var/run/vsftpd && \
204 mkdir /var/run/vsftpd/empty && \
206 echo "Match User netconf\n ChrootDirectory /\n X11Forwarding no\n AllowTcpForwarding no\n ForceCommand internal-sftp -d /ftp" >> /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}