2 # ============LICENSE_START=======================================================
3 # Copyright (C) 2020 Nordix Foundation.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
20 FROM python:3.7.6-alpine3.11 as build
22 ARG libyang_version=v1.0-r5
23 ARG sysrepo_version=v0.7.9
24 ARG libnetconf2_version=v0.12-r2
25 ARG netopeer2_version=v0.7-r2
49 # v0.9.3 has somes bugs as warned in libnetconf2/CMakeLists.txt:237
50 && apk add --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/main libssh-dev==0.8.8-r0
52 RUN git config --global advice.detachedHead false
54 ENV PKG_CONFIG_PATH=/opt/lib64/pkgconfig
55 ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64
59 COPY patches/libyang/ ./patches/libyang/
61 && git clone --branch $libyang_version --depth 1 https://github.com/CESNET/libyang.git \
63 && for p in ../patches/libyang/*.patch; do patch -p1 -i $p; done \
64 && mkdir build && cd build \
65 && cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF \
66 -DCMAKE_INSTALL_PREFIX:PATH=/opt \
67 -DGEN_LANGUAGE_BINDINGS=ON \
68 -DPYTHON_MODULE_PATH:PATH=/opt/lib/python3.7/site-packages \
74 && git clone --depth 1 https://github.com/sysrepo/libredblack.git \
76 && ./configure --prefix=/opt --without-rbgen \
81 COPY patches/sysrepo/ ./patches/sysrepo/
83 && git clone --branch $sysrepo_version --depth 1 https://github.com/sysrepo/sysrepo.git \
85 && for p in ../patches/sysrepo/*.patch; do patch -p1 -i $p; done \
86 && mkdir build && cd build \
87 && cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_TESTS=OFF \
88 -DREPOSITORY_LOC:PATH=/opt/etc/sysrepo \
89 -DCMAKE_INSTALL_PREFIX:PATH=/opt \
90 -DGEN_PYTHON_VERSION=3 \
91 -DPYTHON_MODULE_PATH:PATH=/opt/lib/python3.7/site-packages \
97 COPY patches/libnetconf2/ ./patches/libnetconf2/
99 && git clone --branch $libnetconf2_version --depth 1 https://github.com/CESNET/libnetconf2.git \
101 && for p in ../patches/libnetconf2/*.patch; do patch -p1 -i $p; done \
102 && mkdir build && cd build \
103 && cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF \
104 -DCMAKE_INSTALL_PREFIX:PATH=/opt \
106 -DPYTHON_MODULE_PATH:PATH=/opt/lib/python3.7/site-packages \
112 COPY patches/Netopeer2/ ./patches/Netopeer2/
114 && git clone --branch $netopeer2_version --depth 1 https://github.com/CESNET/Netopeer2.git \
116 && for p in ../patches/Netopeer2/*.patch; do patch -p1 -i $p; done \
118 && mkdir build && cd build \
119 && cmake -DCMAKE_BUILD_TYPE:String="Release" \
120 -DCMAKE_INSTALL_PREFIX:PATH=/opt \
127 && cd Netopeer2/server \
128 && mkdir build && cd build \
129 && cmake -DCMAKE_BUILD_TYPE:String="Release" \
130 -DCMAKE_INSTALL_PREFIX:PATH=/opt \
135 FROM python:3.7.6-alpine3.11
136 LABEL authors="eliezio.oliveira@est.tech"
139 && pip install supervisor \
147 # v0.9.3 has somes bugs as warned in libnetconf2/CMakeLists.txt:237
148 && apk add --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/main libssh==0.8.8-r0 \
149 && rm -rf /var/cache/apk/*
151 COPY --from=build /opt/ /opt/
153 ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64
154 ENV PYTHONPATH=/opt/lib/python3.7/site-packages
159 # finish setup and add netconf user
160 RUN adduser --system --disabled-password --gecos 'Netconf User' netconf
162 ENV HOME=/home/netconf
163 VOLUME $HOME/.local/share/virtualenvs
164 # This is NOT a robust health check but it does help tox-docker to detect when
165 # it can start the tests.
166 HEALTHCHECK --interval=1s --start-period=2s --retries=10 CMD test -f /run/netopeer2-server.pid
170 COPY supervisord.conf /etc/supervisord.conf
171 RUN mkdir /etc/supervisord.d
173 COPY entrypoint.sh /opt/bin/
175 CMD /opt/bin/entrypoint.sh