blob: f67851bdf98736db7229028aa0cae73f3996623a [file] [log] [blame]
Stephane Barbarie35595062018-02-08 08:34:39 -05001# -------------
2# Build stage
3
Stephane Barbariec92b9e22018-04-17 10:11:19 -04004FROM golang:1.9.2-alpine AS build-env
Stephane Barbarie35595062018-02-08 08:34:39 -05005
6# Install required packages
7RUN apk add --no-cache wget git libpcap-dev make build-base protobuf protobuf-dev
8
9# Prepare directory structure
10RUN ["mkdir", "-p", "/src/pki", "/src/protos"]
11RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
12RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"]
13
14# Copy files
15ADD ponsim/v2 $GOPATH/src/github.com/opencord/voltha/ponsim/v2
16ADD ponsim/v2 /src
17ADD pki /src/pki
18
19# Copy required proto files
20# ... VOLTHA protos
21ADD voltha/protos/*.proto /src/protos/
22# ... BAL protos
23ADD voltha/adapters/asfvolt16_olt/protos/*.proto /src/protos/
24# ... PONSIM protos
25ADD ponsim/v2/protos/*.proto /src/protos/
26
27# Install golang protobuf and pcap support
28RUN go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
29RUN go get -u github.com/golang/protobuf/protoc-gen-go
30RUN go get -u github.com/google/gopacket/pcap
31
32# Compile protobuf files
33RUN sh /src/scripts/build_protos.sh /src/protos
34
35# Build ponsim
36RUN cd /src && go get -d ./... && go build -o ponsim
37
38# -------------
39# Final stage
40
41FROM alpine
42
43# Install required packages
44RUN apk add --no-cache libpcap-dev
45WORKDIR /app
46
47# Copy required files
48COPY --from=build-env /src/ponsim /app/
49COPY --from=build-env /src/pki /app/pki
50
51ENV VOLTHA_BASE /app