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 | 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 |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame^] | 19 | ADD vendor $GOPATH/src/github.com/opencord/voltha-go/vendor |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 20 | |
| 21 | # Copy required proto files |
| 22 | # ... VOLTHA proos |
| 23 | ADD protos/*.proto /src/protos/ |
| 24 | ADD protos/scripts/* /src/protos/ |
| 25 | |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame^] | 26 | WORKDIR $GOPATH/src/github.com/opencord/voltha-go |
| 27 | |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 28 | # Install golang protobuf |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame^] | 29 | RUN git clone https://github.com/googleapis/googleapis.git /usr/local/include/googleapis |
| 30 | RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go |
khenaidoo | abad44c | 2018-08-03 16:58:35 -0400 | [diff] [blame] | 31 | |
| 32 | # Compile protobuf files |
| 33 | RUN sh /src/protos/build_protos.sh /src/protos |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 34 | |
| 35 | # Build rw_core |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame^] | 36 | RUN cd rw_core && go build -o /src/rw_core |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 37 | |
| 38 | # ------------- |
| 39 | # Image creation stage |
| 40 | |
| 41 | FROM alpine:3.6 |
| 42 | |
| 43 | # Set the working directory |
| 44 | WORKDIR /app |
| 45 | |
| 46 | # Copy required files |
| 47 | COPY --from=build-env /src/rw_core /app/ |
| 48 | |