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 |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame] | 11 | RUN go get google.golang.org/genproto/googleapis/api/annotations |
| 12 | |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 13 | # Prepare directory structure |
William Kurkian | daa6bb2 | 2019-03-07 12:26:28 -0500 | [diff] [blame^] | 14 | RUN ["mkdir", "-p", "/src"] |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [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 | cfee5f4 | 2018-07-19 22:47:38 -0400 | [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 | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 20 | # Copy files |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame] | 21 | ADD rw_core ./rw_core |
| 22 | ADD common ./common |
| 23 | ADD db ./db |
| 24 | ADD kafka ./kafka |
| 25 | ADD vendor ./vendor |
| 26 | |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 27 | # Build rw_core |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 28 | RUN cd rw_core && go build -o /src/rw_core |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 29 | |
| 30 | # ------------- |
| 31 | # Image creation stage |
| 32 | |
khenaidoo | ffe076b | 2019-01-15 16:08:08 -0500 | [diff] [blame] | 33 | FROM alpine:3.8 |
khenaidoo | cfee5f4 | 2018-07-19 22:47:38 -0400 | [diff] [blame] | 34 | |
| 35 | # Set the working directory |
| 36 | WORKDIR /app |
| 37 | |
| 38 | # Copy required files |
| 39 | COPY --from=build-env /src/rw_core /app/ |
| 40 | |