khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 1 | # ------------- |
| 2 | # Build stage |
| 3 | |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame^] | 4 | FROM golang:1.10.7-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 | |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame^] | 9 | # Install protobuf requirements |
| 10 | RUN git clone https://github.com/googleapis/googleapis.git /usr/local/include/googleapis |
| 11 | RUN go get github.com/golang/protobuf/protoc-gen-go |
| 12 | RUN go get google.golang.org/genproto/googleapis/api/annotations |
| 13 | |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 14 | # Prepare directory structure |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 15 | RUN ["mkdir", "-p", "/src", "src/protos"] |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 16 | RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"] |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 17 | RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"] |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 18 | |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame^] | 19 | WORKDIR $GOPATH/src/github.com/opencord/voltha-go |
| 20 | |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 21 | # Copy files |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame^] | 22 | ADD rw_core ./rw_core |
| 23 | ADD common ./common |
| 24 | ADD db ./db |
| 25 | ADD kafka ./kafka |
| 26 | ADD vendor ./vendor |
| 27 | |
| 28 | # Install the protoc-gen-go |
| 29 | RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 30 | |
| 31 | # Copy required proto files |
| 32 | # ... VOLTHA proos |
| 33 | ADD protos/*.proto /src/protos/ |
| 34 | ADD protos/scripts/* /src/protos/ |
| 35 | |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 36 | # Compile protobuf files |
| 37 | RUN sh /src/protos/build_protos.sh /src/protos |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 38 | |
| 39 | # Build rw_core |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 40 | RUN cd rw_core && go build -o /src/rw_core |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 41 | |
| 42 | # ------------- |
| 43 | # Image creation stage |
| 44 | |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame^] | 45 | FROM alpine:3.8 |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 46 | |
| 47 | # Set the working directory |
| 48 | WORKDIR /app |
| 49 | |
| 50 | # Copy required files |
| 51 | COPY --from=build-env /src/rw_core /app/ |
| 52 | |