Stephane Barbarie | 3559506 | 2018-02-08 08:34:39 -0500 | [diff] [blame] | 1 | # ------------- |
| 2 | # Build stage |
| 3 | |
| 4 | FROM golang:alpine AS build-env |
| 5 | |
| 6 | # Install required packages |
| 7 | RUN apk add --no-cache wget git libpcap-dev make build-base protobuf protobuf-dev |
| 8 | |
| 9 | # Prepare directory structure |
| 10 | RUN ["mkdir", "-p", "/src/pki", "/src/protos"] |
| 11 | RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"] |
| 12 | RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"] |
| 13 | |
| 14 | # Copy files |
| 15 | ADD ponsim/v2 $GOPATH/src/github.com/opencord/voltha/ponsim/v2 |
| 16 | ADD ponsim/v2 /src |
| 17 | ADD pki /src/pki |
| 18 | |
| 19 | # Copy required proto files |
| 20 | # ... VOLTHA protos |
| 21 | ADD voltha/protos/*.proto /src/protos/ |
| 22 | # ... BAL protos |
| 23 | ADD voltha/adapters/asfvolt16_olt/protos/*.proto /src/protos/ |
| 24 | # ... PONSIM protos |
| 25 | ADD ponsim/v2/protos/*.proto /src/protos/ |
| 26 | |
| 27 | # Install golang protobuf and pcap support |
| 28 | RUN go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway |
| 29 | RUN go get -u github.com/golang/protobuf/protoc-gen-go |
| 30 | RUN go get -u github.com/google/gopacket/pcap |
| 31 | |
| 32 | # Compile protobuf files |
| 33 | RUN sh /src/scripts/build_protos.sh /src/protos |
| 34 | |
| 35 | # Build ponsim |
| 36 | RUN cd /src && go get -d ./... && go build -o ponsim |
| 37 | |
| 38 | # ------------- |
| 39 | # Final stage |
| 40 | |
| 41 | FROM alpine |
| 42 | |
| 43 | # Install required packages |
| 44 | RUN apk add --no-cache libpcap-dev |
| 45 | WORKDIR /app |
| 46 | |
| 47 | # Copy required files |
| 48 | COPY --from=build-env /src/ponsim /app/ |
| 49 | COPY --from=build-env /src/pki /app/pki |
| 50 | |
| 51 | ENV VOLTHA_BASE /app |