blob: 897b316f1728a20974c0c26fb87a3d9c5d8ca1d3 [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
11RUN go get github.com/golang/protobuf/protoc-gen-go
12RUN go get google.golang.org/genproto/googleapis/api/annotations
13
khenaidoocfee5f42018-07-19 22:47:38 -040014# Prepare directory structure
khenaidooabad44c2018-08-03 16:58:35 -040015RUN ["mkdir", "-p", "/src", "src/protos"]
khenaidoocfee5f42018-07-19 22:47:38 -040016RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
khenaidooabad44c2018-08-03 16:58:35 -040017RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"]
khenaidoocfee5f42018-07-19 22:47:38 -040018
khenaidooffe076b2019-01-15 16:08:08 -050019WORKDIR $GOPATH/src/github.com/opencord/voltha-go
20
khenaidoocfee5f42018-07-19 22:47:38 -040021# Copy files
khenaidooffe076b2019-01-15 16:08:08 -050022ADD rw_core ./rw_core
23ADD common ./common
24ADD db ./db
25ADD kafka ./kafka
26ADD vendor ./vendor
27
28# Install the protoc-gen-go
29RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go
khenaidooabad44c2018-08-03 16:58:35 -040030
31# Copy required proto files
32# ... VOLTHA proos
33ADD protos/*.proto /src/protos/
34ADD protos/scripts/* /src/protos/
35
khenaidooabad44c2018-08-03 16:58:35 -040036# Compile protobuf files
37RUN sh /src/protos/build_protos.sh /src/protos
khenaidoocfee5f42018-07-19 22:47:38 -040038
39# Build rw_core
khenaidooac637102019-01-14 15:44:34 -050040RUN cd rw_core && go build -o /src/rw_core
khenaidoocfee5f42018-07-19 22:47:38 -040041
42# -------------
43# Image creation stage
44
khenaidooffe076b2019-01-15 16:08:08 -050045FROM alpine:3.8
khenaidoocfee5f42018-07-19 22:47:38 -040046
47# Set the working directory
48WORKDIR /app
49
50# Copy required files
51COPY --from=build-env /src/rw_core /app/
52