blob: c7c6a7098b8032592e4e04dfc3a568ea056c2bdf [file] [log] [blame]
Stephane Barbariea75791c2019-01-24 10:58:06 -05001# -------------
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/voltha/protos/go"]
17
18WORKDIR $GOPATH/src/github.com/opencord/voltha-go
19
20# Copy files
21ADD ro_core ./ro_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
29
30# Copy required proto files
31# ... VOLTHA proos
32ADD protos/*.proto /src/protos/
33ADD protos/scripts/* /src/protos/
34
35# Compile protobuf files
36RUN sh /src/protos/build_protos.sh /src/protos
37
38# Build ro_core
39RUN cd ro_core && go build -o /src/ro_core
40
41# -------------
42# Image creation stage
43
44FROM alpine:3.8
45
46# Set the working directory
47WORKDIR /app
48
49# Copy required files
50COPY --from=build-env /src/ro_core /app/
51