Zack Williams | 41513bf | 2018-07-07 20:08:35 -0700 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 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 | 3559506 | 2018-02-08 08:34:39 -0500 | [diff] [blame] | 14 | # ------------- |
| 15 | # Build stage |
| 16 | |
Stephane Barbarie | c92b9e2 | 2018-04-17 10:11:19 -0400 | [diff] [blame] | 17 | FROM golang:1.9.2-alpine AS build-env |
Stephane Barbarie | 3559506 | 2018-02-08 08:34:39 -0500 | [diff] [blame] | 18 | |
| 19 | # Install required packages |
| 20 | RUN apk add --no-cache wget git libpcap-dev make build-base protobuf protobuf-dev |
| 21 | |
| 22 | # Prepare directory structure |
| 23 | RUN ["mkdir", "-p", "/src/pki", "/src/protos"] |
| 24 | RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"] |
| 25 | RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"] |
| 26 | |
| 27 | # Copy files |
| 28 | ADD ponsim/v2 $GOPATH/src/github.com/opencord/voltha/ponsim/v2 |
| 29 | ADD ponsim/v2 /src |
| 30 | ADD pki /src/pki |
| 31 | |
| 32 | # Copy required proto files |
| 33 | # ... VOLTHA protos |
| 34 | ADD voltha/protos/*.proto /src/protos/ |
| 35 | # ... BAL protos |
| 36 | ADD voltha/adapters/asfvolt16_olt/protos/*.proto /src/protos/ |
| 37 | # ... PONSIM protos |
| 38 | ADD ponsim/v2/protos/*.proto /src/protos/ |
| 39 | |
| 40 | # Install golang protobuf and pcap support |
| 41 | RUN go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway |
| 42 | RUN go get -u github.com/golang/protobuf/protoc-gen-go |
| 43 | RUN go get -u github.com/google/gopacket/pcap |
| 44 | |
| 45 | # Compile protobuf files |
| 46 | RUN sh /src/scripts/build_protos.sh /src/protos |
| 47 | |
| 48 | # Build ponsim |
| 49 | RUN cd /src && go get -d ./... && go build -o ponsim |
| 50 | |
| 51 | # ------------- |
| 52 | # Final stage |
| 53 | |
| 54 | FROM alpine |
| 55 | |
| 56 | # Install required packages |
| 57 | RUN apk add --no-cache libpcap-dev |
| 58 | WORKDIR /app |
| 59 | |
| 60 | # Copy required files |
| 61 | COPY --from=build-env /src/ponsim /app/ |
| 62 | COPY --from=build-env /src/pki /app/pki |
| 63 | |
| 64 | ENV VOLTHA_BASE /app |