Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 1 | # 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 |
| 18 | FROM golang:1.12-stretch as builder |
| 19 | |
| 20 | # install prereqs |
Arjun E K | 57a7fcb | 2020-01-30 06:44:45 +0000 | [diff] [blame] | 21 | ENV PROTOC_VERSION 3.7.0 |
| 22 | ENV PROTOC_SHA256SUM a1b8ed22d6dc53c5b8680a6f1760a305b33ef471bece482e92728f00ba2a2969 |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 23 | |
| 24 | RUN 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 Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 32 | && go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger \ |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 33 | && go get -v github.com/golang/protobuf/protoc-gen-go |
| 34 | |
Matteo Scandolo | 47e69bb | 2019-08-28 15:41:12 -0700 | [diff] [blame] | 35 | WORKDIR /go/src/github.com/opencord/bbsim |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 36 | ENV GO111MODULE=on |
| 37 | ENV GOPROXY=https://proxy.golang.org |
| 38 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 39 | # copy and build |
| 40 | COPY . ./ |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 41 | RUN make protos |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 42 | RUN make build-bbsim |
| 43 | RUN make build-bbsimctl |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 44 | |
| 45 | # runtime parent |
| 46 | FROM golang:1.12-stretch |
| 47 | |
| 48 | # runtime prereqs |
| 49 | # the symlink on libpcap is because both alpine and debian come with 1.8.x, but |
| 50 | # debian symlinks it to 0.8 for historical reasons: |
| 51 | # https://packages.debian.org/stretch/libpcap0.8-dev |
| 52 | RUN apt-get update \ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 53 | && apt-get install -y libpcap-dev isc-dhcp-server network-manager tcpdump\ |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 54 | && ln -s /usr/lib/libpcap.so.1.8.1 /usr/lib/libpcap.so.0.8 |
| 55 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 56 | COPY ./configs/dhcpd.conf /etc/dhcp/ |
| 57 | RUN mv /usr/sbin/dhcpd /usr/local/bin/ \ |
| 58 | && mv /sbin/dhclient /usr/local/bin/ \ |
| 59 | && touch /var/lib/dhcp/dhcpd.leases |
| 60 | |
| 61 | WORKDIR /app |
Matteo Scandolo | 82c16d0 | 2019-09-24 09:34:32 -0700 | [diff] [blame] | 62 | COPY --from=builder /go/src/github.com/opencord/bbsim/bbsim /app/bbsim |
| 63 | COPY --from=builder /go/src/github.com/opencord/bbsim/bbsimctl /usr/bin/bbsimctl |
Matteo Scandolo | fe9ac25 | 2019-10-25 11:40:17 -0700 | [diff] [blame] | 64 | RUN mv /usr/sbin/tcpdump /usr/bin/tcpdump |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 65 | RUN chmod a+x /app/bbsim |
Matteo Scandolo | 82c16d0 | 2019-09-24 09:34:32 -0700 | [diff] [blame] | 66 | RUN chmod a+x /usr/bin/bbsimctl |
Matteo Scandolo | a42dd35 | 2019-09-30 15:46:43 -0700 | [diff] [blame] | 67 | RUN bbsimctl completion bash >> $HOME/.bashrc |
Matteo Scandolo | ff9d859 | 2020-03-05 10:02:40 -0800 | [diff] [blame] | 68 | COPY ./configs/bbsim.yaml ./configs/bbsim.yaml |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 69 | CMD [ '/app/bbsim' ] |