ebo | 3ecb7b3 | 2020-02-27 14:04:23 +0000 | [diff] [blame] | 1 | #- |
| 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 | |
| 20 | FROM python:3.7.6-alpine3.11 as build |
| 21 | |
| 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 |
| 26 | |
| 27 | WORKDIR /usr/src |
| 28 | |
| 29 | RUN 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 | |
| 52 | RUN git config --global advice.detachedHead false |
| 53 | |
| 54 | ENV PKG_CONFIG_PATH=/opt/lib64/pkgconfig |
| 55 | ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64 |
| 56 | |
| 57 | |
| 58 | # libyang |
| 59 | COPY patches/libyang/ ./patches/libyang/ |
| 60 | RUN 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 | |
| 73 | RUN 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 |
| 81 | COPY patches/sysrepo/ ./patches/sysrepo/ |
| 82 | RUN 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 |
| 97 | COPY patches/libnetconf2/ ./patches/libnetconf2/ |
| 98 | RUN 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 |
| 112 | COPY patches/Netopeer2/ ./patches/Netopeer2/ |
| 113 | RUN 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 |
| 126 | RUN 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 | |
| 135 | FROM python:3.7.6-alpine3.11 |
| 136 | LABEL authors="eliezio.oliveira@est.tech" |
| 137 | |
| 138 | RUN set -eux \ |
| 139 | && pip install supervisor \ |
| 140 | && apk update \ |
| 141 | && apk upgrade -a \ |
| 142 | && apk add \ |
| 143 | libcurl \ |
| 144 | libev \ |
ebo | 3ecb7b3 | 2020-02-27 14:04:23 +0000 | [diff] [blame] | 145 | 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 | |
| 151 | COPY --from=build /opt/ /opt/ |
| 152 | |
| 153 | ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64 |
ebo | 769a791 | 2020-03-09 15:42:08 +0000 | [diff] [blame^] | 154 | ENV PYTHONPATH=/opt/lib/python3.7/site-packages |
ebo | 3ecb7b3 | 2020-02-27 14:04:23 +0000 | [diff] [blame] | 155 | |
| 156 | COPY config/ /config |
| 157 | VOLUME /config |
| 158 | |
| 159 | # finish setup and add netconf user |
| 160 | RUN adduser --system --disabled-password --gecos 'Netconf User' netconf |
| 161 | |
| 162 | ENV HOME=/home/netconf |
| 163 | VOLUME $HOME/.local/share/virtualenvs |
ebo | 769a791 | 2020-03-09 15:42:08 +0000 | [diff] [blame^] | 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 |
ebo | 3ecb7b3 | 2020-02-27 14:04:23 +0000 | [diff] [blame] | 167 | |
ebo | 3ecb7b3 | 2020-02-27 14:04:23 +0000 | [diff] [blame] | 168 | EXPOSE 830 |
| 169 | |
| 170 | COPY supervisord.conf /etc/supervisord.conf |
| 171 | RUN mkdir /etc/supervisord.d |
| 172 | |
| 173 | COPY entrypoint.sh /opt/bin/ |
| 174 | |
| 175 | CMD /opt/bin/entrypoint.sh |