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 |
William Kurkian | daa6bb2 | 2019-03-07 12:26:28 -0500 | [diff] [blame^] | 14 | RUN ["mkdir", "-p", "/src"] |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 15 | RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"] |
William Kurkian | daa6bb2 | 2019-03-07 12:26:28 -0500 | [diff] [blame^] | 16 | RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha-go"] |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 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 | |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 29 | # Build simulated_olt |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame] | 30 | RUN cd adapters/simulated_olt && go build -o /src/simulated_olt |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 31 | |
| 32 | # ------------- |
| 33 | # Image creation stage |
| 34 | |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame] | 35 | FROM alpine:3.8 |
khenaidoo | d2b6df9 | 2018-12-13 16:37:20 -0500 | [diff] [blame] | 36 | |
| 37 | # Set the working directory |
| 38 | WORKDIR /app |
| 39 | |
| 40 | # Copy required files |
| 41 | COPY --from=build-env /src/simulated_olt /app/ |
| 42 | |