khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 1 | # ------------- |
| 2 | # Build stage |
| 3 | |
khenaidoo | b920354 | 2018-09-17 22:56:37 -0400 | [diff] [blame] | 4 | FROM golang:1.9.2-alpine AS build-env |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 5 | |
| 6 | # Install required packages |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 7 | RUN apk add --no-cache wget git make build-base protobuf protobuf-dev |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 8 | |
| 9 | # Prepare directory structure |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 10 | RUN ["mkdir", "-p", "/src", "src/protos"] |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 11 | RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"] |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 12 | RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"] |
khenaidoo | bf6e7bb | 2018-08-14 22:27:29 -0400 | [diff] [blame] | 13 | #RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha-go"] |
| 14 | |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 15 | |
| 16 | # Copy files |
| 17 | ADD rw_core $GOPATH/src/github.com/opencord/voltha-go/rw_core |
| 18 | ADD common $GOPATH/src/github.com/opencord/voltha-go/common |
| 19 | ADD db $GOPATH/src/github.com/opencord/voltha-go/db |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 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 |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 33 | |
| 34 | # Build rw_core |
khenaidoo | b920354 | 2018-09-17 22:56:37 -0400 | [diff] [blame] | 35 | RUN cd $GOPATH/src/github.com/opencord/voltha-go/rw_core && go get -d ./... && rm -rf $GOPATH/src/go.etcd.io/etcd/vendor/golang.org/x/net/trace && go build -o /src/rw_core |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 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/rw_core /app/ |
| 47 | |