sslobodr | a3ea7d4 | 2019-01-16 15:03:16 -0500 | [diff] [blame] | 1 | # ------------- |
| 2 | # Build stage |
| 3 | |
| 4 | FROM golang:1.10-alpine AS build-env |
| 5 | |
| 6 | |
| 7 | # Install required packages |
| 8 | RUN apk add --no-cache wget git make build-base protobuf protobuf-dev |
| 9 | |
| 10 | RUN git clone https://github.com/googleapis/googleapis.git /usr/local/include/googleapis |
| 11 | |
| 12 | # Prepare directory structure |
| 13 | RUN ["mkdir", "-p", "/src", "src/protos"] |
| 14 | RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"] |
| 15 | RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"] |
| 16 | |
| 17 | # Install golang protobuf |
| 18 | RUN go get github.com/golang/protobuf/protoc-gen-go |
| 19 | RUN go get google.golang.org/genproto/googleapis/rpc/status |
| 20 | RUN go get google.golang.org/grpc/binarylog/grpc_binarylog_v1 |
| 21 | |
| 22 | # Copy files |
| 23 | ADD rw_core $GOPATH/src/github.com/opencord/voltha-go/rw_core |
| 24 | ADD common $GOPATH/src/github.com/opencord/voltha-go/common |
| 25 | ADD db $GOPATH/src/github.com/opencord/voltha-go/db |
| 26 | ADD kafka $GOPATH/src/github.com/opencord/voltha-go/kafka |
| 27 | ADD vendor $GOPATH/src/github.com/opencord/voltha-go/vendor |
| 28 | ADD afrouter $GOPATH/src/github.com/opencord/voltha-go/afrouter |
| 29 | |
| 30 | |
| 31 | # Copy required proto files |
| 32 | # ... VOLTHA proos |
| 33 | ADD protos/*.proto /src/protos/ |
| 34 | ADD protos/scripts/* /src/protos/ |
| 35 | ADD afrouter/arouter.json /src |
| 36 | |
| 37 | # |
| 38 | # Copy generated executables here |
| 39 | WORKDIR $GOPATH/src/github.com/opencord/voltha-go |
| 40 | |
| 41 | #RUN ls -ltrR /go/src/github.com/opencord/voltha-go |
| 42 | |
| 43 | # Install golang protobuf |
| 44 | #RUN go get github.com/golang/protobuf/protoc-gen-go |
| 45 | #RUN go get google.golang.org/genproto/googleapis/rpc/status |
| 46 | #RUN go get google.golang.org/grpc/binarylog/grpc_binarylog_v1 |
| 47 | RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go |
| 48 | |
| 49 | # Compile protobuf files |
| 50 | RUN sh /src/protos/build_protos.sh /src/protos |
| 51 | |
| 52 | # Build rw_core |
| 53 | RUN cd afrouter && go build -o /src/afrouter |
| 54 | |
| 55 | |
| 56 | # ------------- |
| 57 | # Image creation stage |
| 58 | |
| 59 | FROM alpine:3.6 |
| 60 | |
| 61 | # Set the working directory |
| 62 | WORKDIR /app |
| 63 | |
| 64 | # Copy required files |
| 65 | COPY --from=build-env /src/afrouter /app/ |
| 66 | COPY --from=build-env /src/arouter.json /app/ |
| 67 | COPY --from=build-env /src/protos/voltha.pb /app/ |
| 68 | WORKDIR config |
| 69 | WORKDIR /app |
| 70 | |
| 71 | #CMD cd /app && ./arouter -config config/arouter.voltha2.json |
| 72 | |
| 73 | # Set the config volume |
| 74 | |