blob: 6513c0ef1f22af235d9b0f6c47c4234bb8ffc9ca [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
khenaidooffe076b2019-01-15 16:08:08 -050011RUN go get google.golang.org/genproto/googleapis/api/annotations
12
khenaidood2b6df92018-12-13 16:37:20 -050013# 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
khenaidooffe076b2019-01-15 16:08:08 -050018WORKDIR $GOPATH/src/github.com/opencord/voltha-go
19
khenaidood2b6df92018-12-13 16:37:20 -050020# Copy files
khenaidooffe076b2019-01-15 16:08:08 -050021ADD adapters/simulated_olt ./adapters/simulated_olt
22ADD adapters/common ./adapters/common
23ADD adapters/*.go ./adapters/
24ADD common ./common
25ADD db ./db
26ADD kafka ./kafka
27ADD vendor ./vendor
28
29# Install the protoc-gen-go
30RUN go install ./vendor/github.com/golang/protobuf/protoc-gen-go
khenaidood2b6df92018-12-13 16:37:20 -050031
32# Copy required proto files
33# ... VOLTHA proos
34ADD protos/*.proto /src/protos/
35ADD protos/scripts/* /src/protos/
36
khenaidood2b6df92018-12-13 16:37:20 -050037# Compile protobuf files
38RUN sh /src/protos/build_protos.sh /src/protos
39
40# Build simulated_olt
khenaidooffe076b2019-01-15 16:08:08 -050041RUN cd adapters/simulated_olt && go build -o /src/simulated_olt
khenaidood2b6df92018-12-13 16:37:20 -050042
43# -------------
44# Image creation stage
45
khenaidooffe076b2019-01-15 16:08:08 -050046FROM alpine:3.8
khenaidood2b6df92018-12-13 16:37:20 -050047
48# Set the working directory
49WORKDIR /app
50
51# Copy required files
52COPY --from=build-env /src/simulated_olt /app/
53