blob: 61933f8405cae17378847e2d9488507c83ef9c02 [file] [log] [blame]
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +09001# Copyright 2018-present Open Networking Foundation
Zack Williams86f87202018-10-05 10:36:32 -07002#
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#
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +09007# http://www.apache.org/licenses/LICENSE-2.0
Zack Williams86f87202018-10-05 10:36:32 -07008#
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.
14
15# bbsim dockerfile
16
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090017# builder parent
Matteo Scandolof7b260d2019-07-31 13:43:02 -070018FROM golang:1.12-stretch as builder
Zack Williams86f87202018-10-05 10:36:32 -070019
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090020# install prereqs
21ENV PROTOC_VERSION 3.6.1
22ENV PROTOC_SHA256SUM 6003de742ea3fcf703cfec1cd4a3380fd143081a2eb0e559065563496af27807
Zack Williams86f87202018-10-05 10:36:32 -070023
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090024RUN apt-get update \
25 && apt-get install -y unzip libpcap-dev \
26 && curl -L -o /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip \
27 && echo "$PROTOC_SHA256SUM /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip" | sha256sum -c - \
28 && unzip /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /tmp/protoc3 \
29 && mv /tmp/protoc3/bin/* /usr/local/bin/ \
30 && mv /tmp/protoc3/include/* /usr/local/include/ \
31 && go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \
Matteo Scandolof7b260d2019-07-31 13:43:02 -070032 && go get -v github.com/golang/protobuf/protoc-gen-go
33
Zack Williams2abf3932019-08-05 14:07:05 -070034WORKDIR /go/src/github.com/opencord/voltha-bbsim
Matteo Scandolof7b260d2019-07-31 13:43:02 -070035ENV GO111MODULE=on
36ENV GOPROXY=https://proxy.golang.org
37
38# get dependencies
39COPY go.mod go.sum ./
40RUN go mod download
41
42# build the protos
43COPY Makefile ./
44COPY openolt.proto ./
45COPY protos/ ./protos
46RUN make protos/openolt.pb.go
47COPY api/ ./api
48RUN make bbsimapi
Zack Williams86f87202018-10-05 10:36:32 -070049
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090050# copy and build
Matteo Scandolof7b260d2019-07-31 13:43:02 -070051COPY . ./
52RUN GO111MODULE=on go build -i -v -o bbsim
Keita NISHIMOTO3b8b9c02018-10-09 09:40:01 +090053
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090054# runtime parent
Matteo Scandolof7b260d2019-07-31 13:43:02 -070055FROM golang:1.12-stretch
Keita NISHIMOTO3b8b9c02018-10-09 09:40:01 +090056
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090057# runtime prereqs
58# the symlink on libpcap is because both alpine and debian come with 1.8.x, but
59# debian symlinks it to 0.8 for historical reasons:
60# https://packages.debian.org/stretch/libpcap0.8-dev
61RUN apt-get update \
Matteo Scandolof7b260d2019-07-31 13:43:02 -070062 && apt-get install -y libpcap-dev isc-dhcp-server network-manager\
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090063 && ln -s /usr/lib/libpcap.so.1.8.1 /usr/lib/libpcap.so.0.8
Keita NISHIMOTO3b8b9c02018-10-09 09:40:01 +090064
Keita NISHIMOTO3b8b9c02018-10-09 09:40:01 +090065COPY ./config/isc-dhcp-server /etc/default/
66COPY ./config/dhcpd.conf /etc/dhcp/
67RUN mv /usr/sbin/dhcpd /usr/local/bin/ \
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090068&& mv /sbin/dhclient /usr/local/bin/ \
69&& touch /var/lib/dhcp/dhcpd.leases
Keita NISHIMOTO3b8b9c02018-10-09 09:40:01 +090070
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090071WORKDIR /app
Zack Williams2abf3932019-08-05 14:07:05 -070072COPY --from=builder /go/src/github.com/opencord/voltha-bbsim/bbsim /app/bbsim
Zack Williams86f87202018-10-05 10:36:32 -070073
Keita NISHIMOTOca4da5f2018-10-15 22:48:52 +090074CMD [ '/app/bbsim' ]