blob: 86e15bb495fa4ba1211749fc8d5d934b43405b29 [file] [log] [blame]
Matteo Scandolo4747d292019-08-05 11:50:18 -07001# Copyright 2018-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.
14
15# bbsim dockerfile
16
17# builder parent
18FROM golang:1.12-stretch as builder
19
20# install prereqs
21ENV PROTOC_VERSION 3.6.1
22ENV PROTOC_SHA256SUM 6003de742ea3fcf703cfec1cd4a3380fd143081a2eb0e559065563496af27807
23
24RUN 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 \
Zdravko Bozakov2da76342019-10-21 09:47:35 +020032 && go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger \
Matteo Scandolo4747d292019-08-05 11:50:18 -070033 && go get -v github.com/golang/protobuf/protoc-gen-go
34
Matteo Scandolo47e69bb2019-08-28 15:41:12 -070035WORKDIR /go/src/github.com/opencord/bbsim
Matteo Scandolo4747d292019-08-05 11:50:18 -070036ENV GO111MODULE=on
37ENV GOPROXY=https://proxy.golang.org
38
Matteo Scandolo4747d292019-08-05 11:50:18 -070039# build the protos
40COPY Makefile ./
41COPY api ./api
Matteo Scandolo4747d292019-08-05 11:50:18 -070042
43# copy and build
44COPY . ./
Zdravko Bozakov2da76342019-10-21 09:47:35 +020045RUN make dep # we cannot vendor dependencies unless the code is there
46RUN make protos
Matteo Scandolo40e067f2019-10-16 16:59:41 -070047RUN make build-bbsim
48RUN make build-bbsimctl
Matteo Scandolo4747d292019-08-05 11:50:18 -070049
50# runtime parent
51FROM golang:1.12-stretch
52
53# runtime prereqs
54# the symlink on libpcap is because both alpine and debian come with 1.8.x, but
55# debian symlinks it to 0.8 for historical reasons:
56# https://packages.debian.org/stretch/libpcap0.8-dev
57RUN apt-get update \
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -070058 && apt-get install -y libpcap-dev isc-dhcp-server network-manager tcpdump\
Matteo Scandolo4747d292019-08-05 11:50:18 -070059 && ln -s /usr/lib/libpcap.so.1.8.1 /usr/lib/libpcap.so.0.8
60
Matteo Scandolo4747d292019-08-05 11:50:18 -070061COPY ./configs/dhcpd.conf /etc/dhcp/
62RUN mv /usr/sbin/dhcpd /usr/local/bin/ \
63&& mv /sbin/dhclient /usr/local/bin/ \
64&& touch /var/lib/dhcp/dhcpd.leases
65
66WORKDIR /app
Matteo Scandolo82c16d02019-09-24 09:34:32 -070067COPY --from=builder /go/src/github.com/opencord/bbsim/bbsim /app/bbsim
68COPY --from=builder /go/src/github.com/opencord/bbsim/bbsimctl /usr/bin/bbsimctl
Matteo Scandolofe9ac252019-10-25 11:40:17 -070069RUN mv /usr/sbin/tcpdump /usr/bin/tcpdump
Matteo Scandolo4747d292019-08-05 11:50:18 -070070RUN chmod a+x /app/bbsim
Matteo Scandolo82c16d02019-09-24 09:34:32 -070071RUN chmod a+x /usr/bin/bbsimctl
Matteo Scandoloa42dd352019-09-30 15:46:43 -070072RUN bbsimctl completion bash >> $HOME/.bashrc
Zdravko Bozakov2da76342019-10-21 09:47:35 +020073CMD [ '/app/bbsim' ]