blob: d4776a4e47122279d524f2c865d3101ffc3af597 [file] [log] [blame]
ebo3ecb7b32020-02-27 14:04:23 +00001#-
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
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
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.
16#
17# SPDX-License-Identifier: Apache-2.0
18# ============LICENSE_END=========================================================
19
20FROM python:3.7.6-alpine3.11 as build
21
22ARG libyang_version=v1.0-r5
23ARG sysrepo_version=v0.7.9
24ARG libnetconf2_version=v0.12-r2
25ARG netopeer2_version=v0.7-r2
26
27WORKDIR /usr/src
28
29RUN set -eux \
30 && apk add \
31 autoconf \
32 bash \
33 build-base \
34 cmake \
35 curl-dev \
36 file \
37 git \
38 libev-dev \
39 openssh-keygen \
40 openssl \
41 openssl-dev \
42 pcre-dev \
43 pkgconfig \
44 protobuf-c-dev \
45 swig \
46 # for troubleshooting
47 the_silver_searcher \
48 vim \
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
51
52RUN git config --global advice.detachedHead false
53
54ENV PKG_CONFIG_PATH=/opt/lib64/pkgconfig
55ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64
56
57
58# libyang
59COPY patches/libyang/ ./patches/libyang/
60RUN set -eux \
61 && git clone --branch $libyang_version --depth 1 https://github.com/CESNET/libyang.git \
62 && cd libyang \
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 \
69 .. \
70 && make -j2 \
71 && make install
72
73RUN set -eux \
74 && git clone --depth 1 https://github.com/sysrepo/libredblack.git \
75 && cd libredblack \
76 && ./configure --prefix=/opt --without-rbgen \
77 && make \
78 && make install
79
80# sysrepo
81COPY patches/sysrepo/ ./patches/sysrepo/
82RUN set -eux \
83 && git clone --branch $sysrepo_version --depth 1 https://github.com/sysrepo/sysrepo.git \
84 && cd sysrepo \
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 \
92 .. \
93 && make -j2 \
94 && make install
95
96# libnetconf2
97COPY patches/libnetconf2/ ./patches/libnetconf2/
98RUN set -eux \
99 && git clone --branch $libnetconf2_version --depth 1 https://github.com/CESNET/libnetconf2.git \
100 && cd libnetconf2 \
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 \
105 -DENABLE_PYTHON=ON \
106 -DPYTHON_MODULE_PATH:PATH=/opt/lib/python3.7/site-packages \
107 .. \
108 && make \
109 && make install
110
111# keystore
112COPY patches/Netopeer2/ ./patches/Netopeer2/
113RUN set -eux \
114 && git clone --branch $netopeer2_version --depth 1 https://github.com/CESNET/Netopeer2.git \
115 && cd Netopeer2 \
116 && for p in ../patches/Netopeer2/*.patch; do patch -p1 -i $p; done \
117 && cd keystored \
118 && mkdir build && cd build \
119 && cmake -DCMAKE_BUILD_TYPE:String="Release" \
120 -DCMAKE_INSTALL_PREFIX:PATH=/opt \
121 .. \
122 && make -j2 \
123 && make install
124
125# netopeer2
126RUN set -eux \
127 && cd Netopeer2/server \
128 && mkdir build && cd build \
129 && cmake -DCMAKE_BUILD_TYPE:String="Release" \
130 -DCMAKE_INSTALL_PREFIX:PATH=/opt \
131 .. \
132 && make -j2 \
133 && make install
134
135FROM python:3.7.6-alpine3.11
136LABEL authors="eliezio.oliveira@est.tech"
137
138RUN set -eux \
139 && pip install supervisor \
140 && apk update \
141 && apk upgrade -a \
142 && apk add \
143 libcurl \
144 libev \
ebo3ecb7b32020-02-27 14:04:23 +0000145 pcre \
146 protobuf-c \
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/*
150
151COPY --from=build /opt/ /opt/
152
153ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64
ebo769a7912020-03-09 15:42:08 +0000154ENV PYTHONPATH=/opt/lib/python3.7/site-packages
ebo3ecb7b32020-02-27 14:04:23 +0000155
156COPY config/ /config
157VOLUME /config
158
159# finish setup and add netconf user
160RUN adduser --system --disabled-password --gecos 'Netconf User' netconf
161
162ENV HOME=/home/netconf
163VOLUME $HOME/.local/share/virtualenvs
ebo769a7912020-03-09 15:42:08 +0000164# This is NOT a robust health check but it does help tox-docker to detect when
165# it can start the tests.
166HEALTHCHECK --interval=1s --start-period=2s --retries=10 CMD test -f /run/netopeer2-server.pid
ebo3ecb7b32020-02-27 14:04:23 +0000167
ebo3ecb7b32020-02-27 14:04:23 +0000168EXPOSE 830
169
170COPY supervisord.conf /etc/supervisord.conf
171RUN mkdir /etc/supervisord.d
172
173COPY entrypoint.sh /opt/bin/
174
175CMD /opt/bin/entrypoint.sh