blob: c2a78a3eb89f415783440e8b51efe02e10a0fade [file] [log] [blame]
khenaidoocfee5f42018-07-19 22:47:38 -04001# -------------
2# Build stage
3
khenaidoob9203542018-09-17 22:56:37 -04004FROM golang:1.9.2-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
9# Prepare directory structure
khenaidooabad44c2018-08-03 16:58:35 -040010RUN ["mkdir", "-p", "/src", "src/protos"]
khenaidoocfee5f42018-07-19 22:47:38 -040011RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
khenaidooabad44c2018-08-03 16:58:35 -040012RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"]
khenaidoobf6e7bb2018-08-14 22:27:29 -040013#RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha-go"]
14
khenaidoocfee5f42018-07-19 22:47:38 -040015
16# Copy files
17ADD rw_core $GOPATH/src/github.com/opencord/voltha-go/rw_core
18ADD common $GOPATH/src/github.com/opencord/voltha-go/common
19ADD db $GOPATH/src/github.com/opencord/voltha-go/db
khenaidooabad44c2018-08-03 16:58:35 -040020ADD kafka $GOPATH/src/github.com/opencord/voltha-go/kafka
21
22# Copy required proto files
23# ... VOLTHA proos
24ADD protos/*.proto /src/protos/
25ADD protos/scripts/* /src/protos/
26
27# Install golang protobuf
28RUN go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
29RUN go get -u github.com/golang/protobuf/protoc-gen-go
30
31# Compile protobuf files
32RUN sh /src/protos/build_protos.sh /src/protos
khenaidoocfee5f42018-07-19 22:47:38 -040033
34# Build rw_core
khenaidoob9203542018-09-17 22:56:37 -040035RUN cd $GOPATH/src/github.com/opencord/voltha-go/rw_core && go get -d ./... && rm -rf $GOPATH/src/go.etcd.io/etcd/vendor/golang.org/x/net/trace && go build -o /src/rw_core
khenaidoocfee5f42018-07-19 22:47:38 -040036
37# -------------
38# Image creation stage
39
40FROM alpine:3.6
41
42# Set the working directory
43WORKDIR /app
44
45# Copy required files
46COPY --from=build-env /src/rw_core /app/
47