blob: 714ead78d3fb1237664bdc1b85c10477e4d8f761 [file] [log] [blame]
khenaidoocfee5f42018-07-19 22:47:38 -04001# -------------
2# Build stage
3
khenaidooffe076b2019-01-15 16:08:08 -05004FROM golang:1.10.7-alpine AS build-env
khenaidoocfee5f42018-07-19 22:47:38 -04005
6# Install required packages
khenaidooabad44c2018-08-03 16:58:35 -04007RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
khenaidoocfee5f42018-07-19 22:47:38 -04008
khenaidooffe076b2019-01-15 16:08:08 -05009# Install protobuf requirements
10RUN git clone https://github.com/googleapis/googleapis.git /usr/local/include/googleapis
khenaidooffe076b2019-01-15 16:08:08 -050011RUN go get google.golang.org/genproto/googleapis/api/annotations
12
khenaidoocfee5f42018-07-19 22:47:38 -040013# Prepare directory structure
khenaidooabad44c2018-08-03 16:58:35 -040014RUN ["mkdir", "-p", "/src", "src/protos"]
khenaidoocfee5f42018-07-19 22:47:38 -040015RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
khenaidooabad44c2018-08-03 16:58:35 -040016RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"]
khenaidoocfee5f42018-07-19 22:47:38 -040017
khenaidooffe076b2019-01-15 16:08:08 -050018WORKDIR $GOPATH/src/github.com/opencord/voltha-go
19
khenaidoocfee5f42018-07-19 22:47:38 -040020# Copy files
khenaidooffe076b2019-01-15 16:08:08 -050021ADD rw_core ./rw_core
22ADD common ./common
23ADD db ./db
24ADD kafka ./kafka
25ADD vendor ./vendor
26
27# Install the protoc-gen-go
28RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go
khenaidooabad44c2018-08-03 16:58:35 -040029
30# Copy required proto files
31# ... VOLTHA proos
32ADD protos/*.proto /src/protos/
33ADD protos/scripts/* /src/protos/
34
khenaidooabad44c2018-08-03 16:58:35 -040035# Compile protobuf files
36RUN sh /src/protos/build_protos.sh /src/protos
khenaidoocfee5f42018-07-19 22:47:38 -040037
38# Build rw_core
khenaidooac637102019-01-14 15:44:34 -050039RUN cd rw_core && go build -o /src/rw_core
khenaidoocfee5f42018-07-19 22:47:38 -040040
41# -------------
42# Image creation stage
43
khenaidooffe076b2019-01-15 16:08:08 -050044FROM alpine:3.8
khenaidoocfee5f42018-07-19 22:47:38 -040045
46# Set the working directory
47WORKDIR /app
48
49# Copy required files
50COPY --from=build-env /src/rw_core /app/
51