khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 1 | # ------------- |
| 2 | # Build stage |
| 3 | |
| 4 | FROM golang:alpine AS build-env |
| 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 | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 13 | |
| 14 | # Copy files |
| 15 | ADD rw_core $GOPATH/src/github.com/opencord/voltha-go/rw_core |
| 16 | ADD common $GOPATH/src/github.com/opencord/voltha-go/common |
| 17 | ADD db $GOPATH/src/github.com/opencord/voltha-go/db |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame^] | 18 | ADD kafka $GOPATH/src/github.com/opencord/voltha-go/kafka |
| 19 | |
| 20 | # Copy required proto files |
| 21 | # ... VOLTHA proos |
| 22 | ADD protos/*.proto /src/protos/ |
| 23 | ADD protos/scripts/* /src/protos/ |
| 24 | |
| 25 | # Install golang protobuf |
| 26 | RUN go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway |
| 27 | RUN go get -u github.com/golang/protobuf/protoc-gen-go |
| 28 | |
| 29 | # Compile protobuf files |
| 30 | RUN sh /src/protos/build_protos.sh /src/protos |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 31 | |
| 32 | # Build rw_core |
| 33 | RUN cd $GOPATH/src/github.com/opencord/voltha-go/rw_core && go get -d ./... && go build -o /src/rw_core |
| 34 | |
| 35 | # ------------- |
| 36 | # Image creation stage |
| 37 | |
| 38 | FROM alpine:3.6 |
| 39 | |
| 40 | # Set the working directory |
| 41 | WORKDIR /app |
| 42 | |
| 43 | # Copy required files |
| 44 | COPY --from=build-env /src/rw_core /app/ |
| 45 | |