blob: ae3b9195358b99d77d9d94a1000189070f629038 [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
Matteo Scandolo91455022020-07-20 15:42:32 -070020RUN apt-get update && apt-get install -y build-essential=12.3 libpcap-dev=1.8.1-3 --no-install-recommends
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 Scandolo91455022020-07-20 15:42:32 -070050 && apt-get install -y libpcap-dev=1.8.1-6ubuntu1.18.04.1 isc-dhcp-server=4.3.5-3ubuntu7.1 \
51 network-manager=1.10.6-2ubuntu1.4 tcpdump=4.9.3-0ubuntu0.18.04.1 --no-install-recommends \
52 && apt-get clean \
53 && rm -rf /var/lib/apt/lists/* \
Kent Hagerman60d62302020-03-10 17:02:36 -040054 && ln -s /usr/lib/libpcap.so.1.8.1 /usr/lib/libpcap.so.0.9
Matteo Scandolo4747d292019-08-05 11:50:18 -070055
Matteo Scandolo4747d292019-08-05 11:50:18 -070056COPY ./configs/dhcpd.conf /etc/dhcp/
57RUN mv /usr/sbin/dhcpd /usr/local/bin/ \
58&& mv /sbin/dhclient /usr/local/bin/ \
59&& touch /var/lib/dhcp/dhcpd.leases
60
61WORKDIR /app
Kent Hagerman60d62302020-03-10 17:02:36 -040062COPY --from=builder /app/bbsim /app/bbsim
63COPY --from=builder /app/bbsimctl /usr/bin/bbsimctl
Matteo Scandolofe9ac252019-10-25 11:40:17 -070064RUN mv /usr/sbin/tcpdump /usr/bin/tcpdump
Matteo Scandolo4747d292019-08-05 11:50:18 -070065RUN chmod a+x /app/bbsim
Matteo Scandolo82c16d02019-09-24 09:34:32 -070066RUN chmod a+x /usr/bin/bbsimctl
Matteo Scandolo4a036262020-08-17 15:56:13 -070067COPY ./configs/ ./configs/
Matteo Scandolo91455022020-07-20 15:42:32 -070068RUN bbsimctl completion bash >> "$HOME/.bashrc"
Matteo Scandolo91455022020-07-20 15:42:32 -070069CMD [ "/app/bbsim" ]