Stephane Barbarie | 1408896 | 2017-06-01 16:56:55 -0400 | [diff] [blame] | 1 | # Copyright 2017 the original author or authors. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
Stephane Barbarie | 1408896 | 2017-06-01 16:56:55 -0400 | [diff] [blame] | 14 | |
| 15 | FROM centos:7 |
| 16 | |
Kim Kempf | 01e23a8 | 2018-02-09 14:23:50 -0800 | [diff] [blame^] | 17 | MAINTAINER Voltha Community <info@opennetworking.org> |
Stephane Barbarie | 1408896 | 2017-06-01 16:56:55 -0400 | [diff] [blame] | 18 | |
| 19 | # install required packages |
| 20 | RUN ["yum", "install", "-y", "epel-release"] |
| 21 | RUN ["yum", "install", "-y", "git", "make", "libtool", "libxml2-devel", "file", "libxslt-devel", "libssh-devel", "libcurl-devel", "python-pip", "libxml2-python", "openssh-server", "augeas-devel", "readline", "readline-devel", "openssl", "openssl-perl", "openssl-devel", "m2crypto", "which", "unzip", "gcc-c++", "gflags-devel", "gtest-devel", "clang", "c++-devel", "wget"] |
| 22 | RUN ["ssh-keygen", "-A"] |
| 23 | RUN ["pip", "install", "pyang"] |
| 24 | RUN ["yum", "clean", "packages"] |
| 25 | RUN ["yum", "clean", "headers"] |
| 26 | |
| 27 | # clone, build and install libnetconf |
| 28 | RUN set -e -x; \ |
| 29 | git clone https://github.com/CESNET/libnetconf.git /usr/src/libnetconf; \ |
| 30 | cd /usr/src/libnetconf; \ |
| 31 | ./configure --enable-tls --prefix='/usr'; \ |
| 32 | make; \ |
| 33 | make install; \ |
| 34 | ln -s /usr/lib/pkgconfig/libnetconf.pc /usr/lib64/pkgconfig/; \ |
| 35 | make clean; |
| 36 | |
| 37 | # clone netopeer |
| 38 | RUN set -e -x; \ |
| 39 | git clone https://github.com/CESNET/netopeer.git /usr/src/netopeer; |
| 40 | |
| 41 | # build and install netopeer-cli |
| 42 | RUN set -e -x; \ |
| 43 | cd /usr/src/netopeer/cli; \ |
| 44 | ./configure --enable-tls --prefix='/usr'; \ |
| 45 | make; \ |
| 46 | make install; \ |
| 47 | make clean; |
| 48 | |
| 49 | # build and install netopeer-server |
| 50 | RUN set -e -x; \ |
| 51 | cd /usr/src/netopeer/server; \ |
| 52 | ./configure --enable-tls --prefix='/usr'; \ |
| 53 | make; \ |
| 54 | make install; \ |
| 55 | cp -v config/datastore.xml /usr/etc/netopeer/cfgnetopeer/datastore.xml; \ |
| 56 | make clean; |
| 57 | |
| 58 | # clone, build and install protobuf |
| 59 | RUN set -e -x; \ |
| 60 | git clone -b v3.2.1 https://github.com/google/protobuf.git /usr/src/protobuf; \ |
| 61 | cd /usr/src/protobuf; \ |
| 62 | ./autogen.sh; \ |
| 63 | ./configure; \ |
| 64 | make; \ |
| 65 | make install; \ |
| 66 | ldconfig; \ |
| 67 | make clean; |
| 68 | |
| 69 | # Install golang |
| 70 | RUN set -e -x; \ |
| 71 | cd /tmp; \ |
| 72 | wget https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz; \ |
| 73 | tar -C /usr/local -xzf /tmp/go1.8.1.linux-amd64.tar.gz; \ |
| 74 | rm -f /tmp/go1.8.1.linux-amd64.tar.gz |
| 75 | |
| 76 | # Setup necessary environment variables |
| 77 | ENV GOROOT /usr/local/go |
| 78 | ENV PATH $PATH:$GOROOT/bin |
| 79 | |
| 80 | RUN ["mkdir", "/usr/local/share/go"] |
| 81 | ENV GOPATH /usr/local/share/go |
| 82 | ENV PATH $PATH:$GOPATH/bin |
| 83 | |
| 84 | # Install golang protobuf/grpc libraries |
| 85 | RUN set -e -x; \ |
| 86 | go get -u github.com/golang/protobuf/{proto,protoc-gen-go}; \ |
| 87 | go get -u google.golang.org/grpc; \ |
| 88 | go get -u github.com/hashicorp/consul/api; |
| 89 | |
| 90 | # Build and Install the golang Voltha GRPC client layer |
| 91 | COPY netopeer/voltha-grpc-client /usr/src/voltha-grpc-client |
| 92 | RUN set -e -x; \ |
| 93 | mkdir -p /usr/local/share/go/src/github.com/opencord/voltha/netconf; \ |
| 94 | ln -s /usr/src/voltha-grpc-client /usr/local/share/go/src/github.com/opencord/voltha/netconf/translator; \ |
| 95 | cd /usr/src/voltha-grpc-client; \ |
| 96 | go build -buildmode=c-shared -o voltha.so voltha.go; \ |
| 97 | mv voltha.so /usr/lib64; \ |
| 98 | mv voltha.h /usr/include; \ |
| 99 | cp voltha-defs.h /usr/include; \ |
| 100 | rm -f /usr/lib64/libvoltha.so; \ |
| 101 | ln -s /usr/lib64/voltha.so /usr/lib64/libvoltha.so; |
| 102 | |
| 103 | # ------------------------------------------------ |
| 104 | # Sample transapi implementation |
| 105 | # |
| 106 | # To demonstrate the integration with the netopeer netconf server |
| 107 | # |
| 108 | |
| 109 | # Build and Install the golang Voltha model conversion package |
| 110 | COPY netopeer/voltha-netconf-model /usr/src/voltha-netconf-model |
| 111 | RUN set -e -x; \ |
| 112 | cd /usr/src/voltha-netconf-model; \ |
| 113 | go build -buildmode=c-shared -o voltha-netconf-model.so netconf-model.go; \ |
| 114 | mv voltha-netconf-model.so /usr/lib64; \ |
| 115 | mv voltha-netconf-model.h /usr/include; \ |
| 116 | rm -f /usr/lib64/libvoltha-netconf-model.so; \ |
| 117 | ln -s /usr/lib64/voltha-netconf-model.so /usr/lib64/libvoltha-netconf-model.so; |
| 118 | |
| 119 | # Build and install the Voltha netconf transapi library |
| 120 | COPY netopeer/voltha-transapi /usr/src/netopeer/voltha-transapi |
| 121 | RUN set -e -x; \ |
| 122 | cd /usr/src/netopeer/voltha-transapi; \ |
| 123 | autoreconf --install; \ |
| 124 | ./configure --prefix='/usr'; \ |
| 125 | make; \ |
| 126 | make install; |
| 127 | |
| 128 | # Finally start the netopeer-server with debugging logs enabled |
| 129 | CMD ["/usr/bin/netopeer-server", "-v", "3"] |
| 130 | |
| 131 | # Expose the default netconf port |
| 132 | EXPOSE 830 |