khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [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 | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 5 | |
| 6 | # Install required packages |
| 7 | RUN apk add --no-cache wget git make build-base protobuf protobuf-dev |
| 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 |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame] | 11 | RUN go get google.golang.org/genproto/googleapis/api/annotations |
| 12 | |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 13 | # Prepare directory structure |
| 14 | RUN ["mkdir", "-p", "/src", "src/protos"] |
| 15 | RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"] |
| 16 | RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"] |
| 17 | |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame] | 18 | WORKDIR $GOPATH/src/github.com/opencord/voltha-go |
| 19 | |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 20 | # Copy files |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame] | 21 | ADD adapters/simulated_olt ./adapters/simulated_olt |
| 22 | ADD adapters/common ./adapters/common |
| 23 | ADD adapters/*.go ./adapters/ |
| 24 | ADD common ./common |
| 25 | ADD db ./db |
| 26 | ADD kafka ./kafka |
| 27 | ADD vendor ./vendor |
| 28 | |
| 29 | # Install the protoc-gen-go |
| 30 | RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 31 | |
| 32 | # Copy required proto files |
| 33 | # ... VOLTHA proos |
| 34 | ADD protos/*.proto /src/protos/ |
| 35 | ADD protos/scripts/* /src/protos/ |
| 36 | |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 37 | # Compile protobuf files |
| 38 | RUN sh /src/protos/build_protos.sh /src/protos |
| 39 | |
| 40 | # Build simulated_olt |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame] | 41 | RUN cd adapters/simulated_olt && go build -o /src/simulated_olt |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 42 | |
| 43 | # ------------- |
| 44 | # Image creation stage |
| 45 | |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame] | 46 | FROM alpine:3.8 |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 47 | |
| 48 | # Set the working directory |
| 49 | WORKDIR /app |
| 50 | |
| 51 | # Copy required files |
| 52 | COPY --from=build-env /src/simulated_olt /app/ |
| 53 | |