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 | |
Matteo Scandolo | 9145502 | 2020-07-20 15:42:32 -0700 | [diff] [blame] | 20 | RUN apt-get update && apt-get install -y build-essential=12.3 libpcap-dev=1.8.1-3 --no-install-recommends |
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 | 9145502 | 2020-07-20 15:42:32 -0700 | [diff] [blame] | 50 | && 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 Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 54 | && 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] | 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 |
Kent Hagerman | 60d6230 | 2020-03-10 17:02:36 -0400 | [diff] [blame] | 62 | COPY --from=builder /app/bbsim /app/bbsim |
| 63 | COPY --from=builder /app/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 | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame^] | 67 | COPY ./configs/ ./configs/ |
Matteo Scandolo | 9145502 | 2020-07-20 15:42:32 -0700 | [diff] [blame] | 68 | RUN bbsimctl completion bash >> "$HOME/.bashrc" |
Matteo Scandolo | 9145502 | 2020-07-20 15:42:32 -0700 | [diff] [blame] | 69 | CMD [ "/app/bbsim" ] |