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