blob: 2431fa97a087c83730cf274a638c3f56a0b7064a [file] [log] [blame]
khenaidoocfee5f42018-07-19 22:47:38 -04001# -------------
2# Build stage
3
4FROM golang:alpine AS build-env
5
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"]
khenaidoocfee5f42018-07-19 22:47:38 -040013
14# Copy files
15ADD rw_core $GOPATH/src/github.com/opencord/voltha-go/rw_core
16ADD common $GOPATH/src/github.com/opencord/voltha-go/common
17ADD db $GOPATH/src/github.com/opencord/voltha-go/db
khenaidooabad44c2018-08-03 16:58:35 -040018ADD kafka $GOPATH/src/github.com/opencord/voltha-go/kafka
19
20# Copy required proto files
21# ... VOLTHA proos
22ADD protos/*.proto /src/protos/
23ADD protos/scripts/* /src/protos/
24
25# Install golang protobuf
26RUN go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
27RUN go get -u github.com/golang/protobuf/protoc-gen-go
28
29# Compile protobuf files
30RUN sh /src/protos/build_protos.sh /src/protos
khenaidoocfee5f42018-07-19 22:47:38 -040031
32# Build rw_core
33RUN cd $GOPATH/src/github.com/opencord/voltha-go/rw_core && go get -d ./... && go build -o /src/rw_core
34
35# -------------
36# Image creation stage
37
38FROM alpine:3.6
39
40# Set the working directory
41WORKDIR /app
42
43# Copy required files
44COPY --from=build-env /src/rw_core /app/
45