blob: 4db18afbf10d807ed21d8726c07491cb7e0f3129 [file] [log] [blame]
khenaidood2b6df92018-12-13 16:37:20 -05001# -------------
2# Build stage
3
khenaidooffe076b2019-01-15 16:08:08 -05004FROM golang:1.10.7-alpine AS build-env
khenaidood2b6df92018-12-13 16:37:20 -05005
6# Install required packages
7RUN apk add --no-cache wget git make build-base protobuf protobuf-dev
8
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
khenaidood2b6df92018-12-13 16:37:20 -050014# Prepare directory structure
15RUN ["mkdir", "-p", "/src", "src/protos"]
16RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
17RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"]
18
khenaidooffe076b2019-01-15 16:08:08 -050019WORKDIR $GOPATH/src/github.com/opencord/voltha-go
20
khenaidood2b6df92018-12-13 16:37:20 -050021# Copy files
khenaidooffe076b2019-01-15 16:08:08 -050022ADD adapters/simulated_olt ./adapters/simulated_olt
23ADD adapters/common ./adapters/common
24ADD adapters/*.go ./adapters/
25ADD common ./common
26ADD db ./db
27ADD kafka ./kafka
28ADD vendor ./vendor
29
30# Install the protoc-gen-go
31RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go
khenaidood2b6df92018-12-13 16:37:20 -050032
33# Copy required proto files
34# ... VOLTHA proos
35ADD protos/*.proto /src/protos/
36ADD protos/scripts/* /src/protos/
37
khenaidood2b6df92018-12-13 16:37:20 -050038# Compile protobuf files
39RUN sh /src/protos/build_protos.sh /src/protos
40
41# Build simulated_olt
khenaidooffe076b2019-01-15 16:08:08 -050042RUN cd adapters/simulated_olt && go build -o /src/simulated_olt
khenaidood2b6df92018-12-13 16:37:20 -050043
44# -------------
45# Image creation stage
46
khenaidooffe076b2019-01-15 16:08:08 -050047FROM alpine:3.8
khenaidood2b6df92018-12-13 16:37:20 -050048
49# Set the working directory
50WORKDIR /app
51
52# Copy required files
53COPY --from=build-env /src/simulated_olt /app/
54