aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/netconf-pnp-simulator/engine/Dockerfile
blob: 42660695377fdc1f2ccea360d79906eafa169320 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#-
# ============LICENSE_START=======================================================
#  Copyright (C) 2020 Nordix Foundation.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================

FROM python:3.7.6-alpine3.11 as build

ARG libyang_version=v1.0-r5
ARG sysrepo_version=v0.7.9
ARG libnetconf2_version=v0.12-r2
ARG netopeer2_version=v0.7-r2

WORKDIR /usr/src

RUN set -eux \
      && apk add \
         autoconf \
         bash \
         build-base \
         cmake \
         curl-dev \
         file \
         git \
         libev-dev \
         openssh-keygen \
         openssl \
         openssl-dev \
         pcre-dev \
         pkgconfig \
         protobuf-c-dev \
         swig \
         # for troubleshooting
         the_silver_searcher \
         vim \
      # v0.9.3 has somes bugs as warned in libnetconf2/CMakeLists.txt:237
      && apk add --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/main libssh-dev==0.8.8-r0

RUN git config --global advice.detachedHead false

ENV PKG_CONFIG_PATH=/opt/lib64/pkgconfig
ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64


# libyang
COPY patches/libyang/ ./patches/libyang/
RUN set -eux \
      && git clone --branch $libyang_version --depth 1 https://github.com/CESNET/libyang.git \
      && cd libyang \
      && for p in ../patches/libyang/*.patch; do patch -p1 -i $p; done \
      && mkdir build && cd build \
      && cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF \
         -DCMAKE_INSTALL_PREFIX:PATH=/opt \
         -DGEN_LANGUAGE_BINDINGS=ON \
         -DPYTHON_MODULE_PATH:PATH=/opt/lib/python3.7/site-packages \
         .. \
      && make -j2 \
      && make install

RUN set -eux \
      && git clone --depth 1 https://github.com/sysrepo/libredblack.git \
      && cd libredblack \
      && ./configure --prefix=/opt --without-rbgen \
      && make \
      && make install

# sysrepo
COPY patches/sysrepo/ ./patches/sysrepo/
RUN set -eux \
      && git clone --branch $sysrepo_version --depth 1 https://github.com/sysrepo/sysrepo.git \
      && cd sysrepo \
      && for p in ../patches/sysrepo/*.patch; do patch -p1 -i $p; done \
      && mkdir build && cd build \
      && cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_TESTS=OFF \
         -DREPOSITORY_LOC:PATH=/opt/etc/sysrepo \
         -DCMAKE_INSTALL_PREFIX:PATH=/opt \
         -DGEN_PYTHON_VERSION=3 \
         -DPYTHON_MODULE_PATH:PATH=/opt/lib/python3.7/site-packages \
         .. \
      && make -j2 \
      && make install

# libnetconf2
COPY patches/libnetconf2/ ./patches/libnetconf2/
RUN set -eux \
      && git clone --branch $libnetconf2_version --depth 1 https://github.com/CESNET/libnetconf2.git \
      && cd libnetconf2 \
      && for p in ../patches/libnetconf2/*.patch; do patch -p1 -i $p; done \
      && mkdir build && cd build \
      && cmake -DCMAKE_BUILD_TYPE:String="Release" -DENABLE_BUILD_TESTS=OFF \
         -DCMAKE_INSTALL_PREFIX:PATH=/opt \
         -DENABLE_PYTHON=ON \
         -DPYTHON_MODULE_PATH:PATH=/opt/lib/python3.7/site-packages \
         .. \
      && make \
      && make install

# keystore
COPY patches/Netopeer2/ ./patches/Netopeer2/
RUN set -eux \
      && git clone --branch $netopeer2_version --depth 1 https://github.com/CESNET/Netopeer2.git \
      && cd Netopeer2 \
      && for p in ../patches/Netopeer2/*.patch; do patch -p1 -i $p; done \
      && cd keystored \
      && mkdir build && cd build \
      && cmake -DCMAKE_BUILD_TYPE:String="Release" \
         -DCMAKE_INSTALL_PREFIX:PATH=/opt \
         .. \
      && make -j2 \
      && make install

# netopeer2
RUN set -eux \
      && cd Netopeer2/server \
      && mkdir build && cd build \
      && cmake -DCMAKE_BUILD_TYPE:String="Release" \
         -DCMAKE_INSTALL_PREFIX:PATH=/opt \
         .. \
      && make -j2 \
      && make install

FROM python:3.7.6-alpine3.11
LABEL authors="eliezio.oliveira@est.tech"

RUN set -eux \
      && pip install supervisor \
      && apk update \
      && apk upgrade -a \
      && apk add \
         libcurl \
         libev \
         pcre \
         protobuf-c \
      # v0.9.3 has somes bugs as warned in libnetconf2/CMakeLists.txt:237
      && apk add --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/main libssh==0.8.8-r0 \
      && rm -rf /var/cache/apk/*

COPY --from=build /opt/ /opt/

ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64

COPY config/ /config
VOLUME /config

# finish setup and add netconf user
RUN adduser --system --disabled-password --gecos 'Netconf User' netconf

ENV HOME=/home/netconf
VOLUME $HOME/.local/share/virtualenvs

EXPOSE 830

COPY supervisord.conf /etc/supervisord.conf
RUN mkdir /etc/supervisord.d

COPY entrypoint.sh /opt/bin/

CMD /opt/bin/entrypoint.sh