khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 1 | # ------------- |
| 2 | # Build stage |
| 3 | |
| 4 | FROM golang:1.9.2-alpine AS build-env |
| 5 | |
| 6 | # Install required packages |
| 7 | RUN apk add --no-cache wget git make build-base protobuf protobuf-dev |
| 8 | |
| 9 | # Prepare directory structure |
| 10 | RUN ["mkdir", "-p", "/src", "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 adapters/simulated_olt $GOPATH/src/github.com/opencord/voltha-go/adapters/simulated_olt |
| 16 | ADD adapters/common $GOPATH/src/github.com/opencord/voltha-go/adapters/common |
| 17 | ADD adapters/*.go $GOPATH/src/github.com/opencord/voltha-go/adapters/ |
| 18 | ADD common $GOPATH/src/github.com/opencord/voltha-go/common |
| 19 | ADD db $GOPATH/src/github.com/opencord/voltha-go/db |
| 20 | ADD kafka $GOPATH/src/github.com/opencord/voltha-go/kafka |
| 21 | |
| 22 | # Copy required proto files |
| 23 | # ... VOLTHA proos |
| 24 | ADD protos/*.proto /src/protos/ |
| 25 | ADD protos/scripts/* /src/protos/ |
| 26 | |
| 27 | # Install golang protobuf |
| 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 | |
| 31 | # Compile protobuf files |
| 32 | RUN sh /src/protos/build_protos.sh /src/protos |
| 33 | |
| 34 | # Build simulated_olt |
| 35 | RUN cd $GOPATH/src/github.com/opencord/voltha-go/adapters/simulated_olt && go get -d ./... && rm -rf $GOPATH/src/go.etcd.io/etcd/vendor/golang.org/x/net/trace && go build -o /src/simulated_olt |
| 36 | |
| 37 | # ------------- |
| 38 | # Image creation stage |
| 39 | |
| 40 | FROM alpine:3.6 |
| 41 | |
| 42 | # Set the working directory |
| 43 | WORKDIR /app |
| 44 | |
| 45 | # Copy required files |
| 46 | COPY --from=build-env /src/simulated_olt /app/ |
| 47 | |