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 curl |
| 9 | |
| 10 | RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh |
| 11 | |
| 12 | RUN git clone https://github.com/googleapis/googleapis.git /usr/local/include/googleapis |
| 13 | |
| 14 | # Prepare directory structure |
| 15 | RUN ["mkdir", "-p", "/src", "src/protos"] |
| 16 | RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"] |
| 17 | RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"] |
| 18 | |
| 19 | # Install golang protobuf |
| 20 | RUN go get github.com/golang/protobuf/protoc-gen-go |
| 21 | RUN go get google.golang.org/genproto/googleapis/rpc/status |
| 22 | RUN go get google.golang.org/grpc/binarylog/grpc_binarylog_v1 |
| 23 | |
| 24 | # Copy files |
| 25 | ADD rw_core $GOPATH/src/github.com/opencord/voltha-go/rw_core |
| 26 | ADD common $GOPATH/src/github.com/opencord/voltha-go/common |
| 27 | ADD db $GOPATH/src/github.com/opencord/voltha-go/db |
| 28 | ADD kafka $GOPATH/src/github.com/opencord/voltha-go/kafka |
| 29 | ADD vendor $GOPATH/src/github.com/opencord/voltha-go/vendor |
| 30 | ADD afrouter $GOPATH/src/github.com/opencord/voltha-go/afrouter |
| 31 | ADD arouterd $GOPATH/src/github.com/opencord/voltha-go/arouterd |
| 32 | ADD Gopkg.lock $GOPATH/src/github.com/opencord/voltha-go |
| 33 | ADD Gopkg.toml $GOPATH/src/github.com/opencord/voltha-go |
| 34 | |
| 35 | |
| 36 | # Copy required proto files |
| 37 | # ... VOLTHA proos |
| 38 | ADD protos/*.proto /src/protos/ |
| 39 | ADD protos/scripts/* /src/protos/ |
| 40 | ADD afrouter/arouter.json /src |
| 41 | |
| 42 | # |
| 43 | # Copy generated executables here |
| 44 | WORKDIR $GOPATH/src/github.com/opencord/voltha-go |
| 45 | #RUN $GOPATH/bin/dep ensure -add github.com/coreos/etcd |
| 46 | |
| 47 | #RUN ls -ltrR /go/src/github.com/opencord/voltha-go |
| 48 | |
| 49 | # Install golang protobuf |
| 50 | #RUN go get github.com/golang/protobuf/protoc-gen-go |
| 51 | #RUN go get google.golang.org/genproto/googleapis/rpc/status |
| 52 | #RUN go get google.golang.org/grpc/binarylog/grpc_binarylog_v1 |
| 53 | RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go |
| 54 | |
| 55 | # Compile protobuf files |
| 56 | RUN sh /src/protos/build_protos.sh /src/protos |
| 57 | |
| 58 | # Build rw_core |
| 59 | RUN cd arouterd && go build -o /src/arouterd |
| 60 | |
| 61 | |
| 62 | # ------------- |
| 63 | # Image creation stage |
| 64 | |
| 65 | FROM alpine:3.6 |
| 66 | |
| 67 | # Set the working directory |
| 68 | WORKDIR /app |
| 69 | |
| 70 | # Copy required files |
| 71 | COPY --from=build-env /src/arouterd /app/ |