blob: 96d94d354efc8ee31aafa443b6902d4cd78e5a8f [file] [log] [blame]
Zack Williams41513bf2018-07-07 20:08:35 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
Stephane Barbarie35595062018-02-08 08:34:39 -050014# -------------
15# Build stage
16
Stephane Barbariec92b9e22018-04-17 10:11:19 -040017FROM golang:1.9.2-alpine AS build-env
Stephane Barbarie35595062018-02-08 08:34:39 -050018
19# Install required packages
20RUN apk add --no-cache wget git libpcap-dev make build-base protobuf protobuf-dev
21
22# Prepare directory structure
23RUN ["mkdir", "-p", "/src/pki", "/src/protos"]
24RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
25RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"]
26
27# Copy files
28ADD ponsim/v2 $GOPATH/src/github.com/opencord/voltha/ponsim/v2
29ADD ponsim/v2 /src
30ADD pki /src/pki
31
32# Copy required proto files
33# ... VOLTHA protos
34ADD voltha/protos/*.proto /src/protos/
35# ... BAL protos
36ADD voltha/adapters/asfvolt16_olt/protos/*.proto /src/protos/
37# ... PONSIM protos
38ADD ponsim/v2/protos/*.proto /src/protos/
39
40# Install golang protobuf and pcap support
41RUN go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
42RUN go get -u github.com/golang/protobuf/protoc-gen-go
43RUN go get -u github.com/google/gopacket/pcap
44
45# Compile protobuf files
46RUN sh /src/scripts/build_protos.sh /src/protos
47
48# Build ponsim
49RUN cd /src && go get -d ./... && go build -o ponsim
50
51# -------------
52# Final stage
53
54FROM alpine
55
56# Install required packages
57RUN apk add --no-cache libpcap-dev
58WORKDIR /app
59
60# Copy required files
61COPY --from=build-env /src/ponsim /app/
62COPY --from=build-env /src/pki /app/pki
63
64ENV VOLTHA_BASE /app