blob: c9755915740e56d2b85677bf713dd598fe79c9f2 [file] [log] [blame]
Phaneendra Manda4c62c802019-03-06 21:37:49 +05301# -------------
2# Build stage
3
4FROM golang:1.10.7-alpine AS build-env
5
6# Install required packages
7RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
8
9# Install protobuf requirements
10RUN git clone https://github.com/googleapis/googleapis.git /usr/local/include/googleapis
11RUN go get google.golang.org/genproto/googleapis/api/annotations
12
13# Prepare directory structure
14RUN ["mkdir", "-p", "/src", "src/protos"]
15RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
16RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord"]
17RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha-go"]
18
19WORKDIR $GOPATH/src/github.com/opencord
20
21RUN git clone https://gerrit.opencord.org/voltha-go.git
22
23WORKDIR $GOPATH/src/github.com/opencord/voltha-go
24
25
26# Copy files
27ADD adaptercore ./adapters/openolt/adaptercore
28ADD config ./adapters/openolt/config
29ADD *.go ./adapters/openolt
30
31RUN ls ./adapters/openolt
32
33# Copy required proto files
34ADD openolt.proto ./protos
35
36# Install the protoc-gen-go
37RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go
38
39# Compile protobuf files
40RUN sh protos/scripts/build_protos.sh protos
41
42RUN protoc --go_out=Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor,plugins=grpc:$GOPATH/src -I protos -I /usr/local/include/googleapis protos/openolt.proto
43
44# Build openolt
45
46RUN cd adapters/openolt && go build -o /src/openolt
47
48# -------------
49# Image creation stage
50
51FROM alpine:3.8
52
53# Set the working directory
54WORKDIR /app
55
56# Copy required files
57COPY --from=build-env /src/openolt /app/
58