Stephane Barbarie | 1408896 | 2017-06-01 16:56:55 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2017 the original author or authors. |
| 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 | |
| 18 | FROM centos:7 |
| 19 | |
| 20 | MAINTAINER Stephane Barbarie <sbarbari@ciena.com> |
| 21 | |
| 22 | # install required packages |
| 23 | RUN ["yum", "install", "-y", "epel-release"] |
| 24 | 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"] |
| 25 | RUN ["ssh-keygen", "-A"] |
| 26 | RUN ["pip", "install", "pyang"] |
| 27 | RUN ["yum", "clean", "packages"] |
| 28 | RUN ["yum", "clean", "headers"] |
| 29 | |
| 30 | # clone, build and install libnetconf |
| 31 | RUN set -e -x; \ |
| 32 | git clone https://github.com/CESNET/libnetconf.git /usr/src/libnetconf; \ |
| 33 | cd /usr/src/libnetconf; \ |
| 34 | ./configure --enable-tls --prefix='/usr'; \ |
| 35 | make; \ |
| 36 | make install; \ |
| 37 | ln -s /usr/lib/pkgconfig/libnetconf.pc /usr/lib64/pkgconfig/; \ |
| 38 | make clean; |
| 39 | |
| 40 | # clone netopeer |
| 41 | RUN set -e -x; \ |
| 42 | git clone https://github.com/CESNET/netopeer.git /usr/src/netopeer; |
| 43 | |
| 44 | # build and install netopeer-cli |
| 45 | RUN set -e -x; \ |
| 46 | cd /usr/src/netopeer/cli; \ |
| 47 | ./configure --enable-tls --prefix='/usr'; \ |
| 48 | make; \ |
| 49 | make install; \ |
| 50 | make clean; |
| 51 | |
| 52 | # build and install netopeer-server |
| 53 | RUN set -e -x; \ |
| 54 | cd /usr/src/netopeer/server; \ |
| 55 | ./configure --enable-tls --prefix='/usr'; \ |
| 56 | make; \ |
| 57 | make install; \ |
| 58 | cp -v config/datastore.xml /usr/etc/netopeer/cfgnetopeer/datastore.xml; \ |
| 59 | make clean; |
| 60 | |
| 61 | # clone, build and install protobuf |
| 62 | RUN set -e -x; \ |
| 63 | git clone -b v3.2.1 https://github.com/google/protobuf.git /usr/src/protobuf; \ |
| 64 | cd /usr/src/protobuf; \ |
| 65 | ./autogen.sh; \ |
| 66 | ./configure; \ |
| 67 | make; \ |
| 68 | make install; \ |
| 69 | ldconfig; \ |
| 70 | make clean; |
| 71 | |
| 72 | # Install golang |
| 73 | RUN set -e -x; \ |
| 74 | cd /tmp; \ |
| 75 | wget https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz; \ |
| 76 | tar -C /usr/local -xzf /tmp/go1.8.1.linux-amd64.tar.gz; \ |
| 77 | rm -f /tmp/go1.8.1.linux-amd64.tar.gz |
| 78 | |
| 79 | # Setup necessary environment variables |
| 80 | ENV GOROOT /usr/local/go |
| 81 | ENV PATH $PATH:$GOROOT/bin |
| 82 | |
| 83 | RUN ["mkdir", "/usr/local/share/go"] |
| 84 | ENV GOPATH /usr/local/share/go |
| 85 | ENV PATH $PATH:$GOPATH/bin |
| 86 | |
| 87 | # Install golang protobuf/grpc libraries |
| 88 | RUN set -e -x; \ |
| 89 | go get -u github.com/golang/protobuf/{proto,protoc-gen-go}; \ |
| 90 | go get -u google.golang.org/grpc; \ |
| 91 | go get -u github.com/hashicorp/consul/api; |
| 92 | |
| 93 | # Build and Install the golang Voltha GRPC client layer |
| 94 | COPY netopeer/voltha-grpc-client /usr/src/voltha-grpc-client |
| 95 | RUN set -e -x; \ |
| 96 | mkdir -p /usr/local/share/go/src/github.com/opencord/voltha/netconf; \ |
| 97 | ln -s /usr/src/voltha-grpc-client /usr/local/share/go/src/github.com/opencord/voltha/netconf/translator; \ |
| 98 | cd /usr/src/voltha-grpc-client; \ |
| 99 | go build -buildmode=c-shared -o voltha.so voltha.go; \ |
| 100 | mv voltha.so /usr/lib64; \ |
| 101 | mv voltha.h /usr/include; \ |
| 102 | cp voltha-defs.h /usr/include; \ |
| 103 | rm -f /usr/lib64/libvoltha.so; \ |
| 104 | ln -s /usr/lib64/voltha.so /usr/lib64/libvoltha.so; |
| 105 | |
| 106 | # ------------------------------------------------ |
| 107 | # Sample transapi implementation |
| 108 | # |
| 109 | # To demonstrate the integration with the netopeer netconf server |
| 110 | # |
| 111 | |
| 112 | # Build and Install the golang Voltha model conversion package |
| 113 | COPY netopeer/voltha-netconf-model /usr/src/voltha-netconf-model |
| 114 | RUN set -e -x; \ |
| 115 | cd /usr/src/voltha-netconf-model; \ |
| 116 | go build -buildmode=c-shared -o voltha-netconf-model.so netconf-model.go; \ |
| 117 | mv voltha-netconf-model.so /usr/lib64; \ |
| 118 | mv voltha-netconf-model.h /usr/include; \ |
| 119 | rm -f /usr/lib64/libvoltha-netconf-model.so; \ |
| 120 | ln -s /usr/lib64/voltha-netconf-model.so /usr/lib64/libvoltha-netconf-model.so; |
| 121 | |
| 122 | # Build and install the Voltha netconf transapi library |
| 123 | COPY netopeer/voltha-transapi /usr/src/netopeer/voltha-transapi |
| 124 | RUN set -e -x; \ |
| 125 | cd /usr/src/netopeer/voltha-transapi; \ |
| 126 | autoreconf --install; \ |
| 127 | ./configure --prefix='/usr'; \ |
| 128 | make; \ |
| 129 | make install; |
| 130 | |
| 131 | # Finally start the netopeer-server with debugging logs enabled |
| 132 | CMD ["/usr/bin/netopeer-server", "-v", "3"] |
| 133 | |
| 134 | # Expose the default netconf port |
| 135 | EXPOSE 830 |