blob: 2fa46332ff2f9fdbd8bc1f7c21048e4232bcdc62 [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
Kent Hagerman60d62302020-03-10 17:02:36 -040018FROM golang:1.13.8-stretch as builder
Matteo Scandolo4747d292019-08-05 11:50:18 -070019
Kent Hagerman60d62302020-03-10 17:02:36 -040020RUN apt-get update && apt-get install -y build-essential libpcap-dev
Matteo Scandolo4747d292019-08-05 11:50:18 -070021
Kent Hagerman60d62302020-03-10 17:02:36 -040022ENV CGO_ENABLED=1
Matteo Scandolo4747d292019-08-05 11:50:18 -070023
Kent Hagerman60d62302020-03-10 17:02:36 -040024WORKDIR /app
Matteo Scandolo4747d292019-08-05 11:50:18 -070025
Matteo Scandolo4747d292019-08-05 11:50:18 -070026# copy and build
27COPY . ./
Kent Hagerman60d62302020-03-10 17:02:36 -040028
29RUN go build -mod vendor \
30 -ldflags "-w -X main.buildTime=$(date +%Y/%m/%d-%H:%M:%S) \
31 -X main.commitHash=$(git log --pretty=format:%H -n 1) \
32 -X main.gitStatus=${GIT_STATUS} \
33 -X main.version=${VERSION}" \
34 ./cmd/bbsim && \
35 go build -mod vendor \
36 -ldflags "-w -X github.com/opencord/bbsim/internal/bbsimctl/config.BuildTime=$(date +%Y/%m/%d-%H:%M:%S) \
37 -X github.com/opencord/bbsim/internal/bbsimctl/config.CommitHash=$(git log --pretty=format:%H -n 1) \
38 -X github.com/opencord/bbsim/internal/bbsimctl/config.GitStatus=${GIT_STATUS} \
39 -X github.com/opencord/bbsim/internal/bbsimctl/config.Version=${VERSION}" \
40 ./cmd/bbsimctl
Matteo Scandolo4747d292019-08-05 11:50:18 -070041
42# runtime parent
Kent Hagerman60d62302020-03-10 17:02:36 -040043FROM ubuntu:18.04
Matteo Scandolo4747d292019-08-05 11:50:18 -070044
45# runtime prereqs
46# the symlink on libpcap is because both alpine and debian come with 1.8.x, but
47# debian symlinks it to 0.8 for historical reasons:
48# https://packages.debian.org/stretch/libpcap0.8-dev
49RUN apt-get update \
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -070050 && apt-get install -y libpcap-dev isc-dhcp-server network-manager tcpdump\
Kent Hagerman60d62302020-03-10 17:02:36 -040051 && ln -s /usr/lib/libpcap.so.1.8.1 /usr/lib/libpcap.so.0.9
Matteo Scandolo4747d292019-08-05 11:50:18 -070052
Matteo Scandolo4747d292019-08-05 11:50:18 -070053COPY ./configs/dhcpd.conf /etc/dhcp/
54RUN mv /usr/sbin/dhcpd /usr/local/bin/ \
55&& mv /sbin/dhclient /usr/local/bin/ \
56&& touch /var/lib/dhcp/dhcpd.leases
57
58WORKDIR /app
Kent Hagerman60d62302020-03-10 17:02:36 -040059COPY --from=builder /app/bbsim /app/bbsim
60COPY --from=builder /app/bbsimctl /usr/bin/bbsimctl
Matteo Scandolofe9ac252019-10-25 11:40:17 -070061RUN mv /usr/sbin/tcpdump /usr/bin/tcpdump
Matteo Scandolo4747d292019-08-05 11:50:18 -070062RUN chmod a+x /app/bbsim
Matteo Scandolo82c16d02019-09-24 09:34:32 -070063RUN chmod a+x /usr/bin/bbsimctl
Matteo Scandoloa42dd352019-09-30 15:46:43 -070064RUN bbsimctl completion bash >> $HOME/.bashrc
Matteo Scandoloff9d8592020-03-05 10:02:40 -080065COPY ./configs/bbsim.yaml ./configs/bbsim.yaml
Zdravko Bozakov2da76342019-10-21 09:47:35 +020066CMD [ '/app/bbsim' ]