This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
204 lines (173 loc) · 5.96 KB
/
Dockerfile
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#-
# ============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.7-alpine3.11 as build
ARG zlog_version=1.2.14
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 \
libssh-dev \
openssh-keygen \
openssl \
openssl-dev \
pcre-dev \
pkgconfig \
postgresql-dev \
protobuf-c-dev \
swig \
# for troubleshooting
ctags \
the_silver_searcher \
vim
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=OFF \
.. \
&& 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
# zlog
RUN set -eux \
&& git clone --branch $zlog_version --depth 1 https://github.com/HardySimpson/zlog \
&& cd zlog/src \
&& make PREFIX=/opt \
&& make install PREFIX=/opt
# 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 \
-DBUILD_EXAMPLES=0 \
-DBUILD_CPP_EXAMPLES=0 \
.. \
&& 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=OFF \
.. \
&& 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 \
-DMODEL_INSTALL=ON \
.. \
&& 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
RUN pip install --prefix /opt psycopg2
FROM python:3.7.7-alpine3.11 as stage0
RUN apk upgrade --no-cache --available
FROM scratch
LABEL authors="eliezio.oliveira@est.tech"
COPY --from=stage0 / /
RUN set -eux \
&& apk add --no-cache \
coreutils \
libcurl \
libev \
libssh \
openssl \
pcre \
postgresql-libs \
protobuf-c \
xmlstarlet
COPY --from=build /opt/ /opt/
ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64
ENV PYTHONPATH=/opt/lib/python3.7/site-packages
COPY patches/supervisor/ /usr/src/patches/supervisor/
RUN set -eux \
# the patches for supervisor only work for 4.1 release
&& pip install loguru "supervisor>=4.1,<4.2" virtualenv \
&& cd /usr/local/lib/python3.7/site-packages \
&& for p in /usr/src/patches/supervisor/*.patch; do patch -p1 -i $p; done
COPY config/ /config
VOLUME /config
COPY templates/ /templates
# finish setup and add netconf user
RUN adduser --system --disabled-password --gecos 'Netconf User' netconf
# This is NOT a robust health check but it does help tox-docker to detect when
# it can start the tests.
HEALTHCHECK --interval=1s --start-period=2s --retries=10 CMD test -f /run/netopeer2-server.pid
# SSH
EXPOSE 830
# TLS
EXPOSE 6513
COPY src/ /opt/
RUN mkdir /etc/supervisord.d
# Sensible defaults for loguru configuration
ENV LOGURU_FORMAT="<green>{time:YYYY-DD-MM HH:mm:ss.SSS}</green> {level: <5} [{module}] <lvl>{message}</lvl>"
ENV LOGURU_COLORIZE=True
CMD /opt/bin/entrypoint.sh