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 |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 18 | FROM golang:1.13.8-stretch as builder |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 19 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 20 | RUN apt-get update && apt-get install -y build-essential libpcap-dev |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 21 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 22 | ENV CGO_ENABLED=1 |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 23 | |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 24 | WORKDIR /app |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 25 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 26 | # copy and build |
| 27 | COPY . ./ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 28 | |
| 29 | RUN 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 Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 41 | |
| 42 | # runtime parent |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 43 | FROM ubuntu:18.04 |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 44 | |
| 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 |
| 49 | RUN apt-get update \ |
Matteo Scandolo | 4b3fc7e | 2019-09-17 16:49:54 -0700 | [diff] [blame] | 50 | && apt-get install -y libpcap-dev isc-dhcp-server network-manager tcpdump\ |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 51 | && ln -s /usr/lib/libpcap.so.1.8.1 /usr/lib/libpcap.so.0.9 |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 52 | |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 53 | COPY ./configs/dhcpd.conf /etc/dhcp/ |
| 54 | RUN mv /usr/sbin/dhcpd /usr/local/bin/ \ |
| 55 | && mv /sbin/dhclient /usr/local/bin/ \ |
| 56 | && touch /var/lib/dhcp/dhcpd.leases |
| 57 | |
| 58 | WORKDIR /app |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 59 | COPY --from=builder /app/bbsim /app/bbsim |
| 60 | COPY --from=builder /app/bbsimctl /usr/bin/bbsimctl |
Matteo Scandolo | fe9ac25 | 2019-10-25 11:40:17 -0700 | [diff] [blame] | 61 | RUN mv /usr/sbin/tcpdump /usr/bin/tcpdump |
Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame] | 62 | RUN chmod a+x /app/bbsim |
Matteo Scandolo | 82c16d0 | 2019-09-24 09:34:32 -0700 | [diff] [blame] | 63 | RUN chmod a+x /usr/bin/bbsimctl |
Matteo Scandolo | a42dd35 | 2019-09-30 15:46:43 -0700 | [diff] [blame] | 64 | RUN bbsimctl completion bash >> $HOME/.bashrc |
Matteo Scandolo | ff9d859 | 2020-03-05 10:02:40 -0800 | [diff] [blame] | 65 | COPY ./configs/bbsim.yaml ./configs/bbsim.yaml |
Zdravko Bozakov | 2da7634 | 2019-10-21 09:47:35 +0200 | [diff] [blame] | 66 | CMD [ '/app/bbsim' ] |